|
11 | 11 | DeviceFeature, |
12 | 12 | DeviceStatus, |
13 | 13 | EnergyUsageResponse, |
| 14 | + NavienAPIClient, |
14 | 15 | NavienMqttClient, |
15 | 16 | ) |
16 | 17 | from nwp500.exceptions import ( |
@@ -347,6 +348,38 @@ def raw_callback(topic: str, message: dict[str, Any]) -> None: |
347 | 348 | _logger.error("Timed out updating reservations.") |
348 | 349 |
|
349 | 350 |
|
| 351 | +async def handle_get_device_info_rest( |
| 352 | + api_client: NavienAPIClient, device: Device, raw: bool = False |
| 353 | +) -> None: |
| 354 | + """Get device info from REST API (minimal DeviceInfo fields).""" |
| 355 | + try: |
| 356 | + device_info_obj = await api_client.get_device_info( |
| 357 | + mac_address=device.device_info.mac_address, |
| 358 | + additional_value=device.device_info.additional_value, |
| 359 | + ) |
| 360 | + if raw: |
| 361 | + print_json(device_info_obj.model_dump()) |
| 362 | + else: |
| 363 | + # Print simple formatted output |
| 364 | + info = device_info_obj.device_info |
| 365 | + |
| 366 | + install_type_str = info.install_type if info.install_type else "N/A" |
| 367 | + print("\n=== Device Info (REST API) ===\n") |
| 368 | + print(f"Device Name: {info.device_name}") |
| 369 | + mac_display = ( |
| 370 | + redact_serial(info.mac_address) if info.mac_address else "N/A" |
| 371 | + ) |
| 372 | + print(f"MAC Address: {mac_display}") |
| 373 | + print(f"Device Type: {info.device_type}") |
| 374 | + print(f"Home Seq: {info.home_seq}") |
| 375 | + print(f"Connected: {info.connected}") |
| 376 | + print(f"Install Type: {install_type_str}") |
| 377 | + print(f"Additional Value: {info.additional_value or 'N/A'}") |
| 378 | + print() |
| 379 | + except Exception as e: |
| 380 | + _logger.error(f"Error fetching device info: {e}") |
| 381 | + |
| 382 | + |
350 | 383 | async def handle_get_tou_request( |
351 | 384 | mqtt: NavienMqttClient, device: Device, api_client: Any |
352 | 385 | ) -> None: |
|
0 commit comments