mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
Add support for firmware module v1 (#821)
The v1 of firmware does not support changing the auto update setting, this makes it so that it isn't requested in that case.
This commit is contained in:
parent
33be568897
commit
063518b7db
@ -48,6 +48,7 @@ class Firmware(SmartModule):
|
||||
|
||||
def __init__(self, device: "SmartDevice", module: str):
|
||||
super().__init__(device, module)
|
||||
if self.supported_version > 1:
|
||||
self._add_feature(
|
||||
Feature(
|
||||
device,
|
||||
@ -70,12 +71,17 @@ class Firmware(SmartModule):
|
||||
|
||||
def query(self) -> Dict:
|
||||
"""Query to execute during the update cycle."""
|
||||
return {"get_auto_update_info": None, "get_latest_fw": None}
|
||||
req = {
|
||||
"get_latest_fw": None,
|
||||
}
|
||||
if self.supported_version > 1:
|
||||
req["get_auto_update_info"] = None
|
||||
return req
|
||||
|
||||
@property
|
||||
def latest_firmware(self):
|
||||
"""Return latest firmware information."""
|
||||
fw = self.data["get_latest_fw"]
|
||||
fw = self.data.get("get_latest_fw") or self.data
|
||||
if isinstance(fw, SmartErrorCode):
|
||||
# Error in response, probably disconnected from the cloud.
|
||||
return UpdateInfo(type=0, need_to_upgrade=False)
|
||||
@ -98,7 +104,10 @@ class Firmware(SmartModule):
|
||||
@property
|
||||
def auto_update_enabled(self):
|
||||
"""Return True if autoupdate is enabled."""
|
||||
return self.data["get_auto_update_info"]["enable"]
|
||||
return (
|
||||
"get_auto_update_info" in self.data
|
||||
and self.data["get_auto_update_info"]["enable"]
|
||||
)
|
||||
|
||||
async def set_auto_update_enabled(self, enabled: bool):
|
||||
"""Change autoupdate setting."""
|
||||
|
Loading…
Reference in New Issue
Block a user