From 1fc3ff7ecb18ee474364a86501a3d8113e07b66c Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Sun, 19 Nov 2023 11:45:03 -0700 Subject: [PATCH] [mqtt.homeassistant] Fix compilation problems Use Value.parseMessage in JSONSchemaLight instead of parseCommand, since that's what we're using it for. Compilation broke because PercentageValue.parseCommand now returns a Command (like Value does) instead of a PercentType (since it could be an OnOffType). Signed-off-by: Cody Cutrer --- .../internal/component/JSONSchemaLight.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/JSONSchemaLight.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/JSONSchemaLight.java index 1a279d553c283..b678d3830eaf0 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/JSONSchemaLight.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/JSONSchemaLight.java @@ -255,13 +255,15 @@ public void updateChannelState(ChannelUID channel, State state) { boolean off = false; if (jsonState.state != null) { - onOffValue.update(onOffValue.parseCommand(new StringType(jsonState.state))); + onOffValue.update((State) onOffValue.parseMessage(new StringType(jsonState.state))); off = onOffValue.getChannelState().equals(OnOffType.OFF); - if (brightnessValue.getChannelState() instanceof UnDefType) { - brightnessValue.update(off ? PercentType.ZERO : PercentType.HUNDRED); - } - if (colorValue.getChannelState() instanceof UnDefType) { - colorValue.update(off ? HSBType.BLACK : HSBType.WHITE); + if (onOffValue.getChannelState() instanceof OnOffType onOffState) { + if (brightnessValue.getChannelState() instanceof UnDefType) { + brightnessValue.update(Objects.requireNonNull(onOffState.as(PercentType.class))); + } + if (colorValue.getChannelState() instanceof UnDefType) { + colorValue.update(Objects.requireNonNull(onOffState.as(PercentType.class))); + } } }