|
19 | 19 | import static org.mockito.Mockito.*; |
20 | 20 | import static org.openhab.binding.shelly.internal.ShellyBindingConstants.*; |
21 | 21 | import static org.openhab.binding.shelly.internal.ShellyDevices.*; |
| 22 | +import static org.openhab.binding.shelly.internal.api.ShellyLightApiComponentDTO.API_COMPONENT_CCT; |
| 23 | +import static org.openhab.binding.shelly.internal.api.ShellyLightApiComponentDTO.API_COMPONENT_RGB; |
22 | 24 | import static org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.SHELLY_ALWD_ROLLER_TURN_CLOSE; |
23 | 25 | import static org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.SHELLY_ALWD_ROLLER_TURN_OPEN; |
24 | 26 | import static org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.SHELLY_API_INVTEMP; |
|
40 | 42 | import org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.ShellyRollerStatus; |
41 | 43 | import org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.ShellySettingsDimmer; |
42 | 44 | import org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.ShellySettingsEMeter; |
| 45 | +import org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.ShellySettingsLight; |
43 | 46 | import org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.ShellySettingsMeter; |
44 | 47 | import org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.ShellySettingsRelay; |
| 48 | +import org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.ShellySettingsRgbwLight; |
45 | 49 | import org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.ShellySettingsStatus; |
46 | 50 | import org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.ShellyShortLightStatus; |
47 | 51 | import org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.ShellyStatusSensor; |
@@ -833,6 +837,28 @@ void updateSensorsMutePresentUpdatesSensorsMuteForSmoke() throws Exception { |
833 | 837 | verify(handler, never()).postEvent(any(), anyBoolean()); |
834 | 838 | } |
835 | 839 |
|
| 840 | + @Test |
| 841 | + void updateLightModeHybridProfileSkipsColorSlotAndUpdatesSecondaryComponent() throws Exception { |
| 842 | + ShellyDeviceProfile profile = proRgbwwPmHybridProfile(); |
| 843 | + ShellyThingInterface handler = mockHandler(profile); |
| 844 | + |
| 845 | + ShellySettingsStatus status = new ShellySettingsStatus(); |
| 846 | + ShellySettingsLight colorLight = new ShellySettingsLight(); // settings.lights[0], the "rgb" color slot |
| 847 | + ShellySettingsLight cctLight = new ShellySettingsLight(); // settings.lights[1], the "cct" secondary slot |
| 848 | + cctLight.ison = true; |
| 849 | + cctLight.brightness = 42; |
| 850 | + cctLight.temp = 4000; |
| 851 | + status.lights = new ArrayList<>(List.of(colorLight, cctLight)); |
| 852 | + |
| 853 | + boolean updated = ShellyComponents.updateLightMode(handler, status); |
| 854 | + |
| 855 | + assertThat(updated, is(true)); |
| 856 | + verify(handler, never()).updateChannel(eq(CHANNEL_GROUP_LIGHT_CONTROL), anyString(), any()); |
| 857 | + verify(handler).updateChannel(eq(CHANNEL_GROUP_LIGHT_INDEX + "1"), eq(CHANNEL_BRIGHTNESS + "$Switch"), |
| 858 | + eq(OnOffType.ON)); |
| 859 | + verify(handler).updateChannel(eq(CHANNEL_GROUP_LIGHT_INDEX + "1"), eq(CHANNEL_COLOR_TEMP), any()); |
| 860 | + } |
| 861 | + |
836 | 862 | private static ShellyThingInterface relayHandlerWith(ShellySettingsStatus profileStatus) { |
837 | 863 | ShellyDeviceProfile profile = new ShellyDeviceProfile(THING_TYPE_SHELLYPLUS1PM); |
838 | 864 | profile.isSensor = false; |
@@ -930,6 +956,18 @@ private static ShellyDeviceProfile gen1RollerProfile() { |
930 | 956 | return profile; |
931 | 957 | } |
932 | 958 |
|
| 959 | + // Pro RGBWW PM "rgbcct" profile: settings.lights[0] is the color (rgb) component, [1] is the secondary cct one |
| 960 | + private static ShellyDeviceProfile proRgbwwPmHybridProfile() { |
| 961 | + ShellyDeviceProfile profile = new ShellyDeviceProfile(THING_TYPE_SHELLYPRORGBWWPM); |
| 962 | + profile.inColor = true; |
| 963 | + ShellySettingsRgbwLight colorComponent = new ShellySettingsRgbwLight(); |
| 964 | + colorComponent.apiComponent = API_COMPONENT_RGB; |
| 965 | + ShellySettingsRgbwLight cctComponent = new ShellySettingsRgbwLight(); |
| 966 | + cctComponent.apiComponent = API_COMPONENT_CCT; |
| 967 | + profile.settings.lights = new ArrayList<>(List.of(colorComponent, cctComponent)); |
| 968 | + return profile; |
| 969 | + } |
| 970 | + |
933 | 971 | @Test |
934 | 972 | void deviceTotalKwhEm1dataPresentUsesDeviceTotal() { |
935 | 973 | ShellyDeviceProfile profile = emeterProfile(true, 2); |
|
0 commit comments