Skip to content

Commit f27f45e

Browse files
committed
Adjust device type exception to be a specific feature exception
1 parent f392627 commit f27f45e

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

letpot/converters.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from aiomqtt.types import PayloadType
1010

11-
from letpot.exceptions import LetPotDeviceTypeException, LetPotException
11+
from letpot.exceptions import LetPotDeviceCategoryException, LetPotException
1212
from letpot.models import (
1313
CycleWateringMode,
1414
DeviceFeature,
@@ -117,7 +117,7 @@ def get_current_status_message(self) -> list[int]:
117117

118118
def get_update_status_message(self, status: LetPotDeviceStatus) -> list[int]:
119119
if not isinstance(status, LetPotGardenStatus):
120-
raise LetPotDeviceTypeException()
120+
raise LetPotDeviceCategoryException()
121121
return [
122122
97,
123123
2,
@@ -196,7 +196,7 @@ def get_current_status_message(self) -> list[int]:
196196

197197
def get_update_status_message(self, status: LetPotDeviceStatus) -> list[int]:
198198
if not isinstance(status, LetPotGardenStatus):
199-
raise LetPotDeviceTypeException()
199+
raise LetPotDeviceCategoryException()
200200
return [
201201
11,
202202
2,
@@ -271,7 +271,7 @@ def get_current_status_message(self) -> list[int]:
271271

272272
def get_update_status_message(self, status: LetPotDeviceStatus) -> list[int]:
273273
if not isinstance(status, LetPotGardenStatus):
274-
raise LetPotDeviceTypeException()
274+
raise LetPotDeviceCategoryException()
275275
return [
276276
13,
277277
2,
@@ -354,7 +354,7 @@ def get_current_status_message(self) -> list[int]:
354354

355355
def get_update_status_message(self, status: LetPotDeviceStatus) -> list[int]:
356356
if not isinstance(status, LetPotGardenStatus):
357-
raise LetPotDeviceTypeException()
357+
raise LetPotDeviceCategoryException()
358358
return [
359359
101,
360360
2,
@@ -426,7 +426,7 @@ def get_current_status_message(self) -> list[int]:
426426

427427
def get_update_status_message(self, status: LetPotDeviceStatus) -> list[int]:
428428
if not isinstance(status, LetPotWateringSystemStatus):
429-
raise LetPotDeviceTypeException()
429+
raise LetPotDeviceCategoryException()
430430
return [
431431
65,
432432
2,

letpot/deviceclient.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from letpot.exceptions import (
1919
LetPotAuthenticationException,
2020
LetPotConnectionException,
21-
LetPotDeviceTypeException,
21+
LetPotDeviceCategoryException,
2222
LetPotException,
2323
LetPotFeatureException,
2424
)
@@ -410,7 +410,7 @@ async def set_light_brightness(self, serial: str, level: int) -> None:
410410

411411
use_status = self._get_publish_status(serial)
412412
if not isinstance(use_status, LetPotGardenStatus):
413-
raise LetPotDeviceTypeException()
413+
raise LetPotDeviceCategoryException()
414414
status = dataclasses.replace(use_status, light_brightness=level)
415415
await self._publish_status(serial, status)
416416

@@ -419,7 +419,7 @@ async def set_light_mode(self, serial: str, mode: LightMode) -> None:
419419
"""Set the light mode for this device (flower/vegetable)."""
420420
use_status = self._get_publish_status(serial)
421421
if not isinstance(use_status, LetPotGardenStatus):
422-
raise LetPotDeviceTypeException()
422+
raise LetPotDeviceCategoryException()
423423
status = dataclasses.replace(use_status, light_mode=mode)
424424
await self._publish_status(serial, status)
425425

@@ -430,7 +430,7 @@ async def set_light_schedule(
430430
"""Set the light schedule for this device (start time and/or end time)."""
431431
use_status = self._get_publish_status(serial)
432432
if not isinstance(use_status, LetPotGardenStatus):
433-
raise LetPotDeviceTypeException()
433+
raise LetPotDeviceCategoryException()
434434
start_time = use_status.light_schedule_start if start is None else start
435435
end_time = use_status.light_schedule_end if end is None else end
436436
status = dataclasses.replace(
@@ -445,7 +445,7 @@ async def set_plant_days(self, serial: str, days: int) -> None:
445445
"""Set the plant days counter for this device (number of days)."""
446446
use_status = self._get_publish_status(serial)
447447
if not isinstance(use_status, LetPotGardenStatus):
448-
raise LetPotDeviceTypeException()
448+
raise LetPotDeviceCategoryException()
449449
status = dataclasses.replace(use_status, plant_days=days)
450450
await self._publish_status(serial, status)
451451

@@ -454,7 +454,7 @@ async def set_power(self, serial: str, on: bool) -> None:
454454
"""Set the general power for this device (on/off)."""
455455
use_status = self._get_publish_status(serial)
456456
if not isinstance(use_status, LetPotGardenStatus):
457-
raise LetPotDeviceTypeException()
457+
raise LetPotDeviceCategoryException()
458458
status = dataclasses.replace(use_status, system_on=on)
459459
await self._publish_status(serial, status)
460460

@@ -470,7 +470,7 @@ async def set_sound(self, serial: str, on: bool) -> None:
470470
"""Set the alarm sound for this device (on/off)."""
471471
use_status = self._get_publish_status(serial)
472472
if not isinstance(use_status, LetPotGardenStatus):
473-
raise LetPotDeviceTypeException()
473+
raise LetPotDeviceCategoryException()
474474
status = dataclasses.replace(use_status, system_sound=on)
475475
await self._publish_status(serial, status)
476476

@@ -479,7 +479,7 @@ async def set_temperature_unit(self, serial: str, unit: TemperatureUnit) -> None
479479
"""Set the temperature unit for this device (Celsius/Fahrenheit)."""
480480
use_status = self._get_publish_status(serial)
481481
if not isinstance(use_status, LetPotGardenStatus):
482-
raise LetPotDeviceTypeException()
482+
raise LetPotDeviceCategoryException()
483483
status = dataclasses.replace(use_status, temperature_unit=unit)
484484
await self._publish_status(serial, status)
485485

@@ -488,7 +488,7 @@ async def set_water_mode(self, serial: str, on: bool) -> None:
488488
"""Set the automatic water/nutrient mode for this device (on/off)."""
489489
use_status = self._get_publish_status(serial)
490490
if not isinstance(use_status, LetPotGardenStatus):
491-
raise LetPotDeviceTypeException()
491+
raise LetPotDeviceCategoryException()
492492
status = dataclasses.replace(use_status, water_mode=1 if on else 0)
493493
await self._publish_status(serial, status)
494494

letpot/exceptions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ class LetPotAuthenticationException(LetPotException):
1313
"""LetPot authentication exception."""
1414

1515

16-
class LetPotDeviceTypeException(LetPotException):
17-
"""LetPot incorrect device type exception."""
18-
19-
2016
class LetPotFeatureException(LetPotException):
2117
"""LetPot device feature exception."""
18+
19+
20+
class LetPotDeviceCategoryException(LetPotFeatureException):
21+
"""LetPot incorrect device type exception."""

0 commit comments

Comments
 (0)