Use most recent version of entry

This commit is contained in:
Luke Bonaccorsi 2023-08-17 13:34:05 +01:00
parent 4f111af975
commit b25acad570
2 changed files with 7 additions and 7 deletions

View File

@ -31,14 +31,14 @@ _LOGGER = logging.getLogger(__name__)
async def async_setup(hass, entry) -> bool:
hass.data.setdefault(DOMAIN, {})
current_entries = hass.config_entries.async_entries(DOMAIN)
hass_data = dict(current_entries[0].data)
def update_device(device):
current_entry = hass.config_entries.async_entries(DOMAIN)[0]
hass_data = current_entry.data.copy()
if device["gwId"] in hass_data[CONF_VACS]:
if 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(entry, data=hass_data)
if 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)
_LOGGER.debug("Updated ip address of {} to {}".format(device["gwId"], device["ip"]))
tuyalocaldiscovery = TuyaLocalDiscovery(update_device)
try:

View File

@ -28,7 +28,7 @@ class TuyaLocalDiscovery(asyncio.DatagramProtocol):
self._listeners = await asyncio.gather(listener, encrypted_listener)
_LOGGER.debug("Listening to broadcasts on UDP port 6666 and 6667")
def close(self):
def close(self, *args, **kwargs):
for transport, _ in self._listeners:
transport.close()