FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Do not crash on missing build number in fw version (#1500) · rytilahti/python-kasa@b32d330 · GitHub

Repository navigation

Commit b32d330

Browse files
andcommitted
Do not crash on missing build number in fw version (python-kasa#1500)
Co-authored-by: Steven B <51370195+sdb9696@users.noreply.github.com>
1 parent 0eec4db commit b32d330

9 files changed

Lines changed: 428 additions & 40 deletions

File tree

‎devtools/dump_devinfo.py‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -725,15 +725,6 @@ async def get_smart_test_calls(protocol: SmartProtocol):
725725
successes = []
726726
child_device_components = {}
727727

728-
extra_test_calls = [
729-
SmartCall(
730-
module="temp_humidity_records",
731-
request=SmartRequest.get_raw_request("get_temp_humidity_records").to_dict(),
732-
should_succeed=False,
733-
child_device_id="",
734-
),
735-
]
736-
737728
click.echo("Testing component_nego call ..", nl=False)
738729
responses = await _make_requests_or_exit(
739730
protocol,
@@ -812,8 +803,6 @@ async def get_smart_test_calls(protocol: SmartProtocol):
812803
click.echo(f"Skipping {component_id}..", nl=False)
813804
click.echo(click.style("UNSUPPORTED", fg="yellow"))
814805

815-
test_calls.extend(extra_test_calls)
816-
817806
# Child component calls
818807
for child_device_id, child_components in child_device_components.items():
819808
test_calls.append(
@@ -839,12 +828,6 @@ async def get_smart_test_calls(protocol: SmartProtocol):
839828
else:
840829
click.echo(f"Skipping {component_id}..", nl=False)
841830
click.echo(click.style("UNSUPPORTED", fg="yellow"))
842-
# Add the extra calls for each child
843-
for extra_call in extra_test_calls:
844-
extra_child_call = dataclasses.replace(
845-
extra_call, child_device_id=child_device_id
846-
)
847-
test_calls.append(extra_child_call)
848831

849832
return test_calls, successes
850833

‎devtools/helpers/smartrequests.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ def get_component_requests(component_id, ver_code):
425425
"get_trigger_logs", SmartRequest.GetTriggerLogsParams()
426426
)
427427
],
428+
"temp_humidity_record": [SmartRequest.get_raw_request("get_temp_humidity_records")],
428429
"double_click": [SmartRequest.get_raw_request("get_double_click_info")],
429430
"child_device": [
430431
SmartRequest.get_raw_request("get_child_device_list"),

‎kasa/cli/device.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async def state(ctx, dev: Device):
4848
)
4949
echo(
5050
f"Firmware: {dev.device_info.firmware_version}"
51-
f" {dev.device_info.firmware_build}"
51+
f"{' ' + build if (build := dev.device_info.firmware_build) else ''}"
5252
)
5353
echo(f"MAC (rssi): {dev.mac} ({dev.rssi})")
5454
if verbose:

‎kasa/device.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class DeviceInfo:
161161
device_type: DeviceType
162162
hardware_version: str
163163
firmware_version: str
164-
firmware_build: str
164+
firmware_build: str | None
165165
requires_auth: bool
166166
region: str | None
167167

‎kasa/iot/iotdevice.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,10 @@ def _get_device_info(
760760
device_family = sys_info.get("type", sys_info.get("mic_type"))
761761
device_type = IotDevice._get_device_type_from_sys_info(info)
762762
fw_version_full = sys_info["sw_ver"]
763-
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
763+
if " " in fw_version_full:
764+
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
765+
else:
766+
firmware_version, firmware_build = fw_version_full, None
764767
auth = bool(discovery_info and ("mgt_encrypt_schm" in discovery_info))
765768

766769
return DeviceInfo(

‎kasa/smart/smartdevice.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,10 @@ def _get_device_info(
913913
components, device_family
914914
)
915915
fw_version_full = di["fw_ver"]
916-
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
916+
if " " in fw_version_full:
917+
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
918+
else:
919+
firmware_version, firmware_build = fw_version_full, None
917920
_protocol, devicetype = device_family.split(".")
918921
# Brand inferred from SMART.KASAPLUG/SMART.TAPOPLUG etc.
919922
brand = devicetype[:4].lower()

‎kasa/smartcam/smartcamchild.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ def _get_device_info(
103103
model = cifp["device_model"]
104104
device_type = SmartCamDevice._get_device_type_from_sysinfo(cifp)
105105
fw_version_full = cifp["sw_ver"]
106-
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
106+
if " " in fw_version_full:
107+
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
108+
else:
109+
firmware_version, firmware_build = fw_version_full, None
107110
return DeviceInfo(
108111
short_name=model,
109112
long_name=model,

‎kasa/smartcam/smartcamdevice.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ def _get_device_info(
4747
long_name = discovery_info["device_model"] if discovery_info else short_name
4848
device_type = SmartCamDevice._get_device_type_from_sysinfo(basic_info)
4949
fw_version_full = basic_info["sw_version"]
50-
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
50+
if " " in fw_version_full:
51+
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
52+
else:
53+
firmware_version, firmware_build = fw_version_full, None
5154
return DeviceInfo(
5255
short_name=basic_info["device_model"],
5356
long_name=long_name,

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL