[homematic] Fix updating enum config values (#14213)
When changing an enum value in the configuration, we used the wrong data type: while the value in the OH config is a string (the 'option value' - see HomematicThingHandler::getValueForConfiguration), internally we use an integer (the 'option index'), so we have to do the option value -> option index conversion when applying the new value. This especially was a problem for HM-MOD-EM-8 devices, which check the CHANNEL_FUNCTION enum value as part of their initialization routine. When disabling/enabling them after changing the CHANNEL_FUNCTION enum value, they went offline, because their initialization failed due to a NumberFormatException (via HomematicThingHandler::doInitializeInBackground -> HmChannel::checkForChannelFunctionChange -> HmChannel::getCurrentFunction) Signed-off-by: Danny Baumann <dannybaumann@web.de>
This commit is contained in:
parent
4e44de3894
commit
4dd60bb442
|
@ -601,8 +601,10 @@ public class HomematicThingHandler extends BaseThingHandler {
|
||||||
} else if (dp.isFloatType()) {
|
} else if (dp.isFloatType()) {
|
||||||
newValue = decimal.doubleValue();
|
newValue = decimal.doubleValue();
|
||||||
}
|
}
|
||||||
|
} else if (newValue instanceof String && dp.isEnumType()) {
|
||||||
|
newValue = dp.getOptionIndex((String) newValue);
|
||||||
}
|
}
|
||||||
if (!Objects.equals(dp.isEnumType() ? dp.getOptionValue() : dp.getValue(), newValue)) {
|
if (!Objects.equals(dp.getValue(), newValue)) {
|
||||||
sendDatapoint(dp, new HmDatapointConfig(), newValue);
|
sendDatapoint(dp, new HmDatapointConfig(), newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue