Improve homekit_controller typing (#107381)
This commit is contained in:
parent
427f7a7866
commit
4ea8c174f5
4 changed files with 13 additions and 9 deletions
|
@ -641,7 +641,9 @@ class HKDevice:
|
|||
await self.async_add_new_entities()
|
||||
|
||||
@callback
|
||||
def async_entity_key_removed(self, entity_key: tuple[int, int | None, int | None]):
|
||||
def async_entity_key_removed(
|
||||
self, entity_key: tuple[int, int | None, int | None]
|
||||
) -> None:
|
||||
"""Handle an entity being removed.
|
||||
|
||||
Releases the entity from self.entities so it can be added again.
|
||||
|
@ -666,7 +668,7 @@ class HKDevice:
|
|||
self.char_factories.append(add_entities_cb)
|
||||
self._add_new_entities_for_char([add_entities_cb])
|
||||
|
||||
def _add_new_entities_for_char(self, handlers) -> None:
|
||||
def _add_new_entities_for_char(self, handlers: list[AddCharacteristicCb]) -> None:
|
||||
for accessory in self.entity_map.accessories:
|
||||
for service in accessory.services:
|
||||
for char in service.characteristics:
|
||||
|
@ -768,7 +770,7 @@ class HKDevice:
|
|||
"""Request an debounced update from the accessory."""
|
||||
await self._debounced_update.async_call()
|
||||
|
||||
async def async_update(self, now=None):
|
||||
async def async_update(self, now: datetime | None = None) -> None:
|
||||
"""Poll state of all entities attached to this bridge/accessory."""
|
||||
if not self.pollable_characteristics:
|
||||
self.async_update_available_state()
|
||||
|
|
|
@ -115,7 +115,7 @@ class TriggerSource:
|
|||
|
||||
trigger_callbacks.append(event_handler)
|
||||
|
||||
def async_remove_handler():
|
||||
def async_remove_handler() -> None:
|
||||
trigger_callbacks.remove(event_handler)
|
||||
|
||||
return async_remove_handler
|
||||
|
@ -215,7 +215,7 @@ async def async_setup_triggers_for_entry(
|
|||
conn: HKDevice = hass.data[KNOWN_DEVICES][hkid]
|
||||
|
||||
@callback
|
||||
def async_add_characteristic(service: Service):
|
||||
def async_add_characteristic(service: Service) -> bool:
|
||||
aid = service.accessory.aid
|
||||
service_type = service.type
|
||||
|
||||
|
@ -257,7 +257,9 @@ def async_get_or_create_trigger_source(
|
|||
return source
|
||||
|
||||
|
||||
def async_fire_triggers(conn: HKDevice, events: dict[tuple[int, int], dict[str, Any]]):
|
||||
def async_fire_triggers(
|
||||
conn: HKDevice, events: dict[tuple[int, int], dict[str, Any]]
|
||||
) -> None:
|
||||
"""Process events generated by a HomeKit accessory into automation triggers."""
|
||||
trigger_sources: dict[str, TriggerSource] = conn.hass.data.get(TRIGGERS, {})
|
||||
if not trigger_sources:
|
||||
|
|
|
@ -109,7 +109,7 @@ class HomeKitEntity(Entity):
|
|||
self._accessory.async_entity_key_removed(self._entity_key)
|
||||
|
||||
@callback
|
||||
def _async_unsubscribe_chars(self):
|
||||
def _async_unsubscribe_chars(self) -> None:
|
||||
"""Handle unsubscribing from characteristics."""
|
||||
if self._char_subscription:
|
||||
self._char_subscription()
|
||||
|
@ -118,7 +118,7 @@ class HomeKitEntity(Entity):
|
|||
self._accessory.remove_watchable_characteristics(self.watchable_characteristics)
|
||||
|
||||
@callback
|
||||
def _async_subscribe_chars(self):
|
||||
def _async_subscribe_chars(self) -> None:
|
||||
"""Handle registering characteristics to watch and subscribe."""
|
||||
self._accessory.add_pollable_characteristics(self.pollable_characteristics)
|
||||
self._accessory.add_watchable_characteristics(self.watchable_characteristics)
|
||||
|
|
|
@ -72,7 +72,7 @@ class HomeKitEventEntity(BaseCharacteristicEntity, EventEntity):
|
|||
)
|
||||
|
||||
@callback
|
||||
def _handle_event(self):
|
||||
def _handle_event(self) -> None:
|
||||
if self._char.value is None:
|
||||
# For IP backed devices the characteristic is marked as
|
||||
# pollable, but always returns None when polled
|
||||
|
|
Loading…
Add table
Reference in a new issue