From bb52e1736499fc995a5439fdd2b2a4d52511d261 Mon Sep 17 00:00:00 2001 From: "David F. Mulcahey" Date: Thu, 29 Aug 2019 15:44:53 -0400 Subject: [PATCH] Fix ZHA state restore by always restoring last seen on devices (#26271) * fix state restore by always restoring last seen * cleanup --- homeassistant/components/zha/core/gateway.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/zha/core/gateway.py b/homeassistant/components/zha/core/gateway.py index 9cf93b56581..3d8c3e8fd90 100644 --- a/homeassistant/components/zha/core/gateway.py +++ b/homeassistant/components/zha/core/gateway.py @@ -304,6 +304,8 @@ class ZHAGateway: manufacturer=zha_device.manufacturer, model=zha_device.model, ) + entry = self.zha_storage.async_get_or_create(zha_device) + zha_device.async_update_last_seen(entry.last_seen) return zha_device @callback @@ -356,10 +358,6 @@ class ZHAGateway: ) await self._async_device_joined(device, zha_device) - # This is real traffic from a device so lets update last seen on the entry - entry = self.zha_storage.async_get_or_create(zha_device) - zha_device.async_update_last_seen(entry.last_seen) - device_info = async_get_device_info( self._hass, zha_device, self.ha_device_registry )