Avoid crashing on childdevice property accesses (#732)

* Avoid crashing on childdevice property accesses

* Push updates from parent to child
This commit is contained in:
Teemu R
2024-02-02 17:29:14 +01:00
committed by GitHub
parent 1f62aee7b6
commit 1f15bcda7c
4 changed files with 100 additions and 32 deletions

View File

@@ -79,8 +79,11 @@ class EmeterStatus(dict):
return super().__getitem__(item[: item.find("_")]) * 1000
else: # downscale
for i in super().keys(): # noqa: SIM118
if i.startswith(item):
return self.__getitem__(i) / 1000
if (
i.startswith(item)
and (value := self.__getitem__(i)) is not None
):
return value / 1000
_LOGGER.debug(f"Unable to find value for '{item}'")
return None