1 """Coordinator for the Philips TV integration."""
3 from __future__
import annotations
6 from collections.abc
import Mapping
7 from datetime
import timedelta
11 from haphilipsjs
import (
17 from haphilipsjs.typing
import SystemType
26 from .const
import CONF_ALLOW_NOTIFY, CONF_SYSTEM, DOMAIN
28 _LOGGER = logging.getLogger(__name__)
32 """Coordinator to update data."""
34 config_entry: ConfigEntry
37 self, hass: HomeAssistant, api: PhilipsTV, options: Mapping[str, Any]
39 """Set up the coordinator."""
50 hass, _LOGGER, cooldown=2.0, immediate=
False
56 """Return device info."""
61 manufacturer=
"Philips",
63 name=self.
systemsystem[
"name"],
64 sw_version=self.
systemsystem.
get(
"softwareversion"),
69 """Return the system descriptor."""
70 if self.
apiapi.system:
71 return self.
apiapi.system
76 """Return the system descriptor."""
79 return entry.unique_id
85 """Return if the notify feature should be active.
87 We only run it when TV is considered fully on. When powerstate is in standby, the TV
88 will go in low power states and seemingly break the http server in odd ways.
92 and self.
apiapi.powerstate ==
"On"
93 and self.
apiapi.notify_change_supported
94 and self.
optionsoptions.
get(CONF_ALLOW_NOTIFY,
False)
100 res = await self.
apiapi.notifyChange(130)
101 except (ConnectionFailure, AutenticationFailure):
107 _LOGGER.debug(
"Aborting notify due to unexpected return")
126 """Remove data update."""
131 """Fetch the latest data from the source."""
135 except ConnectionFailure:
137 except AutenticationFailure
as exception:
139 except GeneralFailure
as exception:
def _async_notify_stop(self)
None __init__(self, HomeAssistant hass, PhilipsTV api, Mapping[str, Any] options)
def _async_notify_schedule(self)
DeviceInfo device_info(self)
None _unschedule_refresh(self)
def _async_update_data(self)
None async_set_updated_data(self, _DataT data)
web.Response get(self, web.Request request, str config_key)
IssData update(pyiss.ISS iss)