Skip to content

Commit 2b1e448

Browse files
authored
Normal state is shown as closed for none door sensors - v0.6.2.0 (#32)
1 parent 55b10c4 commit 2b1e448

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

elro/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Elro connects P1 API."""
22

3-
__version__ = "0.6.1.0"
3+
__version__ = "0.6.2.0"

elro/utils.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import collections
88
from typing import Any
99

10-
from elro.device import DEVICE_VALUE, DeviceType, DEVICE_STATE
10+
from elro.device import DEVICE_VALUE, STATE_NORMAL, DeviceType, DEVICE_STATE
1111

1212

1313
# From the ByteUtil class, needed by CRC_maker
@@ -273,6 +273,16 @@ def set_device_name(argv: dict) -> None:
273273

274274
def get_device_states(content: list) -> dict[str, Any]:
275275
"""Return device states."""
276+
277+
def _device_state(device_state: str, device_type: str) -> str:
278+
"""Get the correct device state for door contacts"""
279+
if device_state=="AA" and device_type != DeviceType.DOOR_WINDOW_SENSOR.name:
280+
return STATE_NORMAL
281+
return DEVICE_STATE.get(
282+
device_state, device_state
283+
)
284+
285+
276286
return_dict = {}
277287
for hexdata in content:
278288
try:
@@ -286,7 +296,7 @@ def get_device_states(content: list) -> dict[str, Any]:
286296
"device_type": device_type,
287297
"signal": int(hexdata["device_status"][0:2], 16),
288298
"battery": int(hexdata["device_status"][2:4], 16),
289-
"device_state": DEVICE_STATE.get(
299+
"device_state": _device_state(
290300
device_state, device_state
291301
), # return hex device state if it is not known
292302
"device_value": DEVICE_VALUE.get(

0 commit comments

Comments
 (0)