Skip to content

Commit d34ca22

Browse files
committed
Added tests to all devices. Refactored all other tests and added new cases.
1 parent 326e354 commit d34ca22

File tree

15 files changed

+3058
-995
lines changed

15 files changed

+3058
-995
lines changed

inelsmqtt/const.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244
"111": SWITCH, # FA3_612M,
245245
"112": SWITCH, # IOU3_108M,
246246

247-
"114" : SWITCH, # RC3_610DALI,
247+
"114": SWITCH, # RC3_610DALI,
248248
"115": SENSOR, # IM3_20B,
249249
"116": SENSOR, # IM3_40B,
250250
"117": SENSOR, # IM3_80B
@@ -258,7 +258,7 @@
258258
"128": SWITCH, # GCR3_11,
259259
"129": SWITCH, # GCH3_31,
260260

261-
"136": SENSOR, # GSP3_100,
261+
"136": BUTTON, # GSP3_100,
262262
"137": BUTTON, # GDB3_10,
263263
"138": BUTTON, # GSB3_40SX,
264264
"139": BUTTON, # GSB3_60SX

inelsmqtt/devices/__init__.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ def is_subscribed(self) -> bool:
9797
"""
9898
return self.__mqtt.is_subscribed(self.__state_topic)
9999

100+
@property
101+
def device_class(self) -> str:
102+
"""Get device class of the device
103+
104+
Returns:
105+
str: Device class
106+
"""
107+
return self.__device_class
108+
100109
@property
101110
def inels_type(self) -> str:
102111
"""Get inels type of the device
@@ -140,12 +149,12 @@ def is_available(self) -> bool:
140149
Returns:
141150
bool: True/False
142151
"""
143-
gw = self.__mqtt.messages().get(self._Device__gw_connected_topic)
152+
gw = self.__mqtt.messages().get(self.gw_connected_topic)
144153
if gw is not None:
145154
if not GW_CONNECTED.get(gw):
146155
return False
147156

148-
val = self.__mqtt.messages().get(self._Device__connected_topic)
157+
val = self.__mqtt.messages().get(self.connected_topic)
149158
if isinstance(val, (bytes, bytearray)):
150159
val = val.decode()
151160

@@ -182,6 +191,24 @@ def domain(self) -> str:
182191
str: Name of the domain
183192
"""
184193
return self.__domain
194+
195+
@property
196+
def connected_topic(self) -> str:
197+
"""Connected topic
198+
199+
Returns:
200+
str: string of the connected topic
201+
"""
202+
return self.__connected_topic
203+
204+
@property
205+
def gw_connected_topic(self) -> str:
206+
"""Gateway connected topic
207+
208+
Returns:
209+
str: string of the gateway connected topic
210+
"""
211+
return self.__gw_connected_topic
185212

186213
@property
187214
def state(self) -> Any:
@@ -359,4 +386,4 @@ def model_number(self) -> str:
359386
@property
360387
def serial_number(self) -> str:
361388
"""Serial number of the device."""
362-
return self.__device.unique_id
389+
return self.__device.unique_id

inelsmqtt/discovery.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,6 @@ def __init__(self, mqtt: InelsMqtt) -> None:
1616
"""Initialize inels mqtt discovery"""
1717
self.__mqtt = mqtt
1818
self.__devices: list[Device] = []
19-
self.__coordinators: list[str] = []
20-
self.__coordinators_with_devices: dict[str, list[Device]] = {}
21-
22-
@property
23-
def coordinators(self) -> list[str]:
24-
"""Coordinators list
25-
26-
Returns:
27-
_type_: list of coordinator serial numbers
28-
"""
29-
return self.__coordinators
3019

3120
@property
3221
def devices(self) -> list[Device]:
@@ -72,12 +61,6 @@ def discovery(self) -> dict[str, list[Device]]:
7261
devs = sanitized_devs
7362

7463
self.__devices = [Device(self.__mqtt, "inels/status/" + item) for item in devs]
75-
# for item in self.__devices:
76-
# if item.parent_id not in self.__coordinators:
77-
# self.__coordinators.append(item.parent_id)
78-
# self.__coordinators_with_devices[item.parent_id] = []
79-
80-
# self.__coordinators_with_devices[item.parent_id].append(item)
8164

8265
_LOGGER.info("Discovered %s devices", len(self.__devices))
8366

inelsmqtt/util.py

Lines changed: 71 additions & 72 deletions
Large diffs are not rendered by default.

test-requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
flake8==4.0.1
22
paho-mqtt==1.6.1
3-
attrs>=21.2.0
3+
pytest==8.2.0
4+
attrs>=21.2.0

tests/const.py

Lines changed: 0 additions & 129 deletions
This file was deleted.

tests/devices/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)