pydeconz 115__tar.gz → 116__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pydeconz-115 → pydeconz-116}/PKG-INFO +3 -3
- {pydeconz-115 → pydeconz-116}/pydeconz/__init__.py +1 -1
- {pydeconz-115 → pydeconz-116}/pydeconz/config.py +1 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/errors.py +0 -1
- {pydeconz-115 → pydeconz-116}/pydeconz/interfaces/api_handlers.py +4 -2
- {pydeconz-115 → pydeconz-116}/pydeconz/interfaces/events.py +4 -2
- {pydeconz-115 → pydeconz-116}/pydeconz/interfaces/lights.py +3 -1
- {pydeconz-115 → pydeconz-116}/pydeconz/interfaces/sensors.py +25 -1
- {pydeconz-115 → pydeconz-116}/pydeconz/models/__init__.py +6 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/api.py +3 -1
- {pydeconz-115 → pydeconz-116}/pydeconz/models/group.py +1 -29
- {pydeconz-115 → pydeconz-116}/pydeconz/models/light/light.py +1 -1
- {pydeconz-115 → pydeconz-116}/pydeconz/models/light/range_extender.py +0 -1
- pydeconz-116/pydeconz/models/sensor/carbon_dioxide.py +28 -0
- pydeconz-116/pydeconz/models/sensor/formaldehyde.py +28 -0
- {pydeconz-115 → pydeconz-116}/pydeconz.egg-info/PKG-INFO +3 -3
- {pydeconz-115 → pydeconz-116}/pydeconz.egg-info/SOURCES.txt +2 -0
- {pydeconz-115 → pydeconz-116}/pydeconz.egg-info/requires.txt +8 -8
- {pydeconz-115 → pydeconz-116}/pyproject.toml +30 -30
- {pydeconz-115 → pydeconz-116}/tests/test_api.py +1 -1
- {pydeconz-115 → pydeconz-116}/tests/test_gateway.py +14 -16
- {pydeconz-115 → pydeconz-116}/tests/test_groups.py +0 -102
- pydeconz-116/tests/test_sensors.py +76 -0
- pydeconz-115/tests/test_sensors.py +0 -72
- {pydeconz-115 → pydeconz-116}/LICENSE +0 -0
- {pydeconz-115 → pydeconz-116}/README.rst +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/__main__.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/gateway.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/interfaces/__init__.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/interfaces/alarm_systems.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/interfaces/groups.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/interfaces/scenes.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/alarm_system.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/deconz_device.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/event.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/light/__init__.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/light/configuration_tool.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/light/cover.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/light/lock.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/light/siren.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/scene.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/__init__.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/air_purifier.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/air_quality.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/alarm.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/ancillary_control.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/battery.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/carbon_monoxide.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/consumption.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/daylight.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/door_lock.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/fire.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/generic_flag.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/generic_status.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/humidity.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/light_level.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/moisture.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/open_close.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/particulate_matter.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/power.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/presence.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/pressure.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/relative_rotary.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/switch.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/temperature.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/thermostat.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/time.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/vibration.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/models/sensor/water.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/py.typed +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/utils.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz/websocket.py +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz.egg-info/dependency_links.txt +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz.egg-info/entry_points.txt +0 -0
- {pydeconz-115 → pydeconz-116}/pydeconz.egg-info/top_level.txt +0 -0
- {pydeconz-115 → pydeconz-116}/setup.cfg +0 -0
- {pydeconz-115 → pydeconz-116}/tests/test_alarm_system.py +0 -0
- {pydeconz-115 → pydeconz-116}/tests/test_config.py +0 -0
- {pydeconz-115 → pydeconz-116}/tests/test_events.py +0 -0
- {pydeconz-115 → pydeconz-116}/tests/test_lights.py +0 -0
- {pydeconz-115 → pydeconz-116}/tests/test_scenes.py +0 -0
- {pydeconz-115 → pydeconz-116}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pydeconz
|
|
3
|
-
Version:
|
|
3
|
+
Version: 116
|
|
4
4
|
Summary: Python library for communicating with deCONZ REST-API
|
|
5
5
|
Author-email: Robert Svensson <Kane610@users.noreply.github.com>
|
|
6
6
|
License: MIT
|
|
@@ -12,9 +12,9 @@ Classifier: Development Status :: 5 - Production/Stable
|
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
14
|
Classifier: Operating System :: OS Independent
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
16
|
Classifier: Topic :: Home Automation
|
|
17
|
-
Requires-Python: >=3.
|
|
17
|
+
Requires-Python: >=3.12.0
|
|
18
18
|
Description-Content-Type: text/x-rst
|
|
19
19
|
Provides-Extra: requirements
|
|
20
20
|
Provides-Extra: requirements_test
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
from .errors import * # noqa: D104,
|
|
1
|
+
from .errors import * # noqa: D104, F403
|
|
2
2
|
from .gateway import DeconzSession # noqa: F401
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""API handler base classes."""
|
|
2
2
|
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
3
5
|
from collections.abc import (
|
|
4
6
|
Callable,
|
|
5
7
|
ItemsView,
|
|
@@ -32,7 +34,7 @@ class APIHandler(Generic[DataResource]):
|
|
|
32
34
|
resource_types: set[ResourceType] | None = None
|
|
33
35
|
item_cls: Any
|
|
34
36
|
|
|
35
|
-
def __init__(self, gateway:
|
|
37
|
+
def __init__(self, gateway: DeconzSession, grouped: bool = False) -> None:
|
|
36
38
|
"""Initialize API handler."""
|
|
37
39
|
self.gateway = gateway
|
|
38
40
|
self._items: dict[str, DataResource] = {}
|
|
@@ -157,7 +159,7 @@ class GroupedAPIHandler(Generic[DataResource]):
|
|
|
157
159
|
resource_group: ResourceGroup
|
|
158
160
|
|
|
159
161
|
def __init__(
|
|
160
|
-
self, gateway:
|
|
162
|
+
self, gateway: DeconzSession, handlers: list[APIHandler[DataResource]]
|
|
161
163
|
) -> None:
|
|
162
164
|
"""Initialize grouped API handler."""
|
|
163
165
|
self.gateway = gateway
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Manage events from deCONZ."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
2
4
|
|
|
3
5
|
from collections.abc import Callable
|
|
4
6
|
import logging
|
|
@@ -24,7 +26,7 @@ UnsubscribeType = Callable[[], None]
|
|
|
24
26
|
class EventHandler:
|
|
25
27
|
"""Event handler class."""
|
|
26
28
|
|
|
27
|
-
def __init__(self, gateway:
|
|
29
|
+
def __init__(self, gateway: DeconzSession) -> None:
|
|
28
30
|
"""Initialize API items."""
|
|
29
31
|
self.gateway = gateway
|
|
30
32
|
self._subscribers: list[SubscriptionType] = []
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""Python library to connect deCONZ and Home Assistant to work together."""
|
|
2
2
|
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
3
5
|
import logging
|
|
4
6
|
from typing import TYPE_CHECKING, Any
|
|
5
7
|
|
|
@@ -244,7 +246,7 @@ class LightResourceManager(GroupedAPIHandler[LightResources]):
|
|
|
244
246
|
|
|
245
247
|
resource_group = ResourceGroup.LIGHT
|
|
246
248
|
|
|
247
|
-
def __init__(self, gateway:
|
|
249
|
+
def __init__(self, gateway: DeconzSession) -> None:
|
|
248
250
|
"""Initialize light manager."""
|
|
249
251
|
self.configuration_tool = ConfigurationToolHandler(gateway, grouped=True)
|
|
250
252
|
self.covers = CoverHandler(gateway, grouped=True)
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""Python library to connect deCONZ and Home Assistant to work together."""
|
|
2
2
|
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
3
5
|
from typing import TYPE_CHECKING, Any
|
|
4
6
|
|
|
5
7
|
from ..models import ResourceGroup, ResourceType
|
|
@@ -8,11 +10,13 @@ from ..models.sensor.air_quality import AirQuality
|
|
|
8
10
|
from ..models.sensor.alarm import Alarm
|
|
9
11
|
from ..models.sensor.ancillary_control import AncillaryControl
|
|
10
12
|
from ..models.sensor.battery import Battery
|
|
13
|
+
from ..models.sensor.carbon_dioxide import CarbonDioxide
|
|
11
14
|
from ..models.sensor.carbon_monoxide import CarbonMonoxide
|
|
12
15
|
from ..models.sensor.consumption import Consumption
|
|
13
16
|
from ..models.sensor.daylight import Daylight
|
|
14
17
|
from ..models.sensor.door_lock import DoorLock
|
|
15
18
|
from ..models.sensor.fire import Fire
|
|
19
|
+
from ..models.sensor.formaldehyde import Formaldehyde
|
|
16
20
|
from ..models.sensor.generic_flag import GenericFlag
|
|
17
21
|
from ..models.sensor.generic_status import GenericStatus
|
|
18
22
|
from ..models.sensor.humidity import Humidity
|
|
@@ -133,6 +137,14 @@ class BatteryHandler(APIHandler[Battery]):
|
|
|
133
137
|
item_cls = Battery
|
|
134
138
|
|
|
135
139
|
|
|
140
|
+
class CarbonDioxideHandler(APIHandler[CarbonDioxide]):
|
|
141
|
+
"""Handler for carbon dioxide sensor."""
|
|
142
|
+
|
|
143
|
+
resource_group = ResourceGroup.SENSOR
|
|
144
|
+
resource_type = ResourceType.ZHA_CARBON_DIOXIDE
|
|
145
|
+
item_cls = CarbonDioxide
|
|
146
|
+
|
|
147
|
+
|
|
136
148
|
class CarbonMonoxideHandler(APIHandler[CarbonMonoxide]):
|
|
137
149
|
"""Handler for carbon monoxide sensor."""
|
|
138
150
|
|
|
@@ -211,6 +223,14 @@ class FireHandler(APIHandler[Fire]):
|
|
|
211
223
|
item_cls = Fire
|
|
212
224
|
|
|
213
225
|
|
|
226
|
+
class FormaldehydeHandler(APIHandler[Formaldehyde]):
|
|
227
|
+
"""Handler for formaldehyde sensor."""
|
|
228
|
+
|
|
229
|
+
resource_group = ResourceGroup.SENSOR
|
|
230
|
+
resource_type = ResourceType.ZHA_FORMALDEHYDE
|
|
231
|
+
item_cls = Formaldehyde
|
|
232
|
+
|
|
233
|
+
|
|
214
234
|
class GenericFlagHandler(APIHandler[GenericFlag]):
|
|
215
235
|
"""Handler for generic flag sensor."""
|
|
216
236
|
|
|
@@ -643,18 +663,20 @@ class SensorResourceManager(GroupedAPIHandler[SensorResources]):
|
|
|
643
663
|
|
|
644
664
|
resource_group = ResourceGroup.SENSOR
|
|
645
665
|
|
|
646
|
-
def __init__(self, gateway:
|
|
666
|
+
def __init__(self, gateway: DeconzSession) -> None:
|
|
647
667
|
"""Initialize sensor manager."""
|
|
648
668
|
self.air_purifier = AirPurifierHandler(gateway, grouped=True)
|
|
649
669
|
self.air_quality = AirQualityHandler(gateway, grouped=True)
|
|
650
670
|
self.alarm = AlarmHandler(gateway, grouped=True)
|
|
651
671
|
self.ancillary_control = AncillaryControlHandler(gateway, grouped=True)
|
|
652
672
|
self.battery = BatteryHandler(gateway, grouped=True)
|
|
673
|
+
self.carbon_dioxide = CarbonDioxideHandler(gateway, grouped=True)
|
|
653
674
|
self.carbon_monoxide = CarbonMonoxideHandler(gateway, grouped=True)
|
|
654
675
|
self.consumption = ConsumptionHandler(gateway, grouped=True)
|
|
655
676
|
self.daylight = DaylightHandler(gateway, grouped=True)
|
|
656
677
|
self.door_lock = DoorLockHandler(gateway, grouped=True)
|
|
657
678
|
self.fire = FireHandler(gateway, grouped=True)
|
|
679
|
+
self.formaldehyde = FormaldehydeHandler(gateway, grouped=True)
|
|
658
680
|
self.generic_flag = GenericFlagHandler(gateway, grouped=True)
|
|
659
681
|
self.generic_status = GenericStatusHandler(gateway, grouped=True)
|
|
660
682
|
self.humidity = HumidityHandler(gateway, grouped=True)
|
|
@@ -679,11 +701,13 @@ class SensorResourceManager(GroupedAPIHandler[SensorResources]):
|
|
|
679
701
|
self.alarm,
|
|
680
702
|
self.ancillary_control,
|
|
681
703
|
self.battery,
|
|
704
|
+
self.carbon_dioxide,
|
|
682
705
|
self.carbon_monoxide,
|
|
683
706
|
self.consumption,
|
|
684
707
|
self.daylight,
|
|
685
708
|
self.door_lock,
|
|
686
709
|
self.fire,
|
|
710
|
+
self.formaldehyde,
|
|
687
711
|
self.generic_flag,
|
|
688
712
|
self.generic_status,
|
|
689
713
|
self.humidity,
|
|
@@ -81,6 +81,9 @@ class ResourceType(enum.StrEnum):
|
|
|
81
81
|
# Battery
|
|
82
82
|
ZHA_BATTERY = "ZHABattery"
|
|
83
83
|
|
|
84
|
+
# Carbon dioxide
|
|
85
|
+
ZHA_CARBON_DIOXIDE = "ZHACarbonDioxide"
|
|
86
|
+
|
|
84
87
|
# Carbon monoxide
|
|
85
88
|
ZHA_CARBON_MONOXIDE = "ZHACarbonMonoxide"
|
|
86
89
|
|
|
@@ -97,6 +100,9 @@ class ResourceType(enum.StrEnum):
|
|
|
97
100
|
# Fire
|
|
98
101
|
ZHA_FIRE = "ZHAFire"
|
|
99
102
|
|
|
103
|
+
# Formaldehyde
|
|
104
|
+
ZHA_FORMALDEHYDE = "ZHAFormaldehyde"
|
|
105
|
+
|
|
100
106
|
# Generic flag
|
|
101
107
|
CLIP_GENERIC_FLAG = "CLIPGenericFlag"
|
|
102
108
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""API base class."""
|
|
2
2
|
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
3
5
|
from collections.abc import Callable
|
|
4
6
|
import logging
|
|
5
7
|
from typing import TYPE_CHECKING, Any
|
|
@@ -16,7 +18,7 @@ UnsubscribeType = Callable[[], None]
|
|
|
16
18
|
class APIItem:
|
|
17
19
|
"""Base class for a deCONZ API item."""
|
|
18
20
|
|
|
19
|
-
resource_group:
|
|
21
|
+
resource_group: ResourceGroup
|
|
20
22
|
|
|
21
23
|
def __init__(self, resource_id: str, raw: Any) -> None:
|
|
22
24
|
"""Initialize API item."""
|
|
@@ -4,7 +4,7 @@ from typing import Final, Literal, NotRequired, TypedDict
|
|
|
4
4
|
|
|
5
5
|
from . import ResourceGroup
|
|
6
6
|
from .deconz_device import DeconzDevice
|
|
7
|
-
from .light.light import
|
|
7
|
+
from .light.light import LightColorMode, LightEffect
|
|
8
8
|
from .scene import TypedScene
|
|
9
9
|
|
|
10
10
|
COLOR_STATE_ATTRIBUTES: Final = {
|
|
@@ -187,31 +187,3 @@ class Group(DeconzDevice):
|
|
|
187
187
|
Subsequent ids from multidevices with multiple endpoints.
|
|
188
188
|
"""
|
|
189
189
|
return self.raw.get("multideviceids")
|
|
190
|
-
|
|
191
|
-
def update_color_state(
|
|
192
|
-
self, light: Light, update_all_attributes: bool = False
|
|
193
|
-
) -> None:
|
|
194
|
-
"""Sync color state with light.
|
|
195
|
-
|
|
196
|
-
update_all_attributes is used to control whether or not to
|
|
197
|
-
write light attributes with the value None to the group.
|
|
198
|
-
This is used to not keep any bad values from the group.
|
|
199
|
-
"""
|
|
200
|
-
data = {}
|
|
201
|
-
|
|
202
|
-
for attribute in COLOR_STATE_ATTRIBUTES:
|
|
203
|
-
if (light_attribute := light.raw["state"].get(attribute)) is not None:
|
|
204
|
-
data[attribute] = light_attribute
|
|
205
|
-
continue
|
|
206
|
-
|
|
207
|
-
if update_all_attributes:
|
|
208
|
-
if attribute == "xy":
|
|
209
|
-
data[attribute] = (None, None)
|
|
210
|
-
elif attribute == "colormode":
|
|
211
|
-
continue
|
|
212
|
-
elif attribute == "effect":
|
|
213
|
-
data[attribute] = LightEffect.NONE
|
|
214
|
-
else:
|
|
215
|
-
data[attribute] = None
|
|
216
|
-
|
|
217
|
-
self.update({"action": data})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Python library to connect deCONZ and Home Assistant to work together."""
|
|
2
|
+
|
|
3
|
+
from typing import TypedDict
|
|
4
|
+
|
|
5
|
+
from . import SensorBase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TypedCarbonDioxideState(TypedDict):
|
|
9
|
+
"""Carbon dioxide state type definition."""
|
|
10
|
+
|
|
11
|
+
measured_value: int
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TypedCarbonDioxide(TypedDict):
|
|
15
|
+
"""Carbon dioxide type definition."""
|
|
16
|
+
|
|
17
|
+
state: TypedCarbonDioxideState
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class CarbonDioxide(SensorBase):
|
|
21
|
+
"""Carbon dioxide sensor."""
|
|
22
|
+
|
|
23
|
+
raw: TypedCarbonDioxide
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def carbon_dioxide(self) -> int:
|
|
27
|
+
"""Carbon dioxide detected."""
|
|
28
|
+
return self.raw["state"]["measured_value"]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Python library to connect deCONZ and Home Assistant to work together."""
|
|
2
|
+
|
|
3
|
+
from typing import TypedDict
|
|
4
|
+
|
|
5
|
+
from . import SensorBase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TypedFormaldehydeState(TypedDict):
|
|
9
|
+
"""Formaldehyde state type definition."""
|
|
10
|
+
|
|
11
|
+
measured_value: int
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TypedFormaldehyde(TypedDict):
|
|
15
|
+
"""Formaldehyde type definition."""
|
|
16
|
+
|
|
17
|
+
state: TypedFormaldehydeState
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Formaldehyde(SensorBase):
|
|
21
|
+
"""Formaldehyde sensor."""
|
|
22
|
+
|
|
23
|
+
raw: TypedFormaldehyde
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def formaldehyde(self) -> int:
|
|
27
|
+
"""Formaldehyde detected."""
|
|
28
|
+
return self.raw["state"]["measured_value"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pydeconz
|
|
3
|
-
Version:
|
|
3
|
+
Version: 116
|
|
4
4
|
Summary: Python library for communicating with deCONZ REST-API
|
|
5
5
|
Author-email: Robert Svensson <Kane610@users.noreply.github.com>
|
|
6
6
|
License: MIT
|
|
@@ -12,9 +12,9 @@ Classifier: Development Status :: 5 - Production/Stable
|
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
14
|
Classifier: Operating System :: OS Independent
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
16
|
Classifier: Topic :: Home Automation
|
|
17
|
-
Requires-Python: >=3.
|
|
17
|
+
Requires-Python: >=3.12.0
|
|
18
18
|
Description-Content-Type: text/x-rst
|
|
19
19
|
Provides-Extra: requirements
|
|
20
20
|
Provides-Extra: requirements_test
|
|
@@ -43,11 +43,13 @@ pydeconz/models/sensor/air_quality.py
|
|
|
43
43
|
pydeconz/models/sensor/alarm.py
|
|
44
44
|
pydeconz/models/sensor/ancillary_control.py
|
|
45
45
|
pydeconz/models/sensor/battery.py
|
|
46
|
+
pydeconz/models/sensor/carbon_dioxide.py
|
|
46
47
|
pydeconz/models/sensor/carbon_monoxide.py
|
|
47
48
|
pydeconz/models/sensor/consumption.py
|
|
48
49
|
pydeconz/models/sensor/daylight.py
|
|
49
50
|
pydeconz/models/sensor/door_lock.py
|
|
50
51
|
pydeconz/models/sensor/fire.py
|
|
52
|
+
pydeconz/models/sensor/formaldehyde.py
|
|
51
53
|
pydeconz/models/sensor/generic_flag.py
|
|
52
54
|
pydeconz/models/sensor/generic_status.py
|
|
53
55
|
pydeconz/models/sensor/humidity.py
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
aiohttp>3.
|
|
1
|
+
aiohttp>3.9
|
|
2
2
|
orjson>3.9
|
|
3
3
|
|
|
4
4
|
[requirements]
|
|
5
|
-
aiohttp
|
|
6
|
-
orjson
|
|
5
|
+
aiohttp==3.9.5
|
|
6
|
+
orjson==3.10.3
|
|
7
7
|
|
|
8
8
|
[requirements_dev]
|
|
9
|
-
pre-commit==3.
|
|
9
|
+
pre-commit==3.7.1
|
|
10
10
|
|
|
11
11
|
[requirements_test]
|
|
12
12
|
aioresponses==0.7.6
|
|
13
|
-
mypy==1.
|
|
14
|
-
pytest==8.
|
|
13
|
+
mypy==1.10.0
|
|
14
|
+
pytest==8.2.1
|
|
15
15
|
pytest-aiohttp==1.0.5
|
|
16
|
-
pytest-cov==
|
|
17
|
-
ruff==0.
|
|
16
|
+
pytest-cov==5.0.0
|
|
17
|
+
ruff==0.4.4
|
|
18
18
|
types-orjson==3.6.2
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pydeconz"
|
|
7
|
-
version = "
|
|
7
|
+
version = "116"
|
|
8
8
|
license = {text = "MIT"}
|
|
9
9
|
description = "Python library for communicating with deCONZ REST-API"
|
|
10
10
|
readme = "README.rst"
|
|
@@ -15,31 +15,31 @@ classifiers = [
|
|
|
15
15
|
"Intended Audience :: Developers",
|
|
16
16
|
"License :: OSI Approved :: MIT License",
|
|
17
17
|
"Operating System :: OS Independent",
|
|
18
|
-
"Programming Language :: Python :: 3.
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
19
|
"Topic :: Home Automation",
|
|
20
20
|
]
|
|
21
|
-
requires-python = ">=3.
|
|
21
|
+
requires-python = ">=3.12.0"
|
|
22
22
|
dependencies = [
|
|
23
|
-
"aiohttp>3.
|
|
23
|
+
"aiohttp>3.9",
|
|
24
24
|
"orjson>3.9",
|
|
25
25
|
]
|
|
26
26
|
|
|
27
27
|
[project.optional-dependencies]
|
|
28
28
|
requirements = [
|
|
29
|
-
"aiohttp
|
|
30
|
-
"orjson
|
|
29
|
+
"aiohttp==3.9.5",
|
|
30
|
+
"orjson==3.10.3",
|
|
31
31
|
]
|
|
32
32
|
requirements_test = [
|
|
33
33
|
"aioresponses==0.7.6",
|
|
34
|
-
"mypy==1.
|
|
35
|
-
"pytest==8.
|
|
34
|
+
"mypy==1.10.0",
|
|
35
|
+
"pytest==8.2.1",
|
|
36
36
|
"pytest-aiohttp==1.0.5",
|
|
37
|
-
"pytest-cov==
|
|
38
|
-
"ruff==0.
|
|
37
|
+
"pytest-cov==5.0.0",
|
|
38
|
+
"ruff==0.4.4",
|
|
39
39
|
"types-orjson==3.6.2",
|
|
40
40
|
]
|
|
41
41
|
requirements_dev = [
|
|
42
|
-
"pre-commit==3.
|
|
42
|
+
"pre-commit==3.7.1"
|
|
43
43
|
]
|
|
44
44
|
|
|
45
45
|
[project.urls]
|
|
@@ -63,7 +63,7 @@ exclude_also = [
|
|
|
63
63
|
]
|
|
64
64
|
|
|
65
65
|
[tool.mypy]
|
|
66
|
-
python_version = "3.
|
|
66
|
+
python_version = "3.12"
|
|
67
67
|
check_untyped_defs = true
|
|
68
68
|
disallow_any_generics = true
|
|
69
69
|
disallow_incomplete_defs = true
|
|
@@ -89,13 +89,17 @@ testpaths = ["tests"]
|
|
|
89
89
|
|
|
90
90
|
[tool.ruff]
|
|
91
91
|
src = ["pydeconz", "tests"]
|
|
92
|
-
target-version = "
|
|
92
|
+
target-version = "py312"
|
|
93
93
|
lint.select = [
|
|
94
94
|
"B002", # Python does not support the unary prefix increment
|
|
95
|
+
"B005", # Using .strip() with multi-character strings is misleading
|
|
95
96
|
"B007", # Loop control variable {name} not used within loop body
|
|
96
97
|
"B014", # Exception handler with duplicate exception
|
|
98
|
+
"B015", # Pointless comparison. Did you mean to assign a value? Otherwise, prepend assert or remove it.
|
|
99
|
+
"B018", # Found useless attribute access. Either assign it to a variable or remove it.
|
|
97
100
|
"B023", # Function definition does not bind loop variable {name}
|
|
98
101
|
"B026", # Star-arg unpacking after a keyword argument is strongly discouraged
|
|
102
|
+
"B032", # Possible unintentional type annotation (using :). Did you mean to assign (using =)?
|
|
99
103
|
"C", # complexity
|
|
100
104
|
"COM818", # Trailing comma on bare tuple prohibited
|
|
101
105
|
"D", # docstrings
|
|
@@ -104,26 +108,22 @@ lint.select = [
|
|
|
104
108
|
"G", # flake8-logging-format
|
|
105
109
|
"I", # isort
|
|
106
110
|
"ICN001", # import concentions; {name} should be imported as {asname}
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
+
"ISC", # flake8-implicit-str-concat
|
|
112
|
+
"LOG", # flake8-logging
|
|
113
|
+
"N804", # First argument of a class method should be named cls
|
|
114
|
+
"N805", # First argument of a method should be named self
|
|
115
|
+
"N815", # Variable {name} in class scope should not be mixedCase
|
|
116
|
+
"PERF", # A Linter for performance anti-patterns
|
|
111
117
|
"PGH004", # Use specific rule codes when using noqa
|
|
112
|
-
"
|
|
113
|
-
"
|
|
114
|
-
"
|
|
115
|
-
"
|
|
116
|
-
"
|
|
118
|
+
"PIE", # flake8-pie
|
|
119
|
+
"PL", # pylint
|
|
120
|
+
"PT", # pytest
|
|
121
|
+
"RSE", # flake8-raise
|
|
122
|
+
"RUF005", # Consider iterable unpacking instead of concatenation
|
|
117
123
|
"RUF006", # Store a reference to the return value of asyncio.create_task
|
|
124
|
+
"RUF100", # Unused `noqa` directive
|
|
118
125
|
"S307", # No builtin eval() allowed
|
|
119
|
-
"
|
|
120
|
-
"SIM117", # Merge with-statements that use the same scope
|
|
121
|
-
"SIM118", # Use {key} in {dict} instead of {key} in {dict}.keys()
|
|
122
|
-
"SIM201", # Use {left} != {right} instead of not {left} == {right}
|
|
123
|
-
"SIM208", # Use {expr} instead of not (not {expr})
|
|
124
|
-
"SIM212", # Use {a} if {a} else {b} instead of {b} if not {a} else {a}
|
|
125
|
-
"SIM300", # Yoda conditions. Use 'age == 42' instead of '42 == age'.
|
|
126
|
-
"SIM401", # Use get from dict with default instead of an if block
|
|
126
|
+
"SIM", # flake8-simplify
|
|
127
127
|
"T100", # Trace found: {name} used
|
|
128
128
|
"T20", # flake8-print
|
|
129
129
|
"UP", # pyupgrade
|
|
@@ -83,7 +83,7 @@ async def test_api_items(mock_aioresponse, deconz_refresh_state):
|
|
|
83
83
|
apiitems_1_mock_subscribe_update.assert_called_with(EventType.CHANGED, "1")
|
|
84
84
|
item_1_mock_callback.assert_called()
|
|
85
85
|
item_1_mock_subscribe.assert_called()
|
|
86
|
-
item_1.changed_keys ==
|
|
86
|
+
assert item_1.changed_keys == {"key1"}
|
|
87
87
|
|
|
88
88
|
# item 3 is created
|
|
89
89
|
assert "3" in apiitems
|
|
@@ -82,7 +82,7 @@ async def test_initial_state(deconz_session, deconz_refresh_state, count_subscri
|
|
|
82
82
|
assert count_subscribers() == 1 # Scene subscribed to groups
|
|
83
83
|
|
|
84
84
|
unsub = deconz_session.subscribe(session_subscription := Mock())
|
|
85
|
-
assert count_subscribers() ==
|
|
85
|
+
assert count_subscribers() == 38
|
|
86
86
|
|
|
87
87
|
await deconz_refresh_state(
|
|
88
88
|
alarm_systems={"0": {}},
|
|
@@ -190,11 +190,14 @@ async def test_request(mock_aioresponse, deconz_session):
|
|
|
190
190
|
|
|
191
191
|
# Client error
|
|
192
192
|
|
|
193
|
-
with
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
with (
|
|
194
|
+
patch.object(
|
|
195
|
+
deconz_session.session,
|
|
196
|
+
"request",
|
|
197
|
+
side_effect=aiohttp.client_exceptions.ClientError,
|
|
198
|
+
),
|
|
199
|
+
pytest.raises(RequestError),
|
|
200
|
+
):
|
|
198
201
|
await deconz_session.request("get", "/client_error")
|
|
199
202
|
|
|
200
203
|
# Raise on error
|
|
@@ -220,13 +223,6 @@ async def test_request(mock_aioresponse, deconz_session):
|
|
|
220
223
|
with pytest.raises(pydeconzException):
|
|
221
224
|
await deconz_session.request("get", "/unknown")
|
|
222
225
|
|
|
223
|
-
# Generic exception
|
|
224
|
-
|
|
225
|
-
with patch.object(
|
|
226
|
-
deconz_session.session, "request", side_effect=Exception
|
|
227
|
-
), pytest.raises(Exception):
|
|
228
|
-
await deconz_session.request("get", "")
|
|
229
|
-
|
|
230
226
|
await deconz_session.session.close()
|
|
231
227
|
|
|
232
228
|
|
|
@@ -484,7 +480,7 @@ async def test_sensor_events(deconz_session, mock_websocket_event):
|
|
|
484
480
|
|
|
485
481
|
|
|
486
482
|
@patch("pydeconz.gateway.sleep", new_callable=AsyncMock)
|
|
487
|
-
async def test_retry_on_bridge_busy(
|
|
483
|
+
async def test_retry_on_bridge_busy(gateway_sleep, deconz_refresh_state):
|
|
488
484
|
"""Verify a max count of 4 bridge busy messages."""
|
|
489
485
|
session = await deconz_refresh_state(lights={"1": {"type": "light"}})
|
|
490
486
|
|
|
@@ -498,7 +494,9 @@ async def test_retry_on_bridge_busy(_, deconz_refresh_state):
|
|
|
498
494
|
|
|
499
495
|
|
|
500
496
|
@patch("pydeconz.gateway.sleep", new_callable=AsyncMock)
|
|
501
|
-
async def test_request_exception_bridge_busy_pass_on_retry(
|
|
497
|
+
async def test_request_exception_bridge_busy_pass_on_retry(
|
|
498
|
+
gateway_sleep, deconz_refresh_state
|
|
499
|
+
):
|
|
502
500
|
"""Verify retry can return an expected response."""
|
|
503
501
|
session = await deconz_refresh_state(lights={"1": {"type": "light"}})
|
|
504
502
|
|
|
@@ -514,7 +512,7 @@ async def test_request_exception_bridge_busy_pass_on_retry(_, deconz_refresh_sta
|
|
|
514
512
|
|
|
515
513
|
|
|
516
514
|
@patch("pydeconz.gateway.sleep", new_callable=AsyncMock)
|
|
517
|
-
async def test_reset_retry_with_a_second_request(
|
|
515
|
+
async def test_reset_retry_with_a_second_request(gateway_sleep, deconz_refresh_state):
|
|
518
516
|
"""Verify an ongoing retry can be reset by a new request."""
|
|
519
517
|
session = await deconz_refresh_state(lights={"1": {"type": "light"}})
|
|
520
518
|
|
|
@@ -216,105 +216,3 @@ async def test_enum_group_properties(deconz_refresh_state, path, property, data)
|
|
|
216
216
|
data = {path[0]: {path[1]: input}}
|
|
217
217
|
group.update(data)
|
|
218
218
|
assert getattr(group, property) == output
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
@pytest.mark.parametrize(
|
|
222
|
-
("light_state", "expected_group_state"),
|
|
223
|
-
[
|
|
224
|
-
(
|
|
225
|
-
{
|
|
226
|
-
"bri": 1,
|
|
227
|
-
"ct": 1,
|
|
228
|
-
"hue": 1,
|
|
229
|
-
"sat": 1,
|
|
230
|
-
"xy": (0.1, 0.1),
|
|
231
|
-
"colormode": "xy",
|
|
232
|
-
"reachable": True,
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
"brightness": 1,
|
|
236
|
-
"ct": 1,
|
|
237
|
-
"hue": 1,
|
|
238
|
-
"sat": 1,
|
|
239
|
-
"xy": (0.1, 0.1),
|
|
240
|
-
"colormode": LightColorMode.XY,
|
|
241
|
-
"effect": LightEffect.NONE,
|
|
242
|
-
},
|
|
243
|
-
),
|
|
244
|
-
(
|
|
245
|
-
{
|
|
246
|
-
"bri": 1,
|
|
247
|
-
"ct": 1,
|
|
248
|
-
"colormode": "ct",
|
|
249
|
-
"reachable": True,
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
"brightness": 1,
|
|
253
|
-
"ct": 1,
|
|
254
|
-
"hue": None,
|
|
255
|
-
"sat": None,
|
|
256
|
-
"xy": None,
|
|
257
|
-
"colormode": LightColorMode.CT,
|
|
258
|
-
"effect": LightEffect.NONE,
|
|
259
|
-
},
|
|
260
|
-
),
|
|
261
|
-
(
|
|
262
|
-
{
|
|
263
|
-
"bri": 1,
|
|
264
|
-
"reachable": True,
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
"brightness": 1,
|
|
268
|
-
"ct": None,
|
|
269
|
-
"hue": None,
|
|
270
|
-
"sat": None,
|
|
271
|
-
"xy": None,
|
|
272
|
-
"colormode": LightColorMode.HS,
|
|
273
|
-
"effect": LightEffect.NONE,
|
|
274
|
-
},
|
|
275
|
-
),
|
|
276
|
-
],
|
|
277
|
-
)
|
|
278
|
-
async def test_update_color_state(
|
|
279
|
-
light_state,
|
|
280
|
-
expected_group_state,
|
|
281
|
-
deconz_refresh_state,
|
|
282
|
-
):
|
|
283
|
-
"""Verify that groups works."""
|
|
284
|
-
deconz_session = await deconz_refresh_state(
|
|
285
|
-
groups={
|
|
286
|
-
"0": {
|
|
287
|
-
"action": {
|
|
288
|
-
"bri": 132,
|
|
289
|
-
"colormode": "hs",
|
|
290
|
-
"ct": 0,
|
|
291
|
-
"effect": "none",
|
|
292
|
-
"hue": 0,
|
|
293
|
-
"on": False,
|
|
294
|
-
"sat": 127,
|
|
295
|
-
"scene": None,
|
|
296
|
-
"xy": [0, 0],
|
|
297
|
-
},
|
|
298
|
-
"devicemembership": [],
|
|
299
|
-
"etag": "e31c23b3bd9ece918f23ee17ef430304",
|
|
300
|
-
"id": "11",
|
|
301
|
-
"lights": ["14", "15", "12"],
|
|
302
|
-
"name": "Hall",
|
|
303
|
-
"scenes": [{"id": "1", "name": "warmlight"}],
|
|
304
|
-
"state": {"all_on": False, "any_on": True},
|
|
305
|
-
"type": "LightGroup",
|
|
306
|
-
}
|
|
307
|
-
},
|
|
308
|
-
lights={"14": {"type": "Dimmable light", "state": light_state}},
|
|
309
|
-
)
|
|
310
|
-
|
|
311
|
-
group = deconz_session.groups["0"]
|
|
312
|
-
light = deconz_session.lights["14"]
|
|
313
|
-
group.update_color_state(light, update_all_attributes=True)
|
|
314
|
-
assert group.brightness == expected_group_state["brightness"]
|
|
315
|
-
assert group.color_temp == expected_group_state["ct"]
|
|
316
|
-
assert group.hue == expected_group_state["hue"]
|
|
317
|
-
assert group.saturation == expected_group_state["sat"]
|
|
318
|
-
assert group.xy == expected_group_state["xy"]
|
|
319
|
-
assert group.color_mode == expected_group_state["colormode"]
|
|
320
|
-
assert group.effect == expected_group_state["effect"]
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Test pydeCONZ sensors.
|
|
2
|
+
|
|
3
|
+
pytest --cov-report term-missing --cov=pydeconz.sensor tests/test_sensors.py
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from pydeconz.models import ResourceType
|
|
7
|
+
|
|
8
|
+
from tests import sensors as sensor_test_data
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
async def test_create_all_sensors(deconz_refresh_state):
|
|
12
|
+
"""Verify that creating all sensors work."""
|
|
13
|
+
deconz_session = await deconz_refresh_state(
|
|
14
|
+
sensors={
|
|
15
|
+
"0": sensor_test_data.test_air_purifier.DATA,
|
|
16
|
+
"1": sensor_test_data.test_air_quality.DATA,
|
|
17
|
+
"2": sensor_test_data.test_alarm.DATA,
|
|
18
|
+
"3": sensor_test_data.test_ancillary_control.DATA,
|
|
19
|
+
"4": sensor_test_data.test_battery.DATA,
|
|
20
|
+
"5": sensor_test_data.test_carbon_dioxide.DATA,
|
|
21
|
+
"6": sensor_test_data.test_carbon_monoxide.DATA,
|
|
22
|
+
"7": sensor_test_data.test_consumption.DATA,
|
|
23
|
+
"8": sensor_test_data.test_daylight.DATA,
|
|
24
|
+
"9": sensor_test_data.test_door_lock.DATA,
|
|
25
|
+
"10": sensor_test_data.test_fire.DATA,
|
|
26
|
+
"11": sensor_test_data.test_formaldehyde.DATA,
|
|
27
|
+
"12": sensor_test_data.test_generic_flag.DATA,
|
|
28
|
+
"13": sensor_test_data.test_generic_status.DATA,
|
|
29
|
+
"14": sensor_test_data.test_humidity.DATA,
|
|
30
|
+
"15": sensor_test_data.test_light_level.DATA,
|
|
31
|
+
"16": sensor_test_data.test_moisture.DATA,
|
|
32
|
+
"17": sensor_test_data.test_open_close.DATA,
|
|
33
|
+
"18": sensor_test_data.test_particulate_matter.DATA,
|
|
34
|
+
"19": sensor_test_data.test_power.DATA,
|
|
35
|
+
"20": sensor_test_data.test_presence.DATA,
|
|
36
|
+
"21": sensor_test_data.test_pressure.DATA,
|
|
37
|
+
"22": sensor_test_data.test_relative_rotary.DATA,
|
|
38
|
+
"23": sensor_test_data.test_switch.DATA,
|
|
39
|
+
"24": sensor_test_data.test_temperature.DATA,
|
|
40
|
+
"25": sensor_test_data.test_thermostat.DATA,
|
|
41
|
+
"26": sensor_test_data.test_time.DATA,
|
|
42
|
+
"27": sensor_test_data.test_vibration.DATA,
|
|
43
|
+
"28": sensor_test_data.test_water.DATA,
|
|
44
|
+
},
|
|
45
|
+
)
|
|
46
|
+
sensors = deconz_session.sensors
|
|
47
|
+
assert len(sensors._handlers) == 29
|
|
48
|
+
assert sensors["0"].type == ResourceType.ZHA_AIR_PURIFIER
|
|
49
|
+
assert sensors["1"].type == ResourceType.ZHA_AIR_QUALITY
|
|
50
|
+
assert sensors["2"].type == ResourceType.ZHA_ALARM
|
|
51
|
+
assert sensors["3"].type == ResourceType.ZHA_ANCILLARY_CONTROL
|
|
52
|
+
assert sensors["4"].type == ResourceType.ZHA_BATTERY
|
|
53
|
+
assert sensors["5"].type == ResourceType.ZHA_CARBON_DIOXIDE
|
|
54
|
+
assert sensors["6"].type == ResourceType.ZHA_CARBON_MONOXIDE
|
|
55
|
+
assert sensors["7"].type == ResourceType.ZHA_CONSUMPTION
|
|
56
|
+
assert sensors["8"].type == ResourceType.DAYLIGHT
|
|
57
|
+
assert sensors["9"].type == ResourceType.ZHA_DOOR_LOCK
|
|
58
|
+
assert sensors["10"].type == ResourceType.ZHA_FIRE
|
|
59
|
+
assert sensors["11"].type == ResourceType.ZHA_FORMALDEHYDE
|
|
60
|
+
assert sensors["12"].type == ResourceType.CLIP_GENERIC_FLAG
|
|
61
|
+
assert sensors["13"].type == ResourceType.CLIP_GENERIC_STATUS
|
|
62
|
+
assert sensors["14"].type == ResourceType.ZHA_HUMIDITY
|
|
63
|
+
assert sensors["15"].type == ResourceType.ZHA_LIGHT_LEVEL
|
|
64
|
+
assert sensors["16"].type == ResourceType.ZHA_MOISTURE
|
|
65
|
+
assert sensors["17"].type == ResourceType.ZHA_OPEN_CLOSE
|
|
66
|
+
assert sensors["18"].type == ResourceType.ZHA_PARTICULATE_MATTER
|
|
67
|
+
assert sensors["19"].type == ResourceType.ZHA_POWER
|
|
68
|
+
assert sensors["20"].type == ResourceType.ZHA_PRESENCE
|
|
69
|
+
assert sensors["21"].type == ResourceType.ZHA_PRESSURE
|
|
70
|
+
assert sensors["22"].type == ResourceType.ZHA_RELATIVE_ROTARY
|
|
71
|
+
assert sensors["23"].type == ResourceType.ZHA_SWITCH
|
|
72
|
+
assert sensors["24"].type == ResourceType.ZHA_TEMPERATURE
|
|
73
|
+
assert sensors["25"].type == ResourceType.ZHA_THERMOSTAT
|
|
74
|
+
assert sensors["26"].type == ResourceType.ZHA_TIME
|
|
75
|
+
assert sensors["27"].type == ResourceType.ZHA_VIBRATION
|
|
76
|
+
assert sensors["28"].type == ResourceType.ZHA_WATER
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"""Test pydeCONZ sensors.
|
|
2
|
-
|
|
3
|
-
pytest --cov-report term-missing --cov=pydeconz.sensor tests/test_sensors.py
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
from pydeconz.models import ResourceType
|
|
7
|
-
|
|
8
|
-
from tests import sensors as sensor_test_data
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
async def test_create_all_sensors(deconz_refresh_state):
|
|
12
|
-
"""Verify that creating all sensors work."""
|
|
13
|
-
deconz_session = await deconz_refresh_state(
|
|
14
|
-
sensors={
|
|
15
|
-
"0": sensor_test_data.test_air_purifier.DATA,
|
|
16
|
-
"1": sensor_test_data.test_air_quality.DATA,
|
|
17
|
-
"2": sensor_test_data.test_alarm.DATA,
|
|
18
|
-
"3": sensor_test_data.test_ancillary_control.DATA,
|
|
19
|
-
"4": sensor_test_data.test_battery.DATA,
|
|
20
|
-
"5": sensor_test_data.test_carbon_monoxide.DATA,
|
|
21
|
-
"6": sensor_test_data.test_consumption.DATA,
|
|
22
|
-
"7": sensor_test_data.test_daylight.DATA,
|
|
23
|
-
"8": sensor_test_data.test_door_lock.DATA,
|
|
24
|
-
"9": sensor_test_data.test_fire.DATA,
|
|
25
|
-
"10": sensor_test_data.test_generic_flag.DATA,
|
|
26
|
-
"11": sensor_test_data.test_generic_status.DATA,
|
|
27
|
-
"12": sensor_test_data.test_humidity.DATA,
|
|
28
|
-
"13": sensor_test_data.test_light_level.DATA,
|
|
29
|
-
"14": sensor_test_data.test_moisture.DATA,
|
|
30
|
-
"15": sensor_test_data.test_open_close.DATA,
|
|
31
|
-
"16": sensor_test_data.test_particulate_matter.DATA,
|
|
32
|
-
"17": sensor_test_data.test_power.DATA,
|
|
33
|
-
"18": sensor_test_data.test_presence.DATA,
|
|
34
|
-
"19": sensor_test_data.test_pressure.DATA,
|
|
35
|
-
"20": sensor_test_data.test_relative_rotary.DATA,
|
|
36
|
-
"21": sensor_test_data.test_switch.DATA,
|
|
37
|
-
"22": sensor_test_data.test_temperature.DATA,
|
|
38
|
-
"23": sensor_test_data.test_thermostat.DATA,
|
|
39
|
-
"24": sensor_test_data.test_time.DATA,
|
|
40
|
-
"25": sensor_test_data.test_vibration.DATA,
|
|
41
|
-
"26": sensor_test_data.test_water.DATA,
|
|
42
|
-
},
|
|
43
|
-
)
|
|
44
|
-
sensors = deconz_session.sensors
|
|
45
|
-
assert len(sensors._handlers) == 27
|
|
46
|
-
assert sensors["0"].type == ResourceType.ZHA_AIR_PURIFIER
|
|
47
|
-
assert sensors["1"].type == ResourceType.ZHA_AIR_QUALITY
|
|
48
|
-
assert sensors["2"].type == ResourceType.ZHA_ALARM
|
|
49
|
-
assert sensors["3"].type == ResourceType.ZHA_ANCILLARY_CONTROL
|
|
50
|
-
assert sensors["4"].type == ResourceType.ZHA_BATTERY
|
|
51
|
-
assert sensors["5"].type == ResourceType.ZHA_CARBON_MONOXIDE
|
|
52
|
-
assert sensors["6"].type == ResourceType.ZHA_CONSUMPTION
|
|
53
|
-
assert sensors["7"].type == ResourceType.DAYLIGHT
|
|
54
|
-
assert sensors["8"].type == ResourceType.ZHA_DOOR_LOCK
|
|
55
|
-
assert sensors["9"].type == ResourceType.ZHA_FIRE
|
|
56
|
-
assert sensors["10"].type == ResourceType.CLIP_GENERIC_FLAG
|
|
57
|
-
assert sensors["11"].type == ResourceType.CLIP_GENERIC_STATUS
|
|
58
|
-
assert sensors["12"].type == ResourceType.ZHA_HUMIDITY
|
|
59
|
-
assert sensors["13"].type == ResourceType.ZHA_LIGHT_LEVEL
|
|
60
|
-
assert sensors["14"].type == ResourceType.ZHA_MOISTURE
|
|
61
|
-
assert sensors["15"].type == ResourceType.ZHA_OPEN_CLOSE
|
|
62
|
-
assert sensors["16"].type == ResourceType.ZHA_PARTICULATE_MATTER
|
|
63
|
-
assert sensors["17"].type == ResourceType.ZHA_POWER
|
|
64
|
-
assert sensors["18"].type == ResourceType.ZHA_PRESENCE
|
|
65
|
-
assert sensors["19"].type == ResourceType.ZHA_PRESSURE
|
|
66
|
-
assert sensors["20"].type == ResourceType.ZHA_RELATIVE_ROTARY
|
|
67
|
-
assert sensors["21"].type == ResourceType.ZHA_SWITCH
|
|
68
|
-
assert sensors["22"].type == ResourceType.ZHA_TEMPERATURE
|
|
69
|
-
assert sensors["23"].type == ResourceType.ZHA_THERMOSTAT
|
|
70
|
-
assert sensors["24"].type == ResourceType.ZHA_TIME
|
|
71
|
-
assert sensors["25"].type == ResourceType.ZHA_VIBRATION
|
|
72
|
-
assert sensors["26"].type == ResourceType.ZHA_WATER
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|