Skip to content

Commit f5241c1

Browse files
committed
fix: Fix CLI to no longer depend on old API
Remove use of the old APIs in the CLI.
1 parent d593baa commit f5241c1

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

roborock/cli.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
from roborock.devices.traits.v1.map_content import MapContentTrait
5454
from roborock.exceptions import RoborockException, RoborockUnsupportedFeature
5555
from roborock.protocol import MessageParser
56-
from roborock.version_1_apis.roborock_mqtt_client_v1 import RoborockMqttClientV1
5756
from roborock.web_api import RoborockApiClient
5857

5958
_LOGGER = logging.getLogger(__name__)
@@ -826,40 +825,42 @@ async def get_device_info(ctx: click.Context):
826825

827826
home_data = connection_cache.cache_data.home_data
828827

829-
all_devices = home_data.get_all_devices()
830-
if not all_devices:
828+
device_connection_manager = await context.get_device_manager()
829+
device_manager = await device_connection_manager.ensure_device_manager()
830+
devices = await device_manager.get_devices()
831+
if not devices:
831832
click.echo("No devices found.")
832833
return
833834

834-
click.echo(f"Found {len(all_devices)} devices. Fetching data...")
835+
click.echo(f"Found {len(devices)} devices. Fetching data...")
835836

836837
all_products_data = {}
837838

838-
for device in all_devices:
839+
for device in devices:
839840
click.echo(f" - Processing {device.name} ({device.duid})")
840-
product_info = home_data.product_map[device.product_id]
841-
device_data = DeviceData(device, product_info.model)
842-
mqtt_client = RoborockMqttClientV1(connection_cache.user_data, device_data)
843841

844-
try:
845-
init_status_result = await mqtt_client.send_command(
846-
RoborockCommand.APP_GET_INIT_STATUS,
847-
)
848-
product_nickname = SHORT_MODEL_TO_ENUM.get(product_info.model.split(".")[-1]).name
849-
current_product_data = {
850-
"Protocol Version": device.pv,
851-
"Product Nickname": product_nickname,
842+
if device.product.model in all_products_data:
843+
click.echo(f" - Skipping duplicate model {device.product.model}")
844+
continue
845+
846+
current_product_data = {
847+
"Protocol Version": device.device_info.pv,
848+
"Product Nickname": device.product.product_nickname.name,
849+
}
850+
if device.v1_properties is not None:
851+
try:
852+
result: list[dict[str, Any]] = await device.v1_properties.command.send(RoborockCommand.APP_GET_INIT_STATUS)
853+
except Exception as e:
854+
click.echo(f" - Error processing device {device.name}: {e}", err=True)
855+
continue
856+
init_status_result = result[0] if result else {}
857+
current_product_data.update({
852858
"New Feature Info": init_status_result.get("new_feature_info"),
853859
"New Feature Info Str": init_status_result.get("new_feature_info_str"),
854860
"Feature Info": init_status_result.get("feature_info"),
855-
}
856-
857-
all_products_data[product_info.model] = current_product_data
858-
859-
except Exception as e:
860-
click.echo(f" - Error processing device {device.name}: {e}", err=True)
861-
finally:
862-
await mqtt_client.async_release()
861+
})
862+
863+
all_products_data[device.product.model] = current_product_data
863864

864865
if all_products_data:
865866
click.echo("\n--- Device Information (copy to your YAML file) ---\n")

roborock/devices/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,6 @@ The new design:
556556
- Clear separation of concerns through layers
557557
- Users work with devices, not raw clients
558558

559-
**Note**: Legacy APIs in `version_1_apis/` and `version_a01_apis/` are deprecated and will be removed.
560-
561559

562560
## Implementation Details
563561

0 commit comments

Comments
 (0)