|
87 | 87 | import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2DeviceStatus.Shelly2DeviceStatusResult.Shelly2RGBStatus; |
88 | 88 | import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2DeviceStatus.Shelly2DeviceStatusResult.Shelly2RGBWStatus; |
89 | 89 | import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2DeviceStatus.Shelly2InputStatus; |
| 90 | +import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2DeviceStatus.Shelly2RGBCCTStatus; |
90 | 91 | import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2RelayStatus; |
91 | 92 | import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2RpcBaseMessage; |
92 | 93 | import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2StatusEm1; |
@@ -373,7 +374,7 @@ protected Shelly2GetConfigResult initProfile(ShellyDeviceProfile profile, ThingT |
373 | 374 | profile.status.lights.add(new ShellySettingsLight()); |
374 | 375 | fillRgbwSettings(profile, dc); |
375 | 376 | } |
376 | | - if (profile.isDuo && profile.isGen2) { |
| 377 | + if (profile.isDuo) { |
377 | 378 | fillDuoBulbSettings(profile, dc); |
378 | 379 | } |
379 | 380 | if (profile.isRGBBulb) { |
@@ -550,7 +551,7 @@ protected boolean fillDeviceStatus(ShellySettingsStatus status, Shelly2DeviceSta |
550 | 551 | updated |= updateEmStatus(11, status, result.em11, channelUpdate); |
551 | 552 | updated |= updateRollerStatus(0, status, result.cover0, channelUpdate); |
552 | 553 | updated |= updateDimmerStatus(0, status, result.light0, channelUpdate); |
553 | | - updated |= updateDuoBulbStatus(0, status, result.cct0, channelUpdate); |
| 554 | + updated |= updateDuoBulbStatus(0, status, result.cct0, result.rgbcct0, channelUpdate); |
554 | 555 | updated |= updateRGBWStatus(0, status, result.rgbw0, channelUpdate); |
555 | 556 | updated |= updateRGBBulbStatus(0, status, result.rgb0, channelUpdate); |
556 | 557 | if (channelUpdate) { |
@@ -1064,10 +1065,15 @@ protected void fillRgbwSettings(ShellyDeviceProfile profile, Shelly2GetConfigRes |
1064 | 1065 | } |
1065 | 1066 |
|
1066 | 1067 | protected void fillDuoBulbSettings(ShellyDeviceProfile profile, Shelly2GetConfigResult dc) { |
1067 | | - if (!(profile.isDuo && profile.isGen2)) { |
| 1068 | + if (!profile.isDuo) { |
1068 | 1069 | return; |
1069 | 1070 | } |
1070 | | - applyBulbLightSettings(profile, dc.cct0); |
| 1071 | + if (dc.rgbcct0 != null) { |
| 1072 | + profile.isRGBCCT = true; |
| 1073 | + applyBulbLightSettings(profile, dc.rgbcct0); |
| 1074 | + } else { |
| 1075 | + applyBulbLightSettings(profile, dc.cct0); |
| 1076 | + } |
1071 | 1077 | } |
1072 | 1078 |
|
1073 | 1079 | protected void fillRGBBulbSettings(ShellyDeviceProfile profile, Shelly2GetConfigResult dc) { |
@@ -1125,13 +1131,24 @@ private boolean updateRGBWStatus(int id, ShellySettingsStatus status, @Nullable |
1125 | 1131 | value.white, null, channelUpdate, true); |
1126 | 1132 | } |
1127 | 1133 |
|
1128 | | - private boolean updateDuoBulbStatus(int id, ShellySettingsStatus status, @Nullable Shelly2CCTStatus value, |
1129 | | - boolean channelUpdate) throws ShellyApiException { |
| 1134 | + private boolean updateDuoBulbStatus(int id, ShellySettingsStatus status, @Nullable Shelly2CCTStatus cctValue, |
| 1135 | + @Nullable Shelly2RGBCCTStatus rgbcctValue, boolean channelUpdate) throws ShellyApiException { |
1130 | 1136 | ShellyDeviceProfile profile = getProfile(); |
1131 | | - if (!(profile.isDuo && profile.isGen2) || value == null) { |
| 1137 | + if (!profile.isDuo) { |
| 1138 | + return false; |
| 1139 | + } |
| 1140 | + if (profile.isRGBCCT && rgbcctValue != null) { |
| 1141 | + boolean inColor = "rgb".equals(rgbcctValue.mode); |
| 1142 | + profile.inColor = inColor; |
| 1143 | + profile.device.mode = inColor ? SHELLY_MODE_COLOR : SHELLY_MODE_WHITE; |
| 1144 | + return applyLightStatus(status, 0, rgbcctValue.output, rgbcctValue.brightness, |
| 1145 | + inColor ? rgbcctValue.rgb : null, null, inColor ? null : rgbcctValue.ct, channelUpdate, false); |
| 1146 | + } |
| 1147 | + if (cctValue == null) { |
1132 | 1148 | return false; |
1133 | 1149 | } |
1134 | | - return applyLightStatus(status, 0, value.output, value.brightness, null, null, value.ct, channelUpdate, false); |
| 1150 | + return applyLightStatus(status, 0, cctValue.output, cctValue.brightness, null, null, cctValue.ct, channelUpdate, |
| 1151 | + false); |
1135 | 1152 | } |
1136 | 1153 |
|
1137 | 1154 | private boolean updateRGBBulbStatus(int id, ShellySettingsStatus status, @Nullable Shelly2RGBStatus value, |
|
0 commit comments