Introduced concept of pollables
This commit is contained in:
parent
b3106e8bae
commit
7d67b6c91b
3 changed files with 25 additions and 0 deletions
|
@ -0,0 +1,5 @@
|
||||||
|
from mash.core.entities.contact_sensor import ContactSensor
|
||||||
|
|
||||||
|
|
||||||
|
class ContactSensorZ2M(ContactSensor):
|
||||||
|
|
|
@ -18,4 +18,15 @@ class ContactSensor(Entity):
|
||||||
def is_closed(self) -> bool:
|
def is_closed(self) -> bool:
|
||||||
return self._has_contact
|
return self._has_contact
|
||||||
|
|
||||||
|
def is_open(self) -> bool:
|
||||||
|
return not self._has_contact
|
||||||
|
|
||||||
|
def is_closed_for_seconds(self, duration_in_seconds: float) -> bool:
|
||||||
|
# TODO
|
||||||
|
pass
|
||||||
|
|
||||||
|
def is_open_for_seconds(self, duration_in_seconds: float) -> bool:
|
||||||
|
# TODO
|
||||||
|
pass
|
||||||
|
|
||||||
# TODO: Update state
|
# TODO: Update state
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Entity:
|
||||||
self._room = room
|
self._room = room
|
||||||
self._device_type = device_type
|
self._device_type = device_type
|
||||||
self._groups = set(groups)
|
self._groups = set(groups)
|
||||||
|
self._pollable = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def id(self) -> str:
|
def id(self) -> str:
|
||||||
|
@ -37,5 +38,13 @@ class Entity:
|
||||||
def groups(self) -> set[str]:
|
def groups(self) -> set[str]:
|
||||||
return self._groups
|
return self._groups
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_pollable(self) -> bool:
|
||||||
|
return self._pollable
|
||||||
|
|
||||||
|
def _poll_(self) -> None:
|
||||||
|
"""Polls the bridge for the latest state."""
|
||||||
|
pass
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"{self.name} [{self.id}, type {self.device_type}, room {self.room}, in {len(self.groups)} groups]"
|
return f"{self.name} [{self.id}, type {self.device_type}, room {self.room}, in {len(self.groups)} groups]"
|
||||||
|
|
Loading…
Reference in a new issue