Add type hints to homekit_controller (#72155)
This commit is contained in:
parent
8ef39c3cfd
commit
0422d7f256
1 changed files with 4 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
"""Provides device automations for homekit devices."""
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Generator
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from aiohomekit.model.characteristics import CharacteristicsTypes
|
||||
|
@ -63,7 +64,7 @@ class TriggerSource:
|
|||
self._hass = connection.hass
|
||||
self._connection = connection
|
||||
self._aid = aid
|
||||
self._triggers = {}
|
||||
self._triggers: dict[tuple[str, str], dict[str, Any]] = {}
|
||||
for trigger in triggers:
|
||||
self._triggers[(trigger["type"], trigger["subtype"])] = trigger
|
||||
self._callbacks = {}
|
||||
|
@ -73,7 +74,7 @@ class TriggerSource:
|
|||
for event_handler in self._callbacks.get(iid, []):
|
||||
event_handler(value)
|
||||
|
||||
def async_get_triggers(self):
|
||||
def async_get_triggers(self) -> Generator[tuple[str, str], None, None]:
|
||||
"""List device triggers for homekit devices."""
|
||||
yield from self._triggers
|
||||
|
||||
|
@ -246,7 +247,7 @@ async def async_get_triggers(
|
|||
if device_id not in hass.data.get(TRIGGERS, {}):
|
||||
return []
|
||||
|
||||
device = hass.data[TRIGGERS][device_id]
|
||||
device: TriggerSource = hass.data[TRIGGERS][device_id]
|
||||
|
||||
return [
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue