Correct issue on new device joins in ZHA (#33470)

pull/33497/head
David F. Mulcahey 2020-04-01 08:41:16 -04:00 committed by GitHub
parent 0e6aacb440
commit 3d73f166be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import collections
import itertools
import logging
import os
import time
import traceback
from typing import List, Optional
@ -478,7 +479,9 @@ class ZHAGateway:
async def async_device_initialized(self, device: zha_typing.ZigpyDeviceType):
"""Handle device joined and basic information discovered (async)."""
zha_device = self._async_get_or_create_device(device)
# This is an active device so set a last seen if it is none
if zha_device.last_seen is None:
zha_device.async_update_last_seen(time.time())
_LOGGER.debug(
"device - %s:%s entering async_device_initialized - is_new_join: %s",
device.nwk,

View File

@ -46,8 +46,8 @@ class ZhaStorage:
name=device.name, ieee=str(device.ieee), last_seen=device.last_seen
)
self.devices[device_entry.ieee] = device_entry
return self.async_update_device(device)
self.async_schedule_save()
return device_entry
@callback
def async_get_or_create_device(self, device: ZhaDeviceType) -> ZhaDeviceEntry: