Skip to content

Commit ca8aa22

Browse files
committed
Fix door state if value is unknown and properly invert state for tamper
1 parent d23c8af commit ca8aa22

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

custom_components/span_panel/binary_sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class SpanPanelBinarySensorEntityDescription(
4141
key="doorState",
4242
name="Door State",
4343
device_class=BinarySensorDeviceClass.TAMPER,
44-
value_fn=lambda status_data: status_data.is_door_closed,
44+
value_fn=lambda status_data: not status_data.is_door_closed, #invert logic for tamper
4545
),
4646
SpanPanelBinarySensorEntityDescription(
4747
key="eth0Link",

custom_components/span_panel/span_panel_hardware_status.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
SYSTEM_DOOR_STATE_CLOSED = "CLOSED"
88
SYSTEM_DOOR_STATE_OPEN = "OPEN"
9+
SYSTEM_DOOR_STATE_UNKNOWN = "UNKNOWN"
910

1011

1112
@dataclass
@@ -26,7 +27,9 @@ class SpanPanelHardwareStatus:
2627
_system_data: Dict[str, Any] = field(default_factory=dict)
2728

2829
@property
29-
def is_door_closed(self) -> bool:
30+
def is_door_closed(self) -> bool | None:
31+
if (self.door_state == SYSTEM_DOOR_STATE_UNKNOWN):
32+
return None
3033
return self.door_state == SYSTEM_DOOR_STATE_CLOSED
3134

3235
@property

0 commit comments

Comments
 (0)