Skip to content

Commit e68430b

Browse files
committed
WIP: converter for testing ISE05/ISE06
1 parent af0d1bb commit e68430b

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

letpot/converters.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
_LOGGER = logging.getLogger(__name__)
1919

2020
MODEL_AIR = ("LetPot Air", "LPH-AIR")
21+
MODEL_DI = ("LetPot Automatic Watering System", "DI")
2122
MODEL_MAX = ("LetPot Max", "LPH-MAX")
2223
MODEL_MINI = ("LetPot Mini", "LPH-MINI")
2324
MODEL_PRO = ("LetPot Pro", "LPH-PRO")
@@ -392,9 +393,90 @@ def get_light_brightness_levels(self) -> list[int]:
392393
return [0, 125, 250, 375, 500, 625, 750, 875, 1000]
393394

394395

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+
395476
CONVERTERS: Sequence[type[LetPotDeviceConverter]] = [
396477
LPHx1Converter,
397478
IGSorAltConverter,
398479
LPH6xConverter,
399480
LPH63Converter,
481+
ISEConverter,
400482
]

letpot/models.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,17 @@ class LetPotDeviceStatus:
8585
temperature_value: int | None = None
8686
water_mode: int | None = None
8787
water_level: int | None = None
88+
wifi_state: int | None = None
89+
pump_on: bool | None = None
90+
pump_duration: int | None = None
91+
pump_countdown: list[int] | None = None
92+
pump_cycle_on: bool | None = None
93+
pump_cycle_duration: int | None = None
94+
pump_cycle_workingduration: int | None = None
95+
pump_cycle_mode: int | None = None
96+
pump_cycle_workinginterval: int | None = None
97+
pump_cycle_restinterval: int | None = None
98+
pump_works_latest_reason: int | None = None
99+
pump_works_latest_time: list[int] | None = None
100+
pump_works_next_time: list[int] | None = None
101+
pump_cycle_skip_water: int | None = None

0 commit comments

Comments
 (0)