Add night mode module

This commit is contained in:
Teemu Rytilahti 2025-01-12 14:26:59 +01:00
parent 1f45f425a0
commit 264dc4da71
2 changed files with 47 additions and 0 deletions

View File

@ -26,6 +26,7 @@ from .lightstripeffect import LightStripEffect
from .lighttransition import LightTransition
from .matter import Matter
from .motionsensor import MotionSensor
from .nightmode import NightMode
from .overheatprotection import OverheatProtection
from .reportmode import ReportMode
from .temperaturecontrol import TemperatureControl
@ -70,4 +71,5 @@ __all__ = [
"OverheatProtection",
"HomeKit",
"Matter",
"NightMode",
]

View File

@ -0,0 +1,45 @@
"""Night mode module."""
from ..smartmodule import SmartModule
class NightMode(SmartModule):
"""Implementation for night mode module."""
REQUIRED_COMPONENT = "night_mode"
QUERY_GETTER_NAME = "get_night_mode_info"
# {'get_night_mode_info': {'enable': False,
# 'effective_time':
# {'type': 'sunrise_sunset', 'start_min': 1244, 'end_min': 375,
# 'sunrise_offset': 0, 'sunset_offset': 0}}}
@property
def enabled(self) -> bool:
"""Return True if night mode enabled."""
return self.data["enable"]
@property
def type(self) -> str:
"""Return night mode type."""
return self.data["effective_mode"]["type"]
@property
def start_time(self) -> int:
"""Return night mode start time."""
return self.data["effective_time"]["start_min"]
@property
def end_time(self) -> int:
"""Return night mode end time."""
return self.data["effective_time"]["end_min"]
@property
def sunrise_offset(self) -> int:
"""Return sunrise offset."""
return self.data["effective_time"]["sunrise_offset"]
@property
def sunset_offset(self) -> int:
"""Return sunset offset."""
return self.data["effective_time"]["sunset_offset"]