Skip to content

Do not crash on missing build number in fw version #1500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions devtools/dump_devinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,15 +725,6 @@ async def get_smart_test_calls(protocol: SmartProtocol):
successes = []
child_device_components = {}

extra_test_calls = [
SmartCall(
module="temp_humidity_records",
request=SmartRequest.get_raw_request("get_temp_humidity_records").to_dict(),
should_succeed=False,
child_device_id="",
),
]

click.echo("Testing component_nego call ..", nl=False)
responses = await _make_requests_or_exit(
protocol,
Expand Down Expand Up @@ -812,8 +803,6 @@ async def get_smart_test_calls(protocol: SmartProtocol):
click.echo(f"Skipping {component_id}..", nl=False)
click.echo(click.style("UNSUPPORTED", fg="yellow"))

test_calls.extend(extra_test_calls)

# Child component calls
for child_device_id, child_components in child_device_components.items():
test_calls.append(
Expand All @@ -839,12 +828,6 @@ async def get_smart_test_calls(protocol: SmartProtocol):
else:
click.echo(f"Skipping {component_id}..", nl=False)
click.echo(click.style("UNSUPPORTED", fg="yellow"))
# Add the extra calls for each child
for extra_call in extra_test_calls:
extra_child_call = dataclasses.replace(
extra_call, child_device_id=child_device_id
)
test_calls.append(extra_child_call)

return test_calls, successes

Expand Down
1 change: 1 addition & 0 deletions devtools/helpers/smartrequests.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ def get_component_requests(component_id, ver_code):
"get_trigger_logs", SmartRequest.GetTriggerLogsParams()
)
],
"temp_humidity_record": [SmartRequest.get_raw_request("get_temp_humidity_records")],
"double_click": [SmartRequest.get_raw_request("get_double_click_info")],
"child_device": [
SmartRequest.get_raw_request("get_child_device_list"),
Expand Down
2 changes: 1 addition & 1 deletion kasa/cli/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def state(ctx, dev: Device):
)
echo(
f"Firmware: {dev.device_info.firmware_version}"
f" {dev.device_info.firmware_build}"
f"{' ' + build if (build := dev.device_info.firmware_build) else ''}"
)
echo(f"MAC (rssi): {dev.mac} ({dev.rssi})")
if verbose:
Expand Down
2 changes: 1 addition & 1 deletion kasa/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class DeviceInfo:
device_type: DeviceType
hardware_version: str
firmware_version: str
firmware_build: str
firmware_build: str | None
requires_auth: bool
region: str | None

Expand Down
5 changes: 4 additions & 1 deletion kasa/iot/iotdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,10 @@
device_family = sys_info.get("type", sys_info.get("mic_type"))
device_type = IotDevice._get_device_type_from_sys_info(info)
fw_version_full = sys_info["sw_ver"]
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
if " " in fw_version_full:
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
else:
firmware_version, firmware_build = fw_version_full, None

Check warning on line 766 in kasa/iot/iotdevice.py

View check run for this annotation

Codecov / codecov/patch

kasa/iot/iotdevice.py#L766

Added line #L766 was not covered by tests
auth = bool(discovery_info and ("mgt_encrypt_schm" in discovery_info))

return DeviceInfo(
Expand Down
5 changes: 4 additions & 1 deletion kasa/smart/smartdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,10 @@ def _get_device_info(
components, device_family
)
fw_version_full = di["fw_ver"]
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
if " " in fw_version_full:
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
else:
firmware_version, firmware_build = fw_version_full, None
_protocol, devicetype = device_family.split(".")
# Brand inferred from SMART.KASAPLUG/SMART.TAPOPLUG etc.
brand = devicetype[:4].lower()
Expand Down
5 changes: 4 additions & 1 deletion kasa/smartcam/smartcamchild.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@
model = cifp["device_model"]
device_type = SmartCamDevice._get_device_type_from_sysinfo(cifp)
fw_version_full = cifp["sw_ver"]
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
if " " in fw_version_full:
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
else:
firmware_version, firmware_build = fw_version_full, None

Check warning on line 109 in kasa/smartcam/smartcamchild.py

View check run for this annotation

Codecov / codecov/patch

kasa/smartcam/smartcamchild.py#L109

Added line #L109 was not covered by tests
return DeviceInfo(
short_name=model,
long_name=model,
Expand Down
5 changes: 4 additions & 1 deletion kasa/smartcam/smartcamdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
long_name = discovery_info["device_model"] if discovery_info else short_name
device_type = SmartCamDevice._get_device_type_from_sysinfo(basic_info)
fw_version_full = basic_info["sw_version"]
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
if " " in fw_version_full:
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
else:
firmware_version, firmware_build = fw_version_full, None

Check warning on line 53 in kasa/smartcam/smartcamdevice.py

View check run for this annotation

Codecov / codecov/patch

kasa/smartcam/smartcamdevice.py#L53

Added line #L53 was not covered by tests
return DeviceInfo(
short_name=basic_info["device_model"],
long_name=long_name,
Expand Down
Loading
Loading