mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Correct issue on new device joins in ZHA (#33470)
This commit is contained in:
parent
0e6aacb440
commit
3d73f166be
@ -5,6 +5,7 @@ import collections
|
|||||||
import itertools
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
@ -478,7 +479,9 @@ class ZHAGateway:
|
|||||||
async def async_device_initialized(self, device: zha_typing.ZigpyDeviceType):
|
async def async_device_initialized(self, device: zha_typing.ZigpyDeviceType):
|
||||||
"""Handle device joined and basic information discovered (async)."""
|
"""Handle device joined and basic information discovered (async)."""
|
||||||
zha_device = self._async_get_or_create_device(device)
|
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(
|
_LOGGER.debug(
|
||||||
"device - %s:%s entering async_device_initialized - is_new_join: %s",
|
"device - %s:%s entering async_device_initialized - is_new_join: %s",
|
||||||
device.nwk,
|
device.nwk,
|
||||||
|
@ -46,8 +46,8 @@ class ZhaStorage:
|
|||||||
name=device.name, ieee=str(device.ieee), last_seen=device.last_seen
|
name=device.name, ieee=str(device.ieee), last_seen=device.last_seen
|
||||||
)
|
)
|
||||||
self.devices[device_entry.ieee] = device_entry
|
self.devices[device_entry.ieee] = device_entry
|
||||||
|
self.async_schedule_save()
|
||||||
return self.async_update_device(device)
|
return device_entry
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_get_or_create_device(self, device: ZhaDeviceType) -> ZhaDeviceEntry:
|
def async_get_or_create_device(self, device: ZhaDeviceType) -> ZhaDeviceEntry:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user