diff --git a/homeassistant/components/zha/core/store.py b/homeassistant/components/zha/core/store.py index c82f05303a5..e58dcd46dba 100644 --- a/homeassistant/components/zha/core/store.py +++ b/homeassistant/components/zha/core/store.py @@ -5,7 +5,7 @@ from collections import OrderedDict from collections.abc import MutableMapping import datetime import time -from typing import TYPE_CHECKING, cast +from typing import TYPE_CHECKING, Any, cast import attr @@ -45,10 +45,11 @@ class ZhaStorage: @callback def async_create_device(self, device: ZHADevice) -> ZhaDeviceEntry: """Create a new ZhaDeviceEntry.""" + ieee_str: str = str(device.ieee) device_entry: ZhaDeviceEntry = ZhaDeviceEntry( - name=device.name, ieee=str(device.ieee), last_seen=device.last_seen + name=device.name, ieee=ieee_str, last_seen=device.last_seen ) - self.devices[device_entry.ieee] = device_entry + self.devices[ieee_str] = device_entry self.async_schedule_save() return device_entry @@ -81,8 +82,8 @@ class ZhaStorage: ieee_str: str = str(device.ieee) old = self.devices[ieee_str] - if old is not None and device.last_seen is None: - return + if device.last_seen is None: + return old changes = {} changes["last_seen"] = device.last_seen @@ -93,7 +94,7 @@ class ZhaStorage: async def async_load(self) -> None: """Load the registry of zha device entries.""" - data = await self._store.async_load() + data = cast(dict[str, Any], await self._store.async_load()) devices: OrderedDict[str, ZhaDeviceEntry] = OrderedDict() diff --git a/mypy.ini b/mypy.ini index b5c56d71ff9..0f8c8fc0b61 100644 --- a/mypy.ini +++ b/mypy.ini @@ -3001,6 +3001,3 @@ ignore_errors = true [mypy-homeassistant.components.zha.core.registries] ignore_errors = true - -[mypy-homeassistant.components.zha.core.store] -ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index 453eade7b2d..0fd62d49ae2 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -146,7 +146,6 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.xiaomi_miio.switch", "homeassistant.components.zha.core.discovery", "homeassistant.components.zha.core.registries", - "homeassistant.components.zha.core.store", ] # Component modules which should set no_implicit_reexport = true.