Make harmony handle IP address changes (#33173)

If the IP address of the harmony hub changed it would
not be rediscovered.  We now connect to get the
unique id and then update config entries with
the correct ip if it is already setup.
This commit is contained in:
J. Nick Koston authored and GitHub committed 2020-03-22 21:24:49 -07:00
1 parent 087b672449
commit 0b2a8bf79a
4 files changed
+70 -41

No files matched your search

+7 -2
View File
@@ -37,11 +37,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
harmony_conf_file = hass.config.path(f"harmony_{entry.unique_id}.conf")
try:
device = HarmonyRemote(name, address, activity, harmony_conf_file, delay_secs)
await device.connect()
device = HarmonyRemote(
name, entry.unique_id, address, activity, harmony_conf_file, delay_secs
)
connected_ok = await device.connect()
except (asyncio.TimeoutError, ValueError, AttributeError):
raise ConfigEntryNotReady
if not connected_ok:
raise ConfigEntryNotReady
hass.data[DOMAIN][entry.entry_id] = device
entry.add_update_listener(_update_listener)