|
53 | 53 | from roborock.devices.traits.v1.map_content import MapContentTrait |
54 | 54 | from roborock.exceptions import RoborockException, RoborockUnsupportedFeature |
55 | 55 | from roborock.protocol import MessageParser |
56 | | -from roborock.version_1_apis.roborock_mqtt_client_v1 import RoborockMqttClientV1 |
57 | 56 | from roborock.web_api import RoborockApiClient |
58 | 57 |
|
59 | 58 | _LOGGER = logging.getLogger(__name__) |
@@ -826,40 +825,42 @@ async def get_device_info(ctx: click.Context): |
826 | 825 |
|
827 | 826 | home_data = connection_cache.cache_data.home_data |
828 | 827 |
|
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: |
831 | 832 | click.echo("No devices found.") |
832 | 833 | return |
833 | 834 |
|
834 | | - click.echo(f"Found {len(all_devices)} devices. Fetching data...") |
| 835 | + click.echo(f"Found {len(devices)} devices. Fetching data...") |
835 | 836 |
|
836 | 837 | all_products_data = {} |
837 | 838 |
|
838 | | - for device in all_devices: |
| 839 | + for device in devices: |
839 | 840 | 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) |
843 | 841 |
|
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({ |
852 | 858 | "New Feature Info": init_status_result.get("new_feature_info"), |
853 | 859 | "New Feature Info Str": init_status_result.get("new_feature_info_str"), |
854 | 860 | "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 |
863 | 864 |
|
864 | 865 | if all_products_data: |
865 | 866 | click.echo("\n--- Device Information (copy to your YAML file) ---\n") |
|
0 commit comments