-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[homematic] Validate datapoint values before writing to config #12557
Conversation
HM config datapoint values on some devices can be out of their valid range in some cases, particularly if they are unused by the device currently [1]. Since openhab-core now validates attempts to update configuration by the thing handlers, make sure we always send a valid configuration even for those affected datapoints. [1] One example for such behaviour is HmIPW-DRBL4, which has multiple datapoints which depend on each other - POWERUP_JUMPTARGET can have values OFF, ON, OFF_DELAY, ON_DELAY - POWERUP_ONDELAY_VALUE, POWERUP_ONDELAY_UNIT are only used if POWERUP_JUMPTARGET has value ON_DELAY - likewise, POWERUP_OFFDELAY_VALUE and POWERUP_OFFDELAY_UNIT are only used if POWERUP_JUMPTARGET has value OFF_DELAY - if e.g. the POWERUP_JUMPTARGET is OFF, e.g. POWERUP_ONDELAY_VALUE might stay uninitialized by CCU and/or device itself, in which case it may be reported with an invalid value Signed-off-by: Danny Baumann <[email protected]>
ac8ae99
to
fa4d32b
Compare
...atic/src/main/java/org/openhab/binding/homematic/internal/handler/HomematicThingHandler.java
Outdated
Show resolved
Hide resolved
@@ -140,8 +140,7 @@ private void doInitializeInBackground() throws GatewayNotAvailableException, Hom | |||
loadHomematicChannelValues(channel); | |||
for (HmDatapoint dp : channel.getDatapoints()) { | |||
if (dp.getParamsetType() == HmParamsetType.MASTER) { | |||
config.put(MetadataUtils.getParameterName(dp), | |||
dp.isEnumType() ? dp.getOptionValue() : dp.getValue()); | |||
config.put(MetadataUtils.getParameterName(dp), getValueForConfiguration(dp)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As getValueForConfiguration can retrun null, I am not sure whether this config entry should be set to null, or not set at all ?
I am even not sure if this is valid to set a null value for a config parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only case under which getValueForConfiguration()
returns null is if the datapoint holds a null
value. In that case I'd say that writing null
into the config is correct.
The places I checked that care about the keys present in the map (those that call containsKey()
and keySet()
seem to be able to deal with null values being present. Not sure about e.g. the UI, but given the previous code put null
values in this case (value being null
) as well, I guess it should be fine.
...inding.homematic/src/main/java/org/openhab/binding/homematic/internal/model/HmDatapoint.java
Outdated
Show resolved
Hide resolved
...atic/src/main/java/org/openhab/binding/homematic/internal/handler/HomematicThingHandler.java
Outdated
Show resolved
Hide resolved
...inding.homematic/src/main/java/org/openhab/binding/homematic/internal/model/HmDatapoint.java
Outdated
Show resolved
Hide resolved
...inding.homematic/src/main/java/org/openhab/binding/homematic/internal/model/HmDatapoint.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Danny Baumann <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…ab#12557) * [homematic] Validate datapoint values before writing to config HM config datapoint values on some devices can be out of their valid range in some cases, particularly if they are unused by the device currently [1]. Since openhab-core now validates attempts to update configuration by the thing handlers, make sure we always send a valid configuration even for those affected datapoints. [1] One example for such behaviour is HmIPW-DRBL4, which has multiple datapoints which depend on each other - POWERUP_JUMPTARGET can have values OFF, ON, OFF_DELAY, ON_DELAY - POWERUP_ONDELAY_VALUE, POWERUP_ONDELAY_UNIT are only used if POWERUP_JUMPTARGET has value ON_DELAY - likewise, POWERUP_OFFDELAY_VALUE and POWERUP_OFFDELAY_UNIT are only used if POWERUP_JUMPTARGET has value OFF_DELAY - if e.g. the POWERUP_JUMPTARGET is OFF, e.g. POWERUP_ONDELAY_VALUE might stay uninitialized by CCU and/or device itself, in which case it may be reported with an invalid value Signed-off-by: Danny Baumann <[email protected]> Signed-off-by: Nick Waterton <[email protected]>
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/openhab-3-3-milestone-discussion/132715/130 |
…ab#12557) * [homematic] Validate datapoint values before writing to config HM config datapoint values on some devices can be out of their valid range in some cases, particularly if they are unused by the device currently [1]. Since openhab-core now validates attempts to update configuration by the thing handlers, make sure we always send a valid configuration even for those affected datapoints. [1] One example for such behaviour is HmIPW-DRBL4, which has multiple datapoints which depend on each other - POWERUP_JUMPTARGET can have values OFF, ON, OFF_DELAY, ON_DELAY - POWERUP_ONDELAY_VALUE, POWERUP_ONDELAY_UNIT are only used if POWERUP_JUMPTARGET has value ON_DELAY - likewise, POWERUP_OFFDELAY_VALUE and POWERUP_OFFDELAY_UNIT are only used if POWERUP_JUMPTARGET has value OFF_DELAY - if e.g. the POWERUP_JUMPTARGET is OFF, e.g. POWERUP_ONDELAY_VALUE might stay uninitialized by CCU and/or device itself, in which case it may be reported with an invalid value Signed-off-by: Danny Baumann <[email protected]>
…ab#12557) * [homematic] Validate datapoint values before writing to config HM config datapoint values on some devices can be out of their valid range in some cases, particularly if they are unused by the device currently [1]. Since openhab-core now validates attempts to update configuration by the thing handlers, make sure we always send a valid configuration even for those affected datapoints. [1] One example for such behaviour is HmIPW-DRBL4, which has multiple datapoints which depend on each other - POWERUP_JUMPTARGET can have values OFF, ON, OFF_DELAY, ON_DELAY - POWERUP_ONDELAY_VALUE, POWERUP_ONDELAY_UNIT are only used if POWERUP_JUMPTARGET has value ON_DELAY - likewise, POWERUP_OFFDELAY_VALUE and POWERUP_OFFDELAY_UNIT are only used if POWERUP_JUMPTARGET has value OFF_DELAY - if e.g. the POWERUP_JUMPTARGET is OFF, e.g. POWERUP_ONDELAY_VALUE might stay uninitialized by CCU and/or device itself, in which case it may be reported with an invalid value Signed-off-by: Danny Baumann <[email protected]> Signed-off-by: Andras Uhrin <[email protected]>
…ab#12557) * [homematic] Validate datapoint values before writing to config HM config datapoint values on some devices can be out of their valid range in some cases, particularly if they are unused by the device currently [1]. Since openhab-core now validates attempts to update configuration by the thing handlers, make sure we always send a valid configuration even for those affected datapoints. [1] One example for such behaviour is HmIPW-DRBL4, which has multiple datapoints which depend on each other - POWERUP_JUMPTARGET can have values OFF, ON, OFF_DELAY, ON_DELAY - POWERUP_ONDELAY_VALUE, POWERUP_ONDELAY_UNIT are only used if POWERUP_JUMPTARGET has value ON_DELAY - likewise, POWERUP_OFFDELAY_VALUE and POWERUP_OFFDELAY_UNIT are only used if POWERUP_JUMPTARGET has value OFF_DELAY - if e.g. the POWERUP_JUMPTARGET is OFF, e.g. POWERUP_ONDELAY_VALUE might stay uninitialized by CCU and/or device itself, in which case it may be reported with an invalid value Signed-off-by: Danny Baumann <[email protected]>
HM config datapoint values on some devices can be out of their valid
range in some cases, particularly if they are unused by the device
currently. Since openhab-core now validates attempts to update
configuration by the thing handlers, make sure we always send a valid
configuration even for those affected datapoints.
One example for such behaviour is HmIPW-DRBL4, which has multiple datapoints which depend on each other:
Fixes the issue reported here