Implement switch

This commit is contained in:
Edward Brown 2025-11-23 11:34:49 +00:00
parent 97267b8e29
commit ea8650f232
2 changed files with 13 additions and 9 deletions

View file

@ -5,6 +5,7 @@ from haco.client import ClientHaco
from haco.climate import Climate
from haco.constants import MQTT_HOST
from haco.device import Device
from haco.switch import Switch
async def main():
@ -12,7 +13,9 @@ async def main():
climate_b = Climate(name="Dev Climate B", fan_modes=['a', 'b', 'c'])
b1 = Button(name="Dev Button 1")
device = Device(name="Dev Device", controls=[climate_a, climate_b, b1])
s1 = Switch(name="Dev Switch 1")
device = Device(name="Dev Device", controls=[climate_a, climate_b, b1, s1])
client = ClientHaco(hostname=MQTT_HOST, device=device)

View file

@ -1,14 +1,15 @@
from haco.tools import invert_bool
from dataclasses import dataclass
from typing import Literal
from haco.control import Control
from control import Control
@dataclass(kw_only=True)
class Switch(Control):
NAME = 'switch'
platform: Literal["climate"] = "switch"
def __init__(self, name, icon=None):
super().__init__(name, icon=icon)
def command(self, value):
raise NotImplementedError()
@property
def control_type(self):
return invert_bool
def state(self, value):
raise NotImplementedError()