Skip to content

Commit

Permalink
[mqtt.homeassistant] Fix compilation problems
Browse files Browse the repository at this point in the history
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 <cody@cutrer.us>
  • Loading branch information
ccutrer committed Jan 30, 2024
1 parent f97999a commit 1fc3ff7
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}
}

Expand Down

0 comments on commit 1fc3ff7

Please sign in to comment.