1 """The Apple TV integration."""
3 from __future__
import annotations
5 from pyatv.interface
import AppleTV
as AppleTVInterface
12 from .
import AppleTVManager
13 from .const
import DOMAIN, SIGNAL_CONNECTED, SIGNAL_DISCONNECTED
17 """Device that sends commands to an Apple TV."""
19 _attr_should_poll =
False
20 _attr_has_entity_name =
True
22 atv: AppleTVInterface |
None =
None
24 def __init__(self, name: str, identifier: str, manager: AppleTVManager) ->
None:
25 """Initialize device."""
29 identifiers={(DOMAIN, identifier)},
34 """Handle when an entity is about to be added to Home Assistant."""
37 def _async_connected(atv: AppleTVInterface) ->
None:
38 """Handle that a connection was made to a device."""
44 def _async_disconnected() -> None:
45 """Handle that a connection to a device was lost."""
52 _async_connected(self.
managermanager.atv)
56 self.
hasshass, f
"{SIGNAL_CONNECTED}_{self.unique_id}", _async_connected
62 f
"{SIGNAL_DISCONNECTED}_{self.unique_id}",
68 """Handle when connection is made to device."""
71 """Handle when connection was lost to device."""
None async_device_connected(self, AppleTVInterface atv)
None async_device_disconnected(self)
None __init__(self, str name, str identifier, AppleTVManager manager)
None async_added_to_hass(self)
None async_write_ha_state(self)
None async_on_remove(self, CALLBACK_TYPE func)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)