From 0c58b5e53212047c42e118313a7ebcec132d87fb Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Thu, 5 Dec 2024 16:27:00 +0100 Subject: [PATCH] constify max duration --- kasa/smart/modules/alarm.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kasa/smart/modules/alarm.py b/kasa/smart/modules/alarm.py index 7a945b9b..86e16d8c 100644 --- a/kasa/smart/modules/alarm.py +++ b/kasa/smart/modules/alarm.py @@ -7,6 +7,8 @@ from typing import Literal from ...feature import Feature from ..smartmodule import SmartModule +DURATION_MAX = 10 * 60 + class Alarm(SmartModule): """Implementation of alarm module.""" @@ -81,7 +83,7 @@ class Alarm(SmartModule): attribute_setter="set_alarm_duration", category=Feature.Category.Config, type=Feature.Type.Number, - range_getter=lambda: (1, 10 * 60), + range_getter=lambda: (1, DURATION_MAX), ) ) self._add_feature( @@ -201,7 +203,7 @@ class Alarm(SmartModule): def _check_duration(self, duration: int) -> None: """Raise an exception on invalid duration.""" - if duration < 1 or duration > 10 * 60: + if duration < 1 or duration > DURATION_MAX: raise ValueError(f"Invalid duration {duration} available: 1-600") def _check_sound(self, sound: str) -> None: