Skip to content

Commit

Permalink
Use stored philips_js system data on start (#75981)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
  • Loading branch information
elupus and MartinHjelmare committed Aug 5, 2022
1 parent df67a8c commit a0ef3ad
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions homeassistant/components/philips_js/__init__.py
Expand Up @@ -38,15 +38,22 @@
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

Expand Down

0 comments on commit a0ef3ad

Please sign in to comment.