Skip to content

Commit d398ba9

Browse files
committed
chore: address PR comments
1 parent fe45aa6 commit d398ba9

File tree

2 files changed

+56
-67
lines changed

2 files changed

+56
-67
lines changed

device_info.yaml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
roborock.vacuum.a117:
2-
Protocol Version: '1.0'
3-
Product Nickname: PEARLPLUSS
4-
New Feature Info: 4499197267967999
5-
New Feature Info Str: 000000000000000BC2FF8F7F7EFEFFFF
6-
Feature Info:
2+
protocol_version: '1.0'
3+
product_nickname: PEARLPLUSS
4+
new_feature_info: 4499197267967999
5+
new_feature_info_str: 000000000000000BC2FF8F7F7EFEFFFF
6+
feature_info:
77
- 111
88
- 112
99
- 113
@@ -19,7 +19,7 @@ roborock.vacuum.a117:
1919
- 123
2020
- 124
2121
- 125
22-
Product:
22+
product:
2323
id: 3hVxBJoGbDP2kv93Pcc1pb
2424
name: Roborock Qrevo Master
2525
model: roborock.vacuum.a117
@@ -120,11 +120,11 @@ roborock.vacuum.a117:
120120
mode: ro
121121
type: RAW
122122
roborock.vacuum.a15:
123-
Protocol Version: '1.0'
124-
Product Nickname: TANOSS
125-
New Feature Info: 636084721975295
126-
New Feature Info Str: '0000000000002000'
127-
Feature Info:
123+
protocol_version: '1.0'
124+
product_nickname: TANOSS
125+
new_feature_info: 636084721975295
126+
new_feature_info_str: '0000000000002000'
127+
feature_info:
128128
- 111
129129
- 112
130130
- 113
@@ -139,7 +139,7 @@ roborock.vacuum.a15:
139139
- 123
140140
- 124
141141
- 125
142-
Product:
142+
product:
143143
id: 1YYW18rpgyAJTISwb1NM91
144144
name: S7
145145
model: roborock.vacuum.a15
@@ -240,11 +240,11 @@ roborock.vacuum.a15:
240240
mode: ro
241241
type: RAW
242242
roborock.vacuum.a87:
243-
Protocol Version: '1.0'
244-
Product Nickname: PEARLPLUS
245-
New Feature Info: 4499197267967999
246-
New Feature Info Str: 508A977F7EFEFFFF
247-
Feature Info:
243+
protocol_version: '1.0'
244+
product_nickname: PEARLPLUS
245+
new_feature_info: 4499197267967999
246+
new_feature_info_str: 508A977F7EFEFFFF
247+
feature_info:
248248
- 111
249249
- 112
250250
- 113
@@ -260,7 +260,7 @@ roborock.vacuum.a87:
260260
- 123
261261
- 124
262262
- 125
263-
Product:
263+
product:
264264
id: 5gUei3OIJIXVD3eD85Balg
265265
name: Roborock Qrevo MaxV
266266
model: roborock.vacuum.a87
@@ -361,11 +361,11 @@ roborock.vacuum.a87:
361361
mode: ro
362362
type: RAW
363363
roborock.vacuum.s5e:
364-
Protocol Version: '1.0'
365-
Product Nickname: RUBYSLITE
366-
New Feature Info: 633887780925447
367-
New Feature Info Str: '0000000000002000'
368-
Feature Info:
364+
protocol_version: '1.0'
365+
product_nickname: RUBYSLITE
366+
new_feature_info: 633887780925447
367+
new_feature_info_str: '0000000000002000'
368+
feature_info:
369369
- 111
370370
- 112
371371
- 113
@@ -381,9 +381,9 @@ roborock.vacuum.s5e:
381381
- 124
382382
- 125
383383
roborock.vacuum.sc05:
384-
Protocol Version: B01
385-
Product Nickname: PEARLPLUS
386-
Product:
384+
protocol_version: B01
385+
product_nickname: PEARLPLUS
386+
product:
387387
id: 5ayEx3aKgStqZZ0v5IpMBP
388388
name: Roborock Q7 Series
389389
model: roborock.vacuum.sc05

roborock/cli.py

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from roborock import RoborockCommand
4545
from roborock.data import RoborockBase, UserData
4646
from roborock.data.b01_q10.b01_q10_code_mappings import B01_Q10_DP
47-
from roborock.data.code_mappings import SHORT_MODEL_TO_ENUM, RoborockProductNickname
47+
from roborock.data.code_mappings import SHORT_MODEL_TO_ENUM
4848
from roborock.device_features import DeviceFeatures
4949
from roborock.devices.cache import Cache, CacheData
5050
from roborock.devices.device import RoborockDevice
@@ -861,7 +861,7 @@ def _parse_diagnostic_file(diagnostic_path: Path) -> dict[str, dict[str, Any]]:
861861
if not coordinators:
862862
return all_products_data
863863

864-
for coordinator_id, coordinator_data in coordinators.items():
864+
for coordinator_data in coordinators.values():
865865
device_data = coordinator_data.get("device", {})
866866
product_data = coordinator_data.get("product", {})
867867

@@ -870,11 +870,11 @@ def _parse_diagnostic_file(diagnostic_path: Path) -> dict[str, dict[str, Any]]:
870870
continue
871871
# Derive product nickname from model
872872
short_model = model.split(".")[-1]
873-
product_nickname = SHORT_MODEL_TO_ENUM.get(short_model, RoborockProductNickname.PEARLPLUS)
873+
product_nickname = SHORT_MODEL_TO_ENUM.get(short_model)
874874

875875
current_product_data: dict[str, Any] = {
876-
"Protocol Version": device_data.get("pv"),
877-
"Product Nickname": product_nickname.name,
876+
"protocol_version": device_data.get("pv"),
877+
"product_nickname": product_nickname.name if product_nickname else "Unknown",
878878
}
879879

880880
# Get feature info from the device_features trait (preferred location)
@@ -884,17 +884,17 @@ def _parse_diagnostic_file(diagnostic_path: Path) -> dict[str, dict[str, Any]]:
884884
# newFeatureInfo is the integer
885885
new_feature_info = device_features.get("newFeatureInfo")
886886
if new_feature_info is not None:
887-
current_product_data["New Feature Info"] = new_feature_info
887+
current_product_data["new_feature_info"] = new_feature_info
888888

889889
# newFeatureInfoStr is the hex string
890890
new_feature_info_str = device_features.get("newFeatureInfoStr")
891891
if new_feature_info_str:
892-
current_product_data["New Feature Info Str"] = new_feature_info_str
892+
current_product_data["new_feature_info_str"] = new_feature_info_str
893893

894894
# featureInfo is the list of feature codes
895895
feature_info = device_features.get("featureInfo")
896896
if feature_info:
897-
current_product_data["Feature Info"] = feature_info
897+
current_product_data["feature_info"] = feature_info
898898

899899
# Build product dict from diagnostic product data
900900
if product_data:
@@ -904,7 +904,7 @@ def _parse_diagnostic_file(diagnostic_path: Path) -> dict[str, dict[str, Any]]:
904904
if key in product_data:
905905
product_dict[key] = product_data[key]
906906
if product_dict:
907-
current_product_data["Product"] = product_dict
907+
current_product_data["product"] = product_dict
908908

909909
all_products_data[model] = current_product_data
910910

@@ -965,17 +965,7 @@ async def get_device_info(ctx: click.Context, record: bool, device_info_file: st
965965

966966
click.echo(f"Found {len(all_products_data)} device(s) in diagnostic file.")
967967

968-
# Filter out already recorded models if recording
969-
if record:
970-
all_products_data = {
971-
model: data for model, data in all_products_data.items() if model not in existing_device_info
972-
}
973-
if not all_products_data:
974-
click.echo("No new device info to record (all models already exist).")
975-
return
976-
977968
else:
978-
# Original behavior: connect to devices
979969
click.echo("Discovering devices...")
980970

981971
if record:
@@ -1000,16 +990,15 @@ async def get_device_info(ctx: click.Context, record: bool, device_info_file: st
1000990
click.echo(f" - Processing {device.name} ({device.duid})")
1001991

1002992
model = device.product.model
1003-
if record and model in existing_device_info:
1004-
click.echo(f" - Device info already recorded for {model}")
1005-
continue
1006993
if model in all_products_data:
1007994
click.echo(f" - Skipping duplicate model {model}")
1008995
continue
1009996

1010997
current_product_data = {
1011-
"Protocol Version": device.device_info.pv,
1012-
"Product Nickname": device.product.product_nickname.name,
998+
"protocol_version": device.device_info.pv,
999+
"product_nickname": device.product.product_nickname.name
1000+
if device.product.product_nickname
1001+
else "Unknown",
10131002
}
10141003
if device.v1_properties is not None:
10151004
try:
@@ -1022,15 +1011,15 @@ async def get_device_info(ctx: click.Context, record: bool, device_info_file: st
10221011
init_status_result = result[0] if result else {}
10231012
current_product_data.update(
10241013
{
1025-
"New Feature Info": init_status_result.get("new_feature_info"),
1026-
"New Feature Info Str": init_status_result.get("new_feature_info_str"),
1027-
"Feature Info": init_status_result.get("feature_info"),
1014+
"new_feature_info": init_status_result.get("new_feature_info"),
1015+
"new_feature_info_str": init_status_result.get("new_feature_info_str"),
1016+
"feature_info": init_status_result.get("feature_info"),
10281017
}
10291018
)
10301019

10311020
product_data = device.product.as_dict()
10321021
if product_data:
1033-
current_product_data["Product"] = product_data
1022+
current_product_data["product"] = product_data
10341023

10351024
all_products_data[model] = current_product_data
10361025

@@ -1082,19 +1071,19 @@ def update_docs(data_file: str, output_file: str):
10821071
for model, data in product_data_from_yaml.items():
10831072
# Reconstruct the DeviceFeatures object from the raw data in the YAML file
10841073
device_features = DeviceFeatures.from_feature_flags(
1085-
new_feature_info=data.get("New Feature Info"),
1086-
new_feature_info_str=data.get("New Feature Info Str"),
1087-
feature_info=data.get("Feature Info"),
1088-
product_nickname=data.get("Product Nickname"),
1074+
new_feature_info=data.get("new_feature_info"),
1075+
new_feature_info_str=data.get("new_feature_info_str"),
1076+
feature_info=data.get("feature_info"),
1077+
product_nickname=data.get("product_nickname"),
10891078
)
10901079
features_dict = asdict(device_features)
10911080

10921081
# This dictionary will hold the final data for the markdown table row
10931082
current_product_data = {
1094-
"Product Nickname": data.get("Product Nickname", ""),
1095-
"Protocol Version": data.get("Protocol Version", ""),
1096-
"New Feature Info": data.get("New Feature Info", ""),
1097-
"New Feature Info Str": data.get("New Feature Info Str", ""),
1083+
"product_nickname": data.get("product_nickname", ""),
1084+
"protocol_version": data.get("protocol_version", ""),
1085+
"new_feature_info": data.get("new_feature_info", ""),
1086+
"new_feature_info_str": data.get("new_feature_info_str", ""),
10981087
}
10991088

11001089
# Populate features from the calculated DeviceFeatures object
@@ -1103,7 +1092,7 @@ def update_docs(data_file: str, output_file: str):
11031092
if is_supported:
11041093
current_product_data[feature] = "X"
11051094

1106-
supported_codes = data.get("Feature Info", [])
1095+
supported_codes = data.get("feature_info", [])
11071096
if isinstance(supported_codes, list):
11081097
for code in supported_codes:
11091098
feature_name = str(code)
@@ -1117,10 +1106,10 @@ def write_markdown_table(product_features: dict[str, dict[str, any]], all_featur
11171106
"""Writes the data into a markdown table (products as columns)."""
11181107
sorted_products = sorted(product_features.keys())
11191108
special_rows = [
1120-
"Product Nickname",
1121-
"Protocol Version",
1122-
"New Feature Info",
1123-
"New Feature Info Str",
1109+
"product_nickname",
1110+
"protocol_version",
1111+
"new_feature_info",
1112+
"new_feature_info_str",
11241113
]
11251114
# Regular features are the remaining keys, sorted alphabetically
11261115
# We filter out the special rows to avoid duplicating them.

0 commit comments

Comments
 (0)