Skip to content

Commit de0b1aa

Browse files
fix: handle different possibilities for state of is_open (#189)
Co-authored-by: petretiandrea <petretiandrea@gmail.com>
1 parent c9fbc62 commit de0b1aa

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

plugp100/new/components/smart_door_component.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import logging
12
from typing import Any
23

34
from plugp100.new.components.device_component import DeviceComponent
45

56

7+
_LOGGER = logging.getLogger("SmartDoorComponent")
8+
69
# TODO: get component_negotiation for Tapo Smart Door sensor
710
# this class is actually too specific for SmartDoor, the component can be called open_closed
811

@@ -12,4 +15,9 @@ def __init__(self):
1215
self.is_open = False
1316

1417
async def update(self, current_state: dict[str, Any] | None = None):
15-
self.is_open = current_state["is_open"]
18+
if "is_open" in current_state:
19+
self.is_open = current_state["is_open"]
20+
elif "open" in current_state:
21+
self.is_open = current_state["open"]
22+
else:
23+
_LOGGER.warning("Open state not found in current state")

0 commit comments

Comments
 (0)