Skip to content

Commit 93210dc

Browse files
committed
Added DA3_03M/RGBW, MCD3_01, PMS3_01, GRT3_70
1 parent be39447 commit 93210dc

File tree

8 files changed

+285
-5
lines changed

8 files changed

+285
-5
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Supported bus devices
8282
- DAC3-04M (148)
8383
- DCDA-33M (150)
8484
- DA3-66M (151)
85+
- DA3-03M/RGBW (153)
8586
- ADC3-60M (156)
8687
- TI3-10B (157)
8788
- TI3-40B (158)
@@ -92,11 +93,15 @@ Supported bus devices
9293
- Virtual cooling regulator (168)
9394
- SA3_014M (169)
9495
- JA3_014M (170)
96+
- MCD3-01 (171)
97+
- PMS3-01 (172)
9598
- GSB3-40Sx-V2 (174)
9699
- GSB3-60Sx-V2 (175)
97100
- GSB3-90Sx-V2 (176)
98101
- MSB3-40 (177)
99102
- MSB3-60 (178)
100103
- MSB3-90 (179)
104+
- GRT3-70 (180)
105+
- GRT3-270 (180)
101106
- BITS (bits)
102107
- INTEGETS (integers)

inelsmqtt/const.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
SA3_01B = "SA3-01B"
4949
DA3_22M = "DA3-22M"
5050
GRT3_50 = "GRT3-50"
51+
GRT3_70 = "GRT3-70"
5152
GSB3_90SX = "GSB3-90SX"
5253
SA3_04M = "SA3-04M"
5354
SA3_012M = "SA3-012M"
@@ -98,8 +99,11 @@
9899
GSB3_40SX_V2 = "GSB3-40SX-V2"
99100
GSB3_60SX_V2 = "GSB3-60SX-V2"
100101
GSB3_90SX_V2 = "GSB3-90SX-V2"
102+
MCD3_01 = "MCD3-01"
103+
PMS3_01 = "PMS3-01"
101104
INTEGERS = "INTEGERS"
102105
BITS = "BITS"
106+
DIMMER_RGBW = "RGBW dimmer"
103107

104108
# Virtual bus
105109
VIRT_CONTR = "Virtual controller"

inelsmqtt/discovery.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import logging
44

55
from inelsmqtt import InelsMqtt
6-
from inelsmqtt.const import INELS_ASSUMED_STATE_DEVICES, INELS_COMM_TEST_DICT, INELS_DEVICE_TYPE_DICT
76
from inelsmqtt.devices import Device
7+
from inelsmqtt.utils.core import INELS_ASSUMED_STATE_DEVICES, ProtocolHandlerMapper
88

99
_LOGGER = logging.getLogger(__name__)
1010

@@ -42,8 +42,9 @@ def discovery(self) -> dict[str, list[Device]]:
4242
dev_type = d_frags[1]
4343
unique_id = d_frags[2]
4444

45-
if dev_type in INELS_COMM_TEST_DICT:
46-
self.__mqtt.publish("inels/set/" + d, INELS_COMM_TEST_DICT[dev_type])
45+
command = ProtocolHandlerMapper.get_handler(dev_type).COMM_TEST()
46+
if command:
47+
self.__mqtt.publish("inels/set/" + d, command)
4748
_LOGGER.info("Sending comm test to device of type %s, unique_id %s", dev_type, unique_id)
4849
retry = True
4950

@@ -56,7 +57,7 @@ def discovery(self) -> dict[str, list[Device]]:
5657
for k, v in devs.items():
5758
k_frags = k.split("/")
5859
dev_type = k_frags[1]
59-
if v is not None or INELS_DEVICE_TYPE_DICT[dev_type] in INELS_ASSUMED_STATE_DEVICES:
60+
if v is not None or ProtocolHandlerMapper.get_handler(dev_type) in INELS_ASSUMED_STATE_DEVICES:
6061
sanitized_devs.append(k)
6162
devs = sanitized_devs
6263

inelsmqtt/protocols/cu3.py

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
DEW_POINT,
3333
DIM_OUT_1,
3434
DIM_OUT_2,
35+
DIMMER_RGBW,
3536
DIN,
3637
DMD3_1,
3738
FA3_612M,
@@ -40,6 +41,7 @@
4041
GCR3_11,
4142
GDB3_10,
4243
GRT3_50,
44+
GRT3_70,
4345
GSB3_20SX,
4446
GSB3_40_V2,
4547
GSB3_40SX,
@@ -66,12 +68,14 @@
6668
LIGHT,
6769
LIGHT_IN,
6870
MAX_TEMP,
71+
MCD3_01,
6972
MSB3_40,
7073
MSB3_60,
7174
MSB3_90,
7275
NUMBER,
7376
OUT,
7477
PLUS_MINUS_BUTTONS,
78+
PMS3_01,
7579
PUBLIC_HOLIDAY,
7680
RC3_610DALI,
7781
RELAY,
@@ -118,6 +122,7 @@
118122
LightCoaToa,
119123
Number,
120124
Relay,
125+
RGBWLight,
121126
Shutter,
122127
SimpleLight,
123128
SimpleRelay,
@@ -1703,6 +1708,75 @@ def create_inels_set_value(cls, device_value: DeviceValue) -> str:
17031708
return cls.create_command_payload(cmd)
17041709

17051710

1711+
class DT_153(Base):
1712+
INELS_TYPE = DIMMER_RGBW
1713+
HA_TYPE = LIGHT
1714+
TYPE_ID = "153"
1715+
1716+
DATA = {
1717+
"LED_1": [4, 5, 6, 7, 12],
1718+
"LED_2": [13, 14, 15, 20, 21],
1719+
"LED_3": [22, 23, 28, 29, 30],
1720+
TEMP_IN: [8, 9],
1721+
}
1722+
1723+
@classmethod
1724+
def create_ha_value_object(cls, device_value: DeviceValue) -> str:
1725+
"""Create a HA value object for a RGBW."""
1726+
led_1 = trim_inels_status_bytes(device_value.inels_status_value, cls.DATA, "LED_1")
1727+
led_2 = trim_inels_status_bytes(device_value.inels_status_value, cls.DATA, "LED_2")
1728+
led_3 = trim_inels_status_bytes(device_value.inels_status_value, cls.DATA, "LED_3")
1729+
1730+
temp_in = trim_inels_status_values(device_value.inels_status_value, cls.DATA, TEMP_IN, "")
1731+
1732+
rgbw = []
1733+
for led in [led_1, led_2, led_3]:
1734+
r, g, b, w, y = [int(i, 16) for i in led]
1735+
rgbw.append(RGBWLight(r=r, g=g, b=b, w=w, brightness=y))
1736+
1737+
return new_object(rgbw=rgbw, temp_in=temp_in)
1738+
1739+
@classmethod
1740+
def create_inels_set_value(cls, device_value: DeviceValue) -> str:
1741+
"""Generate command string to set the RGBW and brightness values."""
1742+
led_1, led_2, led_3 = device_value.ha_value.rgbw
1743+
command = [
1744+
0,
1745+
0,
1746+
0,
1747+
0,
1748+
led_1.r,
1749+
led_1.g,
1750+
led_1.b,
1751+
led_1.w,
1752+
0,
1753+
0,
1754+
0,
1755+
0,
1756+
led_1.brightness,
1757+
led_2.r,
1758+
led_2.g,
1759+
led_2.b,
1760+
0,
1761+
0,
1762+
0,
1763+
0,
1764+
led_2.w,
1765+
led_2.brightness,
1766+
led_3.r,
1767+
led_3.g,
1768+
0,
1769+
0,
1770+
0,
1771+
0,
1772+
led_3.b,
1773+
led_3.w,
1774+
led_3.brightness,
1775+
0,
1776+
]
1777+
return Formatter.format_data(command)
1778+
1779+
17061780
class DT_156(Base):
17071781
INELS_TYPE = ADC3_60M
17081782
HA_TYPE = SENSOR
@@ -1812,6 +1886,8 @@ class Command(IntEnum):
18121886
SHUTTER_STATE_SET = {
18131887
Shutter_state.Open: [Command.OPEN, Command.CLOSE],
18141888
Shutter_state.Closed: [Command.CLOSE, Command.OPEN],
1889+
Shutter_state.Stop_up: [Command.CLOSE, Command.CLOSE],
1890+
Shutter_state.Stop_down: [Command.CLOSE, Command.CLOSE],
18151891
}
18161892

18171893
@staticmethod
@@ -2305,6 +2381,29 @@ def create_ha_value_object(cls, device_value: DeviceValue) -> Any:
23052381
)
23062382

23072383

2384+
class DT_171(Base):
2385+
INELS_TYPE = MCD3_01
2386+
HA_TYPE = SENSOR
2387+
TYPE_ID = "171"
2388+
2389+
DATA = {STATE: [0]}
2390+
2391+
@classmethod
2392+
def create_ha_value_object(cls, device_value: DeviceValue) -> Any:
2393+
state = trim_inels_status_values(device_value.inels_status_value, cls.DATA, STATE, "")
2394+
motion = int(state, 16) == 1
2395+
2396+
return new_object(
2397+
motion=motion,
2398+
)
2399+
2400+
2401+
class DT_172(DT_171):
2402+
INELS_TYPE = PMS3_01
2403+
HA_TYPE = SENSOR
2404+
TYPE_ID = "172"
2405+
2406+
23082407
class DT_174(DT_143):
23092408
INELS_TYPE = GSB3_40SX_V2
23102409
HA_TYPE = SENSOR
@@ -2351,6 +2450,61 @@ class DT_179(DT_143):
23512450
INTERFACE_BUTTON_COUNT = 9
23522451

23532452

2453+
class DT_180(Base):
2454+
INELS_TYPE = GRT3_70
2455+
HA_TYPE = SENSOR
2456+
TYPE_ID = "180"
2457+
2458+
DATA = {
2459+
SW: [1],
2460+
TEMP_IN: [2, 3],
2461+
DIN: [7],
2462+
LIGHT_IN: [8, 9, 10, 11],
2463+
AIN: [12, 13],
2464+
HUMIDITY: [14, 15],
2465+
DEW_POINT: [16, 17],
2466+
}
2467+
2468+
@classmethod
2469+
def create_ha_value_object(cls, device_value: DeviceValue) -> Any:
2470+
switches = trim_inels_status_values(device_value.inels_status_value, cls.DATA, SW, "")
2471+
switches_hex_str = f"0x{switches}"
2472+
switches_bin_str = f"{int(switches_hex_str, 16):0>8b}"
2473+
2474+
temp_in = trim_inels_status_values(device_value.inels_status_value, cls.DATA, TEMP_IN, "")
2475+
2476+
digital_inputs = trim_inels_status_values(device_value.inels_status_value, cls.DATA, DIN, "")
2477+
digital_inputs = f"0x{digital_inputs}"
2478+
digital_inputs = f"{int(digital_inputs, 16):0>8b}"
2479+
din = [digital_inputs[7] == "1"]
2480+
prox = digital_inputs[6] == "1"
2481+
2482+
light_in = trim_inels_status_values(device_value.inels_status_value, cls.DATA, LIGHT_IN, "")
2483+
ain = trim_inels_status_values(device_value.inels_status_value, cls.DATA, AIN, "")
2484+
humidity = trim_inels_status_values(device_value.inels_status_value, cls.DATA, HUMIDITY, "")
2485+
dewpoint = trim_inels_status_values(device_value.inels_status_value, cls.DATA, DEW_POINT, "")
2486+
2487+
return new_object(
2488+
din=din,
2489+
prox=prox,
2490+
interface=[
2491+
switches_bin_str[7] == "1",
2492+
switches_bin_str[6] == "1",
2493+
switches_bin_str[5] == "1",
2494+
switches_bin_str[4] == "1",
2495+
switches_bin_str[3] == "1",
2496+
switches_bin_str[2] == "1",
2497+
switches_bin_str[1] == "1",
2498+
],
2499+
temp_in=temp_in,
2500+
light_in=light_in,
2501+
ain=ain,
2502+
humidity=humidity,
2503+
dewpoint=dewpoint,
2504+
backlit=False,
2505+
)
2506+
2507+
23542508
class DT_BITS:
23552509
INELS_TYPE = BITS
23562510
HA_TYPE = SWITCH

inelsmqtt/protocols/elanrf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ class Command(IntEnum):
321321

322322
@classmethod
323323
def COMM_TEST(cls):
324-
return cls.create_command_payload(cls.Command.COMM_TEST, 0, 0, 0, 0, 0)
324+
return cls.create_command_payload(cls.Command.COMM_TEST, 0, 0, 0, 0)
325325

326326
@staticmethod
327327
def create_command_payload(command: int, red: int, green: int, blue: int, brightness: int) -> str:

inelsmqtt/utils/common.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ class RGBLight(SimpleLight):
6666
b: int
6767

6868

69+
@dataclass
70+
class RGBWLight(SimpleLight):
71+
r: int
72+
g: int
73+
b: int
74+
w: int
75+
76+
6977
@dataclass
7078
class AOUTLight(SimpleLight):
7179
aout_coa: bool

inelsmqtt/utils/core.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
# it is filtered out in set_val
1616
DUMMY_VAL = object()
1717

18+
# Devices that support having no state topic at setup time
19+
INELS_ASSUMED_STATE_DEVICES = [
20+
elanrf.DT_18,
21+
elanrf.DT_19,
22+
]
23+
1824

1925
class ProtocolHandlerMapper:
2026
DEVICE_TYPE_MAP = {
@@ -73,6 +79,7 @@ class ProtocolHandlerMapper:
7379
"148": cu3.DT_148,
7480
"150": cu3.DT_150,
7581
"151": cu3.DT_151,
82+
"153": cu3.DT_153,
7683
"156": cu3.DT_156,
7784
"157": cu3.DT_157,
7885
"158": cu3.DT_158,
@@ -86,12 +93,15 @@ class ProtocolHandlerMapper:
8693
"168": cu3.DT_168,
8794
"169": cu3.DT_169,
8895
"170": cu3.DT_170,
96+
"171": cu3.DT_171,
97+
"172": cu3.DT_172,
8998
"174": cu3.DT_174,
9099
"175": cu3.DT_175,
91100
"176": cu3.DT_176,
92101
"177": cu3.DT_177,
93102
"178": cu3.DT_178,
94103
"179": cu3.DT_179,
104+
"180": cu3.DT_180,
95105
"bits": cu3.DT_BITS,
96106
"integers": cu3.DT_INTEGERS,
97107
}

0 commit comments

Comments
 (0)