mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Use stored philips_js system data on start (#75981)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
df67a8cd4f
commit
a0ef3ad21b
@ -38,15 +38,22 @@ LOGGER = logging.getLogger(__name__)
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up Philips TV from a config entry."""
|
||||
|
||||
system: SystemType | None = entry.data.get(CONF_SYSTEM)
|
||||
tvapi = PhilipsTV(
|
||||
entry.data[CONF_HOST],
|
||||
entry.data[CONF_API_VERSION],
|
||||
username=entry.data.get(CONF_USERNAME),
|
||||
password=entry.data.get(CONF_PASSWORD),
|
||||
system=system,
|
||||
)
|
||||
coordinator = PhilipsTVDataUpdateCoordinator(hass, tvapi, entry.options)
|
||||
|
||||
await coordinator.async_refresh()
|
||||
|
||||
if (actual_system := tvapi.system) and actual_system != system:
|
||||
data = {**entry.data, CONF_SYSTEM: actual_system}
|
||||
hass.config_entries.async_update_entry(entry, data=data)
|
||||
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
hass.data[DOMAIN][entry.entry_id] = coordinator
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user