1 """The Philips TV integration."""
3 from __future__
import annotations
7 from haphilipsjs
import PhilipsTV
8 from haphilipsjs.typing
import SystemType
20 from .const
import CONF_SYSTEM
21 from .coordinator
import PhilipsTVDataUpdateCoordinator
24 Platform.BINARY_SENSOR,
26 Platform.MEDIA_PLAYER,
31 LOGGER = logging.getLogger(__name__)
33 PhilipsTVConfigEntry = ConfigEntry[PhilipsTVDataUpdateCoordinator]
37 """Set up Philips TV from a config entry."""
39 system: SystemType |
None = entry.data.get(CONF_SYSTEM)
41 entry.data[CONF_HOST],
42 entry.data[CONF_API_VERSION],
43 username=entry.data.get(CONF_USERNAME),
44 password=entry.data.get(CONF_PASSWORD),
49 await coordinator.async_refresh()
51 if (actual_system := tvapi.system)
and actual_system != system:
52 data = {**entry.data, CONF_SYSTEM: actual_system}
53 hass.config_entries.async_update_entry(entry, data=data)
55 entry.runtime_data = coordinator
57 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
59 entry.async_on_unload(entry.add_update_listener(async_update_entry))
66 await hass.config_entries.async_reload(entry.entry_id)
70 """Unload a config entry."""
71 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_unload_entry(HomeAssistant hass, PhilipsTVConfigEntry entry)
None async_update_entry(HomeAssistant hass, PhilipsTVConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, PhilipsTVConfigEntry entry)