Early return if current entries is empty
This commit is contained in:
parent
26cbc26af1
commit
edd93b1469
|
|
@ -32,13 +32,22 @@ async def async_setup(hass, entry) -> bool:
|
||||||
hass.data.setdefault(DOMAIN, {})
|
hass.data.setdefault(DOMAIN, {})
|
||||||
|
|
||||||
def update_device(device):
|
def update_device(device):
|
||||||
current_entry = hass.config_entries.async_entries(DOMAIN)[0]
|
current_entries = hass.config_entries.async_entries(DOMAIN)
|
||||||
hass_data = current_entry.data.copy()
|
if len(current_entries) == 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
hass_data = current_entries[0].data.copy()
|
||||||
if device["gwId"] in hass_data[CONF_VACS]:
|
if device["gwId"] in hass_data[CONF_VACS]:
|
||||||
if hass_data[CONF_VACS][device["gwId"]]["ip_address"] != device["ip"]:
|
if hass_data[CONF_VACS][device["gwId"]]["ip_address"] != device["ip"]:
|
||||||
hass_data[CONF_VACS][device["gwId"]]["ip_address"] = device["ip"]
|
hass_data[CONF_VACS][device["gwId"]]["ip_address"] = device["ip"]
|
||||||
hass.config_entries.async_update_entry(current_entry, data=hass_data)
|
hass.config_entries.async_update_entry(
|
||||||
_LOGGER.debug("Updated ip address of {} to {}".format(device["gwId"], device["ip"]))
|
current_entries[0], data=hass_data
|
||||||
|
)
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Updated ip address of {} to {}".format(
|
||||||
|
device["gwId"], device["ip"]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
tuyalocaldiscovery = TuyaLocalDiscovery(update_device)
|
tuyalocaldiscovery = TuyaLocalDiscovery(update_device)
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue