haco/haco/switch.py

32 lines
556 B
Python
Raw Normal View History

2025-11-23 11:34:49 +00:00
from dataclasses import dataclass
2023-08-29 16:01:23 +01:00
2025-11-24 10:10:41 +00:00
from haco.control import Control
2025-11-23 11:30:12 +00:00
2023-08-29 16:01:23 +01:00
2025-11-23 11:34:49 +00:00
@dataclass(kw_only=True)
2023-08-29 16:01:23 +01:00
class Switch(Control):
2026-04-29 10:47:13 +01:00
"""
A switch control that can be toggled on or off.
"""
DATA = dict(
platform='switch'
)
2026-04-29 10:47:13 +01:00
def command(self, value: bool) -> bool:
"""
Handle toggle commands from Home Assistant.
2023-08-29 16:01:23 +01:00
2026-04-29 10:47:13 +01:00
"""
2025-11-23 11:34:49 +00:00
raise NotImplementedError()
2023-08-29 16:01:23 +01:00
2026-04-29 10:47:13 +01:00
def state(self, value: bool | None) -> bool:
"""
Return the current state of the switch.
"""
2025-11-23 11:34:49 +00:00
raise NotImplementedError()