[wemo] fix wrong brightness value for dimmer switch (#11385)

* [wemo] fix wrong brightness value for dimmer switch

Signed-off-by: Hans-Jörg Merk <github@hmerk.de>

* Update bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoDimmerHandler.java

Co-authored-by: Hilbrand Bouwkamp <hilbrand@h72.nl>

* Remove @Nullable on simple variable

Co-authored-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
This commit is contained in:
Hans-Jörg Merk 2021-10-15 19:37:07 +02:00 committed by GitHub
parent c6a89bebdd
commit 42c830bfda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -333,17 +333,18 @@ public class WemoDimmerHandler extends AbstractWemoHandler implements UpnpIOPart
new Object[] { variable, value, service, this.getThing().getUID() }); new Object[] { variable, value, service, this.getThing().getUID() });
updateStatus(ThingStatus.ONLINE); updateStatus(ThingStatus.ONLINE);
if (variable != null && value != null) { if (variable != null && value != null) {
String oldBinaryState = this.stateMap.get("BinaryState");
this.stateMap.put(variable, value); this.stateMap.put(variable, value);
}
if (variable != null && value != null) {
switch (variable) { switch (variable) {
case "BinaryState": case "BinaryState":
if (oldBinaryState == null || !oldBinaryState.equals(value)) {
State state = value.equals("0") ? OnOffType.OFF : OnOffType.ON; State state = value.equals("0") ? OnOffType.OFF : OnOffType.ON;
logger.debug("State '{}' for device '{}' received", state, getThing().getUID()); logger.debug("State '{}' for device '{}' received", state, getThing().getUID());
updateState(CHANNEL_BRIGHTNESS, state); updateState(CHANNEL_BRIGHTNESS, state);
if (state.equals(OnOffType.OFF)) { if (state.equals(OnOffType.OFF)) {
updateState(CHANNEL_TIMERSTART, OnOffType.OFF); updateState(CHANNEL_TIMERSTART, OnOffType.OFF);
} }
}
break; break;
case "brightness": case "brightness":
logger.debug("brightness '{}' for device '{}' received", value, getThing().getUID()); logger.debug("brightness '{}' for device '{}' received", value, getThing().getUID());