Merge remote-tracking branch 'upstream/master' into feat/dev_descriptors

This commit is contained in:
Teemu Rytilahti
2024-02-15 15:17:48 +01:00
11 changed files with 403 additions and 53 deletions

View File

@@ -70,7 +70,7 @@ class SmartDevice(Device):
resp = await self.protocol.query("component_nego")
self._components_raw = resp["component_nego"]
self._components = {
comp["id"]: comp["ver_code"]
comp["id"]: int(comp["ver_code"])
for comp in self._components_raw["component_list"]
}
await self._initialize_modules()
@@ -87,9 +87,14 @@ class SmartDevice(Device):
"get_current_power": None,
}
if self._components["device"] >= 2:
extra_reqs = {
**extra_reqs,
"get_device_usage": None,
}
req = {
"get_device_info": None,
"get_device_usage": None,
"get_device_time": None,
**extra_reqs,
}
@@ -97,8 +102,9 @@ class SmartDevice(Device):
resp = await self.protocol.query(req)
self._info = resp["get_device_info"]
self._usage = resp["get_device_usage"]
self._time = resp["get_device_time"]
# Device usage is not available on older firmware versions
self._usage = resp.get("get_device_usage", {})
# Emeter is not always available, but we set them still for now.
self._energy = resp.get("get_energy_usage", {})
self._emeter = resp.get("get_current_power", {})