Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions letpot/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,25 @@ def _hex_bytes_to_int_array(self, hex_message: PayloadType) -> list[int] | None:


class LPHx1Converter(LetPotDeviceConverter):
"""Converters and info for device type LPH11 (Mini), LPH21 (Air), LPH31 (SE)."""
"""Converters and info for device type LPH11 (Mini), LPH21, LPH22 (Air), LPH31, LPH32 (SE)."""

@staticmethod
def supports_type(device_type: str) -> bool:
return device_type in ["LPH11", "LPH21", "LPH31"]
return device_type in ["LPH11", "LPH21", "LPH22", "LPH31", "LPH32"]

def get_device_model(self) -> tuple[str, str] | None:
if self._device_type == "LPH11":
return MODEL_MINI
elif self._device_type == "LPH21":
elif self._device_type in ["LPH21", "LPH22"]:
return MODEL_AIR
elif self._device_type == "LPH31":
elif self._device_type in ["LPH31", "LPH32"]:
return MODEL_SE
else:
return None

def supported_features(self) -> DeviceFeature:
features = DeviceFeature.CATEGORY_HYDROPONIC_GARDEN | DeviceFeature.PUMP_STATUS
if self._device_type in ["LPH21", "LPH31"]:
if self._device_type in ["LPH21", "LPH22", "LPH31", "LPH32"]:
features |= DeviceFeature.LIGHT_BRIGHTNESS_LOW_HIGH
return features

Expand Down Expand Up @@ -137,7 +137,7 @@ def convert_hex_to_status(self, message: PayloadType) -> LetPotDeviceStatus | No
_LOGGER.debug("Invalid message received, ignoring: %s", message)
return None

if self._device_type == "LPH21":
if self._device_type in ["LPH21", "LPH22"]:
error_pump_malfunction = None
else:
error_pump_malfunction = True if data[7] & 2 else False
Expand All @@ -162,7 +162,11 @@ def convert_hex_to_status(self, message: PayloadType) -> LetPotDeviceStatus | No
)

def get_light_brightness_levels(self) -> list[int]:
return [500, 1000] if self._device_type in ["LPH21", "LPH31"] else []
return (
[500, 1000]
if self._device_type in ["LPH21", "LPH22", "LPH31", "LPH32"]
else []
)


class IGSorAltConverter(LetPotDeviceConverter):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
"IGS01",
"LPH11",
"LPH21",
"LPH22",
"LPH27",
"LPH31",
"LPH32",
"LPH37",
"LPH39",
"LPH60",
Expand Down