mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 19:09:32 +00:00
Improve august typing (1) (#108325)
This commit is contained in:
@@ -228,7 +228,7 @@ class AugustDoorBinarySensor(AugustEntityMixin, BinarySensorEntity):
|
||||
self._attr_unique_id = f"{self._device_id}_{description.key}"
|
||||
|
||||
@callback
|
||||
def _update_from_data(self):
|
||||
def _update_from_data(self) -> None:
|
||||
"""Get the latest state of the sensor and update activity."""
|
||||
assert self._data.activity_stream is not None
|
||||
door_activity = self._data.activity_stream.get_latest_device_activity(
|
||||
@@ -270,12 +270,12 @@ class AugustDoorbellBinarySensor(AugustEntityMixin, BinarySensorEntity):
|
||||
"""Initialize the sensor."""
|
||||
super().__init__(data, device)
|
||||
self.entity_description = description
|
||||
self._check_for_off_update_listener = None
|
||||
self._check_for_off_update_listener: Callable[[], None] | None = None
|
||||
self._data = data
|
||||
self._attr_unique_id = f"{self._device_id}_{description.key}"
|
||||
|
||||
@callback
|
||||
def _update_from_data(self):
|
||||
def _update_from_data(self) -> None:
|
||||
"""Get the latest state of the sensor."""
|
||||
self._cancel_any_pending_updates()
|
||||
self._attr_is_on = self.entity_description.value_fn(self._data, self._detail)
|
||||
@@ -286,14 +286,14 @@ class AugustDoorbellBinarySensor(AugustEntityMixin, BinarySensorEntity):
|
||||
else:
|
||||
self._attr_available = True
|
||||
|
||||
def _schedule_update_to_recheck_turn_off_sensor(self):
|
||||
def _schedule_update_to_recheck_turn_off_sensor(self) -> None:
|
||||
"""Schedule an update to recheck the sensor to see if it is ready to turn off."""
|
||||
# If the sensor is already off there is nothing to do
|
||||
if not self.is_on:
|
||||
return
|
||||
|
||||
@callback
|
||||
def _scheduled_update(now):
|
||||
def _scheduled_update(now: datetime) -> None:
|
||||
"""Timer callback for sensor update."""
|
||||
self._check_for_off_update_listener = None
|
||||
self._update_from_data()
|
||||
@@ -304,7 +304,7 @@ class AugustDoorbellBinarySensor(AugustEntityMixin, BinarySensorEntity):
|
||||
self.hass, TIME_TO_RECHECK_DETECTION.total_seconds(), _scheduled_update
|
||||
)
|
||||
|
||||
def _cancel_any_pending_updates(self):
|
||||
def _cancel_any_pending_updates(self) -> None:
|
||||
"""Cancel any updates to recheck a sensor to see if it is ready to turn off."""
|
||||
if not self._check_for_off_update_listener:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user