Better firmware module support for devices not connected to the internet (#854)

Devices not connected to the internet will either error when querying
firmware queries (e.g. P300) or return misleading information (e.g.
P100). This PR adds the cloud connect query to the initial queries and
bypasses the firmware module if not connected.
This commit is contained in:
Steven B
2024-04-23 12:56:32 +01:00
committed by GitHub
parent 03a0ef3cc3
commit aa969ef020
5 changed files with 89 additions and 10 deletions

View File

@@ -104,7 +104,11 @@ class SmartDevice(Device):
We fetch the device info and the available components as early as possible.
If the device reports supporting child devices, they are also initialized.
"""
initial_query = {"component_nego": None, "get_device_info": None}
initial_query = {
"component_nego": None,
"get_device_info": None,
"get_connect_cloud_state": None,
}
resp = await self.protocol.query(initial_query)
# Save the initial state to allow modules access the device info already
@@ -238,6 +242,13 @@ class SmartDevice(Device):
for feat in module._module_features.values():
self._add_feature(feat)
@property
def is_cloud_connected(self):
"""Returns if the device is connected to the cloud."""
if "CloudModule" not in self.modules:
return False
return self.modules["CloudModule"].is_connected
@property
def sys_info(self) -> dict[str, Any]:
"""Returns the device info."""