77import collections
88from 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
274274def 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