Skip to content

Commit 62cbe39

Browse files
committed
Add availability and effects => Version 1.1.0
1 parent 6855649 commit 62cbe39

File tree

5 files changed

+97
-6
lines changed

5 files changed

+97
-6
lines changed

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
# Jablotron RS485 Home Assistant Integration
2-
3-
For connecting to a JA-121-T using a Modbus to Ethernet adapter.
1+
# Lumic HomeAssistant Integration
2+
For connecting your HomeAssistant instance to the Lumic lighting system.

custom_components/lumic/const.py

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
name
2727
hardwareAddress
2828
deviceType
29+
online
2930
room {
3031
name
3132
}
@@ -41,6 +42,7 @@
4142
name
4243
hardwareAddress
4344
deviceType
45+
online
4446
room {
4547
name
4648
}

custom_components/lumic/light.py

+91-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
from homeassistant.components.light import (
1111
ATTR_BRIGHTNESS,
1212
ATTR_HS_COLOR,
13+
ATTR_EFFECT,
1314
SUPPORT_BRIGHTNESS,
1415
SUPPORT_COLOR,
16+
SUPPORT_EFFECT,
1517
LightEntity,
1618
)
1719
import homeassistant.util.color as color_util
@@ -122,14 +124,70 @@ def __init__(self, api, device_id, device_uuid, name):
122124
self._brightness = 0
123125
self._hs_color = [0, 0]
124126
self._state = False
127+
self._scenes: list[str] = [
128+
"Normal",
129+
"Flashing",
130+
"DeCongest",
131+
"ColorWipe",
132+
"ColorWipeBackwards",
133+
"ColorWipeRandom",
134+
"RandomColor",
135+
"RandomPixelColorSingle",
136+
"RainbowAll",
137+
"RainbowStream",
138+
"Scanner",
139+
"DualScanner",
140+
"RunningLight",
141+
"Sparkle",
142+
"RandomSparkle",
143+
"HyperSparkle",
144+
"RunningColor",
145+
"LarsonScanner",
146+
"Comet",
147+
"Fireworks",
148+
"RandomFireworks",
149+
"FireFlicker",
150+
"FireFlickerLight",
151+
"FireFlickerHeavy",
152+
"FireFlickerNaturely"
153+
]
154+
self._scenes_mapping: list[int] = [
155+
"0",
156+
"1",
157+
"2",
158+
"3",
159+
"5",
160+
"7",
161+
"8",
162+
"9",
163+
"11",
164+
"12",
165+
"13",
166+
"14",
167+
"18",
168+
"19",
169+
"20",
170+
"25",
171+
"40",
172+
"43",
173+
"44",
174+
"45",
175+
"46",
176+
"48",
177+
"49",
178+
"50",
179+
"55"
180+
]
181+
self._effect = None
182+
self._available = False
125183
self._supported_features = self._determine_features()
126184
self._logger = logging.getLogger(
127185
("%s:%s:<%s>") % (__name__, self.__class__.__name__, self._device_uuid)
128186
)
129187

130188
def _determine_features(self):
131189
"""Get features supported by the device."""
132-
features = SUPPORT_BRIGHTNESS | SUPPORT_COLOR
190+
features = SUPPORT_BRIGHTNESS | SUPPORT_COLOR | SUPPORT_EFFECT
133191

134192
return features
135193

@@ -162,6 +220,12 @@ async def async_turn_on(self, **kwargs) -> None:
162220
await self._api.setDeviceParameter(
163221
self._device_uuid, "COLOR_WHITE", str(color_white)
164222
)
223+
if ATTR_EFFECT in kwargs:
224+
effect = kwargs[ATTR_EFFECT]
225+
index = self._scenes.index(effect)
226+
await self._api.setDeviceParameter(
227+
self._device_uuid, "MODE", str(self._scenes_mapping[index])
228+
)
165229
if not self._state:
166230
await self._api.setDeviceParameter(self._device_uuid, "STATE", "1")
167231
self._state = True
@@ -190,6 +254,7 @@ async def async_update(self):
190254
result = await self._api.getDeviceById(self._device_id)
191255

192256
self._mac = result["hardwareAddress"]
257+
self._available = result["online"] == 1
193258

194259
color = None
195260
color_white = None
@@ -213,6 +278,14 @@ async def async_update(self):
213278
color = i["value"]
214279
if self._supported_features & SUPPORT_COLOR and i["type"] == "COLOR_WHITE":
215280
color_white = i["valueNumeric"]
281+
282+
# Effect
283+
if (
284+
self._supported_features & SUPPORT_EFFECT
285+
and i["type"] == "MODE"
286+
):
287+
index = self._scenes_mapping.index(i["value"])
288+
self._effect = self._scenes[index]
216289

217290
if (color != None and color_white != None):
218291
r, g, b = int("0x%s" % color[1:3], base=16), int("0x%s" % color[3:5], base=16), int("0x%s" % color[5:7], base=16)
@@ -284,3 +357,20 @@ def min_mireds(self):
284357
def supported_features(self) -> int:
285358
"""Flag supported features."""
286359
return self._supported_features
360+
361+
@property
362+
def effect(self):
363+
"""Return the current effect."""
364+
return self._effect
365+
366+
@property
367+
def effect_list(self):
368+
"""Return the list of supported effects.
369+
URL: https://docs.pro.wizconnected.com/#light-modes
370+
"""
371+
return self._scenes
372+
373+
@property
374+
def available(self):
375+
"""Return if able to retrieve information from device or not."""
376+
return self._available

custom_components/lumic/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"domain": "lumic",
3-
"version": "1.0.1",
43
"name": "Lumic Lighting",
4+
"version": "1.1.0",
55
"config_flow": true,
66
"documentation": "https://github.com/asterix11/hass-lumic",
77
"issue_tracker": "https://github.com/asterix11/hass-lumic/issues",

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "lumic"
3-
version = "1.0.1"
3+
version = "1.1.0"
44
description = "Lumic Home Assistant Integration"
55
authors = ["Asterix11 <[email protected]>"]
66
license = "MIT"

0 commit comments

Comments
 (0)