|
18 | 18 | _LOGGER = logging.getLogger(__name__) |
19 | 19 |
|
20 | 20 | MODEL_AIR = ("LetPot Air", "LPH-AIR") |
| 21 | +MODEL_DI = ("LetPot Automatic Watering System", "DI") |
21 | 22 | MODEL_MAX = ("LetPot Max", "LPH-MAX") |
22 | 23 | MODEL_MINI = ("LetPot Mini", "LPH-MINI") |
23 | 24 | MODEL_PRO = ("LetPot Pro", "LPH-PRO") |
@@ -392,9 +393,90 @@ def get_light_brightness_levels(self) -> list[int]: |
392 | 393 | return [0, 125, 250, 375, 500, 625, 750, 875, 1000] |
393 | 394 |
|
394 | 395 |
|
| 396 | +class ISEConverter(LetPotDeviceConverter): |
| 397 | + """Converters and info for device type ISE05, ISE06 (Automatic Watering System).""" |
| 398 | + |
| 399 | + @staticmethod |
| 400 | + def supports_type(device_type: str) -> bool: |
| 401 | + return device_type in ["ISE05", "ISE06"] |
| 402 | + |
| 403 | + def get_device_model(self) -> tuple[str, str] | None: |
| 404 | + return MODEL_DI |
| 405 | + |
| 406 | + def supported_features(self) -> DeviceFeature: |
| 407 | + return DeviceFeature(0) |
| 408 | + |
| 409 | + def get_current_status_message(self) -> list[int]: |
| 410 | + return [65, 1] |
| 411 | + |
| 412 | + def get_update_status_message(self, status: LetPotDeviceStatus) -> list[int]: |
| 413 | + return [ |
| 414 | + 65, |
| 415 | + 2, |
| 416 | + 1 if status.pump_mode > 0 else 0, |
| 417 | + 1 if status.pump_cycle_on is True else 0, |
| 418 | + math.floor((status.pump_duration or 0) / 256), |
| 419 | + (status.pump_duration or 0) % 256, |
| 420 | + math.floor((status.pump_cycle_duration or 0) / 256), |
| 421 | + (status.pump_cycle_duration or 0) % 256, |
| 422 | + math.floor((status.pump_cycle_workingduration or 0) / 256), |
| 423 | + (status.pump_cycle_workingduration or 0) % 256, |
| 424 | + status.pump_cycle_mode or 0, |
| 425 | + math.floor((status.pump_cycle_workinginterval or 0) / 256), |
| 426 | + (status.pump_cycle_workinginterval or 0) % 256, |
| 427 | + math.floor((status.pump_cycle_restinterval or 0) / 256), |
| 428 | + (status.pump_cycle_restinterval or 0) % 256, |
| 429 | + ] |
| 430 | + |
| 431 | + def convert_hex_to_status(self, message: PayloadType) -> LetPotDeviceStatus | None: |
| 432 | + data = self._hex_bytes_to_int_array(message) |
| 433 | + if data is None or data[4] != 66 or data[5] != 1: |
| 434 | + _LOGGER.debug("Invalid message received, ignoring: %s", message) |
| 435 | + return None |
| 436 | + |
| 437 | + if self._device_type == "ISE05": |
| 438 | + pump_cycle_skipwater = None |
| 439 | + else: |
| 440 | + pump_cycle_skipwater = math.floor((256 * data[35] + data[36]) / 60) |
| 441 | + |
| 442 | + return LetPotDeviceStatus( |
| 443 | + raw=data, |
| 444 | + light_brightness=None, |
| 445 | + light_mode=0, |
| 446 | + light_schedule_end=time(), |
| 447 | + light_schedule_start=time(), |
| 448 | + online=True, |
| 449 | + plant_days=0, |
| 450 | + pump_mode=data[9], |
| 451 | + pump_nutrient=None, |
| 452 | + pump_status=None, |
| 453 | + system_on=data[7] == 1, |
| 454 | + system_sound=None, |
| 455 | + errors=LetPotDeviceErrors(low_water=None), |
| 456 | + wifi_state=data[6], |
| 457 | + pump_on=data[8] == 1, |
| 458 | + pump_duration=256 * data[10] + data[11], |
| 459 | + pump_countdown=data[12:16], |
| 460 | + pump_cycle_on=data[16] == 1, |
| 461 | + pump_cycle_duration=256 * data[17] + data[18], |
| 462 | + pump_cycle_workingduration=256 * data[19] + data[20], |
| 463 | + pump_cycle_mode=data[21], |
| 464 | + pump_cycle_workinginterval=256 * data[22] + data[23], |
| 465 | + pump_cycle_restinterval=256 * data[24] + data[25], |
| 466 | + pump_works_latest_reason=data[26], |
| 467 | + pump_works_latest_time=data[27:31], |
| 468 | + pump_works_next_time=data[31:35], |
| 469 | + pump_cycle_skip_water=pump_cycle_skipwater, |
| 470 | + ) |
| 471 | + |
| 472 | + def get_light_brightness_levels(self) -> list[int]: |
| 473 | + return [] |
| 474 | + |
| 475 | + |
395 | 476 | CONVERTERS: Sequence[type[LetPotDeviceConverter]] = [ |
396 | 477 | LPHx1Converter, |
397 | 478 | IGSorAltConverter, |
398 | 479 | LPH6xConverter, |
399 | 480 | LPH63Converter, |
| 481 | + ISEConverter, |
400 | 482 | ] |
0 commit comments