[mqtt.homeassistant] fix JSON Schema lights (#14717)

https://github.com/openhab/openhab-addons/pull/12238 was merged after
JSON Schema Light was implemented, and changed some assumptions.
this commit adjusts to the changed interface

Signed-off-by: Cody Cutrer <cody@cutrer.us>
This commit is contained in:
Cody Cutrer 2023-03-28 10:26:13 -06:00 committed by GitHub
parent 0a3d9ece3c
commit 2c2ba4bed1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -181,17 +181,18 @@ public class JSONSchemaLight extends AbstractRawSchemaLight {
}
if (jsonState.state != null) {
onOffValue.update(new StringType(jsonState.state));
onOffValue.update(onOffValue.parseCommand(new StringType(jsonState.state)));
if (brightnessValue.getChannelState() instanceof UnDefType) {
brightnessValue.update((OnOffType) onOffValue.getChannelState());
brightnessValue.update(brightnessValue.parseCommand((OnOffType) onOffValue.getChannelState()));
}
if (colorValue.getChannelState() instanceof UnDefType) {
colorValue.update((OnOffType) onOffValue.getChannelState());
colorValue.update(colorValue.parseCommand((OnOffType) onOffValue.getChannelState()));
}
}
if (jsonState.brightness != null) {
brightnessValue.update(new DecimalType(Objects.requireNonNull(jsonState.brightness)));
brightnessValue.update(
brightnessValue.parseCommand(new DecimalType(Objects.requireNonNull(jsonState.brightness))));
if (colorValue.getChannelState() instanceof HSBType) {
HSBType color = (HSBType) colorValue.getChannelState();
colorValue.update(new HSBType(color.getHue(), color.getSaturation(),