Add fallback for serialnumber (#66553)

pull/66624/head
Joakim Plate 2022-02-15 22:42:18 +01:00 committed by Paulus Schoutsen
parent 104f56a01d
commit addc6bce63
2 changed files with 9 additions and 6 deletions

View File

@ -148,9 +148,12 @@ class PhilipsTVDataUpdateCoordinator(DataUpdateCoordinator[None]):
@property @property
def unique_id(self) -> str: def unique_id(self) -> str:
"""Return the system descriptor.""" """Return the system descriptor."""
assert self.config_entry entry: ConfigEntry = self.config_entry
assert self.config_entry.unique_id assert entry
return self.config_entry.unique_id if entry.unique_id:
return entry.unique_id
assert entry.entry_id
return entry.entry_id
@property @property
def _notify_wanted(self): def _notify_wanted(self):

View File

@ -122,9 +122,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
LOGGER.exception("Unexpected exception") LOGGER.exception("Unexpected exception")
errors["base"] = "unknown" errors["base"] = "unknown"
else: else:
if serialnumber := hub.system.get("serialnumber"):
await self.async_set_unique_id(hub.system["serialnumber"]) await self.async_set_unique_id(serialnumber)
self._abort_if_unique_id_configured() self._abort_if_unique_id_configured()
self._current[CONF_SYSTEM] = hub.system self._current[CONF_SYSTEM] = hub.system
self._current[CONF_API_VERSION] = hub.api_version self._current[CONF_API_VERSION] = hub.api_version