|
5 | 5 | from bleak.backends.device import BLEDevice |
6 | 6 |
|
7 | 7 | from ..const import SwitchbotModel |
8 | | -from ..const.light import ColorMode, StripLightColorMode |
| 8 | +from ..const.light import ColorMode, RGBICStripLightColorMode, StripLightColorMode |
9 | 9 | from .base_light import SwitchbotSequenceBaseLight |
10 | 10 | from .device import SwitchbotEncryptedDevice |
11 | 11 |
|
|
18 | 18 | StripLightColorMode.COLOR_TEMP: ColorMode.COLOR_TEMP, |
19 | 19 | StripLightColorMode.UNKNOWN: ColorMode.OFF, |
20 | 20 | } |
| 21 | +_RGBICWW_STRIP_LIGHT_COLOR_MODE_MAP = { |
| 22 | + RGBICStripLightColorMode.SEGMENTED: ColorMode.EFFECT, |
| 23 | + RGBICStripLightColorMode.RGB: ColorMode.RGB, |
| 24 | + RGBICStripLightColorMode.SCENE: ColorMode.EFFECT, |
| 25 | + RGBICStripLightColorMode.MUSIC: ColorMode.EFFECT, |
| 26 | + RGBICStripLightColorMode.CONTROLLER: ColorMode.EFFECT, |
| 27 | + RGBICStripLightColorMode.COLOR_TEMP: ColorMode.COLOR_TEMP, |
| 28 | + RGBICStripLightColorMode.UNKNOWN: ColorMode.OFF, |
| 29 | +} |
21 | 30 | LIGHT_STRIP_CONTROL_HEADER = "570F4901" |
22 | 31 | COMMON_EFFECTS = { |
23 | 32 | "christmas": [ |
|
97 | 106 | "570F490701000503600C2B35040C", |
98 | 107 | ], |
99 | 108 | } |
| 109 | +RGBIC_EFFECTS = { |
| 110 | + "romance": [ |
| 111 | + "570F490D01350100FF10EE", |
| 112 | + "570F490D0363", |
| 113 | + ], |
| 114 | + "energy": [ |
| 115 | + "570F490D01000300ED070F34FF14FFE114", |
| 116 | + "570F490D03FA", |
| 117 | + ], |
| 118 | + "heartbeat": [ |
| 119 | + "570F490D01020400FFDEADFE90FDFF9E3D", |
| 120 | + "570F490D01020403FCBAFD", |
| 121 | + "570F490D03FA", |
| 122 | + ], |
| 123 | + "party": [ |
| 124 | + "570F490D01030400FF8A47FF524DFF4DEE", |
| 125 | + "570F490D010304034DFF8C", |
| 126 | + "570F490D03FA", |
| 127 | + ], |
| 128 | + "dynamic": [ |
| 129 | + "570F490D010403004DFFFB4DFF4FFFBF4D", |
| 130 | + "570F490D03FA", |
| 131 | + ], |
| 132 | + "mystery": [ |
| 133 | + "570F490D01050300F660F6F6D460C6F660", |
| 134 | + "570F490D03FA", |
| 135 | + ], |
| 136 | + "lightning": [ |
| 137 | + "570F490D01340100FFD700", |
| 138 | + "570F490D03FA", |
| 139 | + ], |
| 140 | + "rock": [ |
| 141 | + "570F490D01090300B0F6606864FCFFBC3D", |
| 142 | + "570F490D03FA", |
| 143 | + ], |
| 144 | + "starlight": [ |
| 145 | + "570F490D010A0100FF8C00", |
| 146 | + "570F490D0363", |
| 147 | + ], |
| 148 | + "valentine_day": [ |
| 149 | + "570F490D010C0300FDE0FFFFCC8AD7FF8A", |
| 150 | + "570F490D03FA", |
| 151 | + ], |
| 152 | + "dream": [ |
| 153 | + "570F490D010E0300A3E5FF73F019FFA8E5", |
| 154 | + "570F490D03FA", |
| 155 | + ], |
| 156 | + "alarm": [ |
| 157 | + "570F490D013E0100FF0000", |
| 158 | + "570F490D03FA", |
| 159 | + ], |
| 160 | + "fireworks": [ |
| 161 | + "570F490D01110300FFAA33FFE233FF5CDF", |
| 162 | + "570F490D03FA", |
| 163 | + ], |
| 164 | + "waves": [ |
| 165 | + "570F490D013D01001E90FF", |
| 166 | + "570F490D03FA", |
| 167 | + ], |
| 168 | + "christmas": [ |
| 169 | + "570F490D01380400DC143C228B22DAA520", |
| 170 | + "570F490D0363", |
| 171 | + "570F490D0138040332CD32", |
| 172 | + "570F490D0363", |
| 173 | + ], |
| 174 | + "rainbow": [ |
| 175 | + "570F490D01160600FF0000FF7F00FFFF00", |
| 176 | + "570F490D03FA", |
| 177 | + "570F490D0116060300FF000000FF9400D3", |
| 178 | + "570F490D03FA", |
| 179 | + ], |
| 180 | + "game": [ |
| 181 | + "570F490D011A0400D05CFF668FFFFFEFD5", |
| 182 | + "570F490D0363", |
| 183 | + "570F490D011A0403FFC55C", |
| 184 | + "570F490D0363", |
| 185 | + ], |
| 186 | + "halloween": [ |
| 187 | + "570F490D01320300FF8C009370DB32CD32", |
| 188 | + "570F490D0364", |
| 189 | + ], |
| 190 | + "meditation": [ |
| 191 | + "570F490D013502001E90FF9370DB", |
| 192 | + "570F490D0364", |
| 193 | + ], |
| 194 | + "starlit_sky": [ |
| 195 | + "570F490D010D010099C8FF", |
| 196 | + "570F490D0364", |
| 197 | + ], |
| 198 | + "sleep": [ |
| 199 | + "570F490D01370300FF8C002E4E3E3E3E5E", |
| 200 | + "570F490D0364", |
| 201 | + ], |
| 202 | + "movie": [ |
| 203 | + "570F490D013602001919704B0082", |
| 204 | + "570F490D0364", |
| 205 | + ], |
| 206 | + "sunrise": [ |
| 207 | + "570F490D013F0200FFD700FF4500", |
| 208 | + "570F490D03FA", |
| 209 | + "570F490D03FA", |
| 210 | + ], |
| 211 | + "sunset": [ |
| 212 | + "570F490D01390300FF4500FFA500483D8B", |
| 213 | + "570F490D0363", |
| 214 | + "570F490D0363", |
| 215 | + ], |
| 216 | + "new_year": [ |
| 217 | + "570F490D013F0300FF0000FFD700228B22", |
| 218 | + "570F490D0364", |
| 219 | + ], |
| 220 | + "cherry_blossom": [ |
| 221 | + "570F490D01400200FFB3C1FF69B4", |
| 222 | + "570F490D0364", |
| 223 | + ], |
| 224 | +} |
100 | 225 |
|
101 | 226 |
|
102 | 227 | class SwitchbotLightStrip(SwitchbotSequenceBaseLight): |
@@ -177,3 +302,44 @@ async def verify_encryption_key( |
177 | 302 | def color_modes(self) -> set[ColorMode]: |
178 | 303 | """Return the supported color modes.""" |
179 | 304 | return {ColorMode.RGB, ColorMode.COLOR_TEMP} |
| 305 | + |
| 306 | + |
| 307 | +class SwitchbotRgbicLight(SwitchbotEncryptedDevice, SwitchbotLightStrip): |
| 308 | + """Support for Switchbot RGBIC lights.""" |
| 309 | + |
| 310 | + _effect_dict = RGBIC_EFFECTS |
| 311 | + |
| 312 | + def __init__( |
| 313 | + self, |
| 314 | + device: BLEDevice, |
| 315 | + key_id: str, |
| 316 | + encryption_key: str, |
| 317 | + interface: int = 0, |
| 318 | + model: SwitchbotModel = SwitchbotModel.RGBICWW_STRIP_LIGHT, |
| 319 | + **kwargs: Any, |
| 320 | + ) -> None: |
| 321 | + super().__init__(device, key_id, encryption_key, model, interface, **kwargs) |
| 322 | + |
| 323 | + @classmethod |
| 324 | + async def verify_encryption_key( |
| 325 | + cls, |
| 326 | + device: BLEDevice, |
| 327 | + key_id: str, |
| 328 | + encryption_key: str, |
| 329 | + model: SwitchbotModel = SwitchbotModel.RGBICWW_STRIP_LIGHT, |
| 330 | + **kwargs: Any, |
| 331 | + ) -> bool: |
| 332 | + return await super().verify_encryption_key( |
| 333 | + device, key_id, encryption_key, model, **kwargs |
| 334 | + ) |
| 335 | + |
| 336 | + @property |
| 337 | + def color_modes(self) -> set[ColorMode]: |
| 338 | + """Return the supported color modes.""" |
| 339 | + return {ColorMode.RGB, ColorMode.COLOR_TEMP} |
| 340 | + |
| 341 | + @property |
| 342 | + def color_mode(self) -> ColorMode: |
| 343 | + """Return the current color mode.""" |
| 344 | + device_mode = RGBICStripLightColorMode(self._get_adv_value("color_mode") or 10) |
| 345 | + return _RGBICWW_STRIP_LIGHT_COLOR_MODE_MAP.get(device_mode, ColorMode.OFF) |
0 commit comments