Skip to content

Commit

Permalink
fix: smart door and motion sensor (#535)
Browse files Browse the repository at this point in the history
  • Loading branch information
petretiandrea authored Sep 23, 2023
1 parent 6289cd6 commit 9a09cb5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
1 change: 1 addition & 0 deletions custom_components/tapo/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class OverheatSensor(BaseTapoEntity[TapoCoordinator], BinarySensorEntity):
def __init__(self, coordinator: TapoCoordinator):
super().__init__(coordinator)
self._attr_name = "Overheat"
self._attr_icon = "mdi:fire-alert"
self._attr_entity_category = EntityCategory.DIAGNOSTIC

@property
Expand Down
10 changes: 1 addition & 9 deletions custom_components/tapo/hub/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ class SmartDoorSensor(BaseTapoHubChildEntity, BinarySensorEntity):
def __init__(self, coordinator: TapoCoordinator):
super().__init__(coordinator)

@property
def unique_id(self):
return super().unique_id + "_" + self._attr_name.replace(" ", "_")

@property
def device_class(self) -> Optional[str]:
return BinarySensorDeviceClass.DOOR
Expand All @@ -54,10 +50,6 @@ class MotionSensor(BaseTapoHubChildEntity, BinarySensorEntity):
def __init__(self, coordinator: TapoCoordinator):
super().__init__(coordinator)

@property
def unique_id(self):
return super().unique_id + "_" + self._attr_name.replace(" ", "_")

@property
def device_class(self) -> Optional[str]:
return BinarySensorDeviceClass.MOTION
Expand Down Expand Up @@ -98,5 +90,5 @@ def is_on(self) -> bool:
T31Device: [LowBatterySensor],
T110SmartDoor: [SmartDoorSensor, LowBatterySensor],
S200ButtonDevice: [LowBatterySensor],
T100MotionSensor: [LowBatterySensor],
T100MotionSensor: [MotionSensor, LowBatterySensor],
}
3 changes: 3 additions & 0 deletions custom_components/tapo/hub/tapo_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from homeassistant.helpers.device_registry import DeviceRegistry
from plugp100.api.hub.hub_device import HubDevice
from plugp100.api.hub.s200b_device import S200ButtonDevice
from plugp100.api.hub.t100_device import T100MotionSensor
from plugp100.api.hub.t110_device import T110SmartDoor
from plugp100.api.hub.t31x_device import T31Device
from plugp100.responses.device_state import DeviceInfo
Expand Down Expand Up @@ -126,6 +127,8 @@ def _create_child_device(child_state: dict[str, Any], hub: HubDevice):
return T110SmartDoor(hub, device_id)
elif "s200" in model:
return S200ButtonDevice(hub, device_id)
elif "t100" in model:
return T100MotionSensor(hub, device_id)
return None


Expand Down

0 comments on commit 9a09cb5

Please sign in to comment.