|
68 | 68 | import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2DeviceSettings;
|
69 | 69 | import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2DeviceStatus.Shelly2DeviceStatusLight;
|
70 | 70 | import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2DeviceStatus.Shelly2DeviceStatusResult;
|
| 71 | +import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2DeviceStatus.Shelly2DeviceStatusResult.Shelly2RGBWStatus; |
71 | 72 | import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2DeviceStatus.Shelly2DeviceStatusSys.Shelly2DeviceStatusSysAvlUpdate;
|
72 | 73 | import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2NotifyEvent;
|
73 | 74 | import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2RpcBaseMessage;
|
@@ -306,6 +307,14 @@ public ShellyDeviceProfile getDeviceProfile(String thingType, @Nullable ShellySe
|
306 | 307 | fillDimmerSettings(profile, dc);
|
307 | 308 | }
|
308 | 309 | profile.status.lights = profile.isBulb ? new ArrayList<>() : null;
|
| 310 | + if (profile.isRGBW2) { |
| 311 | + ArrayList<ShellySettingsRgbwLight> rgbwLights = new ArrayList<>(); |
| 312 | + rgbwLights.add(new ShellySettingsRgbwLight()); |
| 313 | + profile.settings.lights = rgbwLights; |
| 314 | + profile.status.lights = new ArrayList<>(); |
| 315 | + profile.status.lights.add(new ShellySettingsLight()); |
| 316 | + fillRgbwSettings(profile, dc); |
| 317 | + } |
309 | 318 | profile.status.thermostats = profile.isTRV ? new ArrayList<>() : null;
|
310 | 319 |
|
311 | 320 | if (profile.hasBattery) {
|
@@ -920,6 +929,26 @@ public void setRollerPos(int relayIndex, int position) throws ShellyApiException
|
920 | 929 |
|
921 | 930 | @Override
|
922 | 931 | public ShellyStatusLight getLightStatus() throws ShellyApiException {
|
| 932 | + ShellyDeviceProfile profile = getProfile(); |
| 933 | + if (profile.isRGBW2) { |
| 934 | + Shelly2RGBWStatus ls = apiRequest( |
| 935 | + new Shelly2RpcRequest().withMethod(SHELLYRPC_METHOD_RGBW_STATUS).withId(0), |
| 936 | + Shelly2RGBWStatus.class); |
| 937 | + ShellyStatusLightChannel lightChannel = new ShellyStatusLightChannel(); |
| 938 | + lightChannel.red = ls.rgb[0]; |
| 939 | + lightChannel.green = ls.rgb[1]; |
| 940 | + lightChannel.blue = ls.rgb[2]; |
| 941 | + lightChannel.white = ls.white; |
| 942 | + lightChannel.brightness = ls.brightness.intValue(); |
| 943 | + |
| 944 | + ShellyStatusLight status = new ShellyStatusLight(); |
| 945 | + status.lights = new ArrayList<>(); |
| 946 | + status.lights.add(lightChannel); |
| 947 | + status.ison = ls.output; |
| 948 | + |
| 949 | + return status; |
| 950 | + } |
| 951 | + |
923 | 952 | throw new ShellyApiException("API call not implemented");
|
924 | 953 | }
|
925 | 954 |
|
@@ -1122,6 +1151,29 @@ public void setLightParm(int lightIndex, String parm, String value) throws Shell
|
1122 | 1151 |
|
1123 | 1152 | @Override
|
1124 | 1153 | public void setLightParms(int lightIndex, Map<String, String> parameters) throws ShellyApiException {
|
| 1154 | + Shelly2RpcRequestParams params = new Shelly2RpcRequestParams(); |
| 1155 | + if (getProfile().isRGBW2) { |
| 1156 | + String brightness = parameters.get(SHELLY_COLOR_BRIGHTNESS); |
| 1157 | + if (brightness != null) { |
| 1158 | + params.brightness = Integer.parseInt(brightness); |
| 1159 | + } |
| 1160 | + String red = parameters.get(SHELLY_COLOR_RED); |
| 1161 | + String green = parameters.get(SHELLY_COLOR_GREEN); |
| 1162 | + String blue = parameters.get(SHELLY_COLOR_BLUE); |
| 1163 | + if (red != null && green != null && blue != null) { |
| 1164 | + params.rgb = new Integer[] { Integer.parseInt(red), Integer.parseInt(green), Integer.parseInt(blue) }; |
| 1165 | + } |
| 1166 | + String white = parameters.get(SHELLY_COLOR_WHITE); |
| 1167 | + if (white != null) { |
| 1168 | + params.white = Integer.parseInt(white); |
| 1169 | + } |
| 1170 | + if (parameters.containsKey(SHELLY_LIGHT_TURN)) { |
| 1171 | + params.on = SHELLY_API_ON.equals(parameters.get(SHELLY_LIGHT_TURN)); |
| 1172 | + } |
| 1173 | + params.id = lightIndex; |
| 1174 | + |
| 1175 | + apiRequest(SHELLYRPC_METHOD_RGBW_SET, params, String.class); |
| 1176 | + } |
1125 | 1177 | throw new ShellyApiException("API call not implemented");
|
1126 | 1178 | }
|
1127 | 1179 |
|
|
0 commit comments