From eaaa24e6e71b92a3b49fd57ed3c6d19d7a52cec3 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Mon, 1 Dec 2025 16:36:47 +0000 Subject: [PATCH 01/72] Move Text control --- haco/{v0/haco => }/text.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename haco/{v0/haco => }/text.py (100%) diff --git a/haco/v0/haco/text.py b/haco/text.py similarity index 100% rename from haco/v0/haco/text.py rename to haco/text.py From 5318014464ee35ea990d92d9a0ca9dedbad06f33 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Mon, 1 Dec 2025 16:42:54 +0000 Subject: [PATCH 02/72] Move Sensor control --- haco/{v0/haco => }/sensor.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename haco/{v0/haco => }/sensor.py (100%) diff --git a/haco/v0/haco/sensor.py b/haco/sensor.py similarity index 100% rename from haco/v0/haco/sensor.py rename to haco/sensor.py From 911b75a295e87d97a8ebadc482d5276863f1d72a Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 2 Dec 2025 09:15:27 +0000 Subject: [PATCH 03/72] Implement Text and Sensor controls --- haco/sensor.py | 117 ++++++++++++++++++++++++++++++++++--------------- haco/text.py | 42 +++++++++--------- haco/version | 2 +- 3 files changed, 104 insertions(+), 57 deletions(-) diff --git a/haco/sensor.py b/haco/sensor.py index 191d2b3..a430d32 100644 --- a/haco/sensor.py +++ b/haco/sensor.py @@ -1,44 +1,89 @@ -from haco.data.type_sensor import DeviceClassSensor -from haco.data.uom import Uom +from dataclasses import dataclass +from enum import StrEnum -import haco.capabilities -import haco.topics -from haco import schema +from haco.capabilities import Capability from haco.control import Control +from haco.uom import Uom +from haco.utils import ConvertersString +class DeviceClass(StrEnum): + """ + + Sourced from: https://www.home-assistant.io/integrations/sensor/#device-class + + """ + + APPARENT_POWER = "apparent_power" # Apparent power in VA. + AQI = "aqi" # Air Quality Index (unitless). + ATMOSPHERIC_PRESSURE = "atmospheric_pressure" # Atmospheric pressure in cbar, bar, hPa, inHg, kPa, mbar, Pa, or psi. + BATTERY = "battery" # Battery percentage in %. + CARBON_DIOXIDE = "carbon_dioxide" # CO₂ in ppm. + CARBON_MONOXIDE = "carbon_monoxide" # CO in ppm. + CURRENT = "current" # Current in A or mA. + DATA_RATE = "data_rate" # Data rate in bit/s, kbit/s, Mbit/s, Gbit/s, B/s, kB/s, MB/s, GB/s, KiB/s, MiB/s, or GiB/s. + DATA_SIZE = "data_size" # Data size in bit, kbit, Mbit, Gbit, B, kB, MB, GB, TB, PB, EB, ZB, YB, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, or YiB. + DATE = "date" # ISO 8601 date string. + DISTANCE = "distance" # Distance in km, m, cm, mm, mi, yd, or in. + DURATION = "duration" # Duration in d, h, min, or s. + ENERGY = "energy" # Energy in Wh, kWh, MWh, MJ, or GJ. + ENERGY_STORAGE = "energy_storage" # Stored energy in Wh, kWh, MWh, MJ, or GJ. + ENUM = "enum" # Limited set of non-numeric states. + FREQUENCY = "frequency" # Frequency in Hz, kHz, MHz, or GHz. + GAS = "gas" # Gas volume in m³, ft³, or CCF. + HUMIDITY = "humidity" # Humidity in %. + ILLUMINANCE = "illuminance" # Light level in lx. + IRRADIANCE = "irradiance" # Irradiance in W/m² or BTU/(h⋅ft²). + MOISTURE = "moisture" # Water content in %. + MONETARY = "monetary" # Monetary value (ISO 4217). + NITROGEN_DIOXIDE = "nitrogen_dioxide" # NO₂ in µg/m³. + NITROGEN_MONOXIDE = "nitrogen_monoxide" # NO in µg/m³. + NITROUS_OXIDE = "nitrous_oxide" # N₂O in µg/m³. + OZONE = "ozone" # O₃ in µg/m³. + PH = "ph" # pH value. + PM1 = "pm1" # Particulate matter <1µm in µg/m³. + PM25 = "pm25" # Particulate matter <2.5µm in µg/m³. + PM10 = "pm10" # Particulate matter <10µm in µg/m³. + POWER_FACTOR = "power_factor" # Power factor (unitless or %). + POWER = "power" # Power in W or kW. + PRECIPITATION = "precipitation" # Accumulated precipitation. + PRECIPITATION_INTENSITY = "precipitation_intensity" # Precipitation rate. + PRESSURE = "pressure" # Pressure in Pa, kPa, hPa, bar, cbar, mbar, mmHg, inHg, or psi. + REACTIVE_POWER = "reactive_power" # Reactive power in var. + SIGNAL_STRENGTH = "signal_strength" # Signal strength in dB or dBm. + SOUND_PRESSURE = "sound_pressure" # Sound pressure in dB or dBA. + SPEED = "speed" # Speed in ft/s, in/d, in/h, km/h, kn, m/s, mph, or mm/d. + SULPHUR_DIOXIDE = "sulphur_dioxide" # SO₂ in µg/m³. + TEMPERATURE = "temperature" # Temperature in °C, °F, or K. + TIMESTAMP = "timestamp" # Datetime object or ISO 8601 string. + VOLATILE_ORGANIC_COMPOUNDS = "volatile_organic_compounds" # VOC in µg/m³. + VOLATILE_ORGANIC_COMPOUNDS_PARTS = "volatile_organic_compounds_parts" # VOC in ppm or ppb. + VOLTAGE = "voltage" # Voltage in V or mV. + VOLUME = "volume" # Volume in L, mL, gal, fl. oz., m³, ft³, or CCF. + VOLUME_STORAGE = "volume_storage" # Stored volume. + WATER = "water" # Water consumption in L, gal, m³, ft³, or CCF. + WEIGHT = "weight" # Mass in kg, g, mg, µg, oz, lb, or st. + WIND_SPEED = "wind_speed" # Wind speed in ft/s, km/h, kn, m/s, or mph. + + +@dataclass(kw_only=True) class Sensor(Control): - NAME = 'sensor' + DATA = dict( + platform='sensor' + ) + converters = ConvertersString - UOM_TYPE = DeviceClassSensor - UOM = Uom + unit_of_measurement: Uom | None = None + device_class: DeviceClass | None = None + + def command(self, value): + raise NotImplementedError() + + def state(self, value): + raise NotImplementedError() @classmethod - def get_schema(cls): - return schema.Schema( - capabilities=[ - haco.capabilities.Capability( - ha=None, - tasmota=schema.Tasmota(announce_data=haco.topics.AnnounceTopic(key='{io_ha}_topic')) - ) - ] - ) - - def __init__(self, name, data_type=None, uom=None, icon=None, uom_type=None): - self.data_type = data_type - self.device_class = uom_type - self.uom = uom - - super().__init__(name, icon=icon) - - @property - def control_type(self): - return self.data_type or (lambda v: v) - - def get_config_ha_ex(self): - data = { - 'unit_of_measurement': self.uom, - 'device_class': self.device_class - } - - return data + def get_capabilities(cls): + return [ + Capability(name=None, command=None) + ] diff --git a/haco/text.py b/haco/text.py index 8a21b55..e9132bb 100644 --- a/haco/text.py +++ b/haco/text.py @@ -1,27 +1,29 @@ +from dataclasses import dataclass +from enum import StrEnum + from haco.control import Control - -from haco.tools import get_range_pair +from haco.utils import ConvertersString +class Mode(StrEnum): + TEXT = "text" + PASSWORD = "password" + + +@dataclass(kw_only=True) class Text(Control): - NAME = 'text' + DATA = dict( + platform='text' + ) + converters = ConvertersString - def __init__(self, name, icon=None, size_range: range = None, pattern: str = None): - self.min, self.max = get_range_pair(size_range) - self.pattern = pattern + pattern: str | None = None + min: int | None = None + max: int | None = None + mode: Mode = Mode.TEXT - super().__init__(name, icon=icon) + def command(self, value): + raise NotImplementedError() - def get_config_ha_ex(self): - data = { - 'min': self.min, - 'max': self.max, - 'pattern': self.pattern, - 'mode': self.__class__.__name__.lower() - } - - return data - - -class Password(Text): - ... + def state(self, value): + raise NotImplementedError() diff --git a/haco/version b/haco/version index 8294c18..7693c96 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.1.2 \ No newline at end of file +0.1.3 \ No newline at end of file From 74f967f7f939484aa7dcc06b3a718393cb6922ee Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 10 Dec 2025 15:19:44 +0000 Subject: [PATCH 04/72] Stop automatically publishing state on announce, and add separate initialise method for announce+state --- haco/client.py | 11 +++-------- haco/control.py | 11 +++++------ haco/device.py | 5 ++++- haco/version | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/haco/client.py b/haco/client.py index ce7abcb..671bf4b 100644 --- a/haco/client.py +++ b/haco/client.py @@ -34,7 +34,7 @@ class ClientHaco(mqtt.Client): payload = message.payload.decode() logger.info(f"{message.topic.value}{Constants.ARROW}{payload}") topic_command = self.device.subscriptions[message.topic.value] - echo_val = await topic_command.handle(message) + await topic_command.handle(message) @@ -42,15 +42,10 @@ class ClientHaco(mqtt.Client): while True: try: async with self: - - await self.device.announce() - + await self.device.initialise() await self.publish(self.will.topic, self.ONLINE, retain=True) - - # await self.publish('haco/development/3012edb1a6d4-1ed9c3469373/dev-device/dev-climate-b/power/command', "OFF", retain=True) - await self.handle() except aiomqtt.MqttError as e: - logger.info(f"⚠️ MQTT disconnected: {e}; retrying in 5s") + logger.info(f"MQTT disconnected: {e}; retrying in 5s") await asyncio.sleep(5) diff --git a/haco/control.py b/haco/control.py index b14cdb0..f1e458b 100644 --- a/haco/control.py +++ b/haco/control.py @@ -98,7 +98,11 @@ class Control(Base, Generic[DeviceT]): return data async def initialise(self): - ... + await self.announce() + for capability in self.capabilities: + if not capability.state: + continue + await capability.state.handle(value=None) async def announce(self): """ @@ -111,11 +115,6 @@ class Control(Base, Generic[DeviceT]): logger.info(f'Announcing {topic} with {data_json}') await self.device.client.publish(topic, data_json, retain=True) - for capability in self.capabilities: - if not capability.state: - continue - await capability.state.handle(value=None) - if __name__ == "__main__": diff --git a/haco/device.py b/haco/device.py index cc25594..718cc60 100644 --- a/haco/device.py +++ b/haco/device.py @@ -24,7 +24,6 @@ class Device(Base): controls: List[Control] = field(default_factory=list, metadata=dict(exclude=True)) parent: ClientHaco | None = field(metadata=dict(exclude=True), init=False) - # announce: dict | None = field(default=None, metadata=dict(exclude=True), init=False) subscriptions: dict | None = field(default=None, metadata=dict(exclude=True), init=False) @@ -52,6 +51,10 @@ class Device(Base): for control in self.controls: await control.announce() + async def initialise(self): + for control in self.controls: + await control.initialise() + @property def client(self): diff --git a/haco/version b/haco/version index 7693c96..446ba66 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.1.3 \ No newline at end of file +0.1.4 \ No newline at end of file From ca3d79458778a42cbf59786d9f61f5629e0f9de9 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 24 Dec 2025 13:35:02 +0000 Subject: [PATCH 05/72] Refine logging --- haco/client.py | 7 +++---- haco/constants.py | 3 +++ haco/control.py | 16 ++++++++-------- haco/device.py | 3 --- haco/topics.py | 16 +++++++++++----- haco/utils.py | 4 ++++ haco/version | 2 +- 7 files changed, 30 insertions(+), 21 deletions(-) diff --git a/haco/client.py b/haco/client.py index 671bf4b..341937d 100644 --- a/haco/client.py +++ b/haco/client.py @@ -3,15 +3,15 @@ import asyncio from fmtr.tools import mqtt, Constants from haco import constants +from haco.constants import SUBSCRIBE from haco.obs import logger +from haco.utils import get_prefix class ClientHaco(mqtt.Client): ONLINE = 'online' OFFLINE = 'offline' - aiomqtt.Client - def __init__(self, *args, device=None, will=None, identifier=None, **kwargs): self.will = will or mqtt.Will(topic=str(constants.TOPIC_AVAIL), payload=self.OFFLINE, retain=True, qos=1, ) identifier = identifier or constants.CLIENT_ID @@ -24,10 +24,9 @@ class ClientHaco(mqtt.Client): return constants.TOPIC_CLIENT async def handle(self): - """Listen for command messages from HA.""" for topic_sub in self.device.subscriptions.keys(): - logger.info(f"Subscribing to {topic_sub}") + logger.info(f"{get_prefix(SUBSCRIBE)}: {topic_sub}") await self.subscribe(topic_sub) async for message in self.messages: diff --git a/haco/constants.py b/haco/constants.py index 4b22965..3e66065 100644 --- a/haco/constants.py +++ b/haco/constants.py @@ -13,3 +13,6 @@ TOPIC_ROOT = Path(paths.name) / env.CHANNEL TOPIC_CLIENT = TOPIC_ROOT / CLIENT_ID TOPIC_AVAIL = TOPIC_CLIENT / STATUS PREFIX_MDI = "mdi:" + +ANNOUNCE = 'announce' +SUBSCRIBE = 'subscribe' diff --git a/haco/control.py b/haco/control.py index f1e458b..6a7f27a 100644 --- a/haco/control.py +++ b/haco/control.py @@ -3,12 +3,13 @@ from __future__ import annotations from dataclasses import dataclass, field from typing import TYPE_CHECKING, TypeVar, Generic, Type, ClassVar +from fmtr.tools import Constants from fmtr.tools.json_tools import to_json from haco.base import Base from haco.capabilities import Capability -from haco.constants import PREFIX_MDI +from haco.constants import PREFIX_MDI, ANNOUNCE from haco.obs import logger -from haco.utils import sanitize_name, Converters, ConvertersBool +from haco.utils import sanitize_name, Converters, ConvertersBool, get_prefix if TYPE_CHECKING: from haco.device import Device @@ -27,7 +28,6 @@ class Control(Base, Generic[DeviceT]): unique_id: str | None = field(default=None, init=False) availability_topic: str | None = field(default=None, init=False) - # announce: dict | None = field(default=None, metadata=dict(exclude=True)) subscriptions: dict | None = field(default=None, metadata=dict(exclude=True), init=False) def __post_init__(self): @@ -49,9 +49,6 @@ class Control(Base, Generic[DeviceT]): self.unique_id = self.get_unique_id() self.availability_topic = self.get_availability_topic() self.subscriptions = self.get_subscriptions() - #self.announce = self.get_announce() - - @property def parent(self): @@ -111,8 +108,11 @@ class Control(Base, Generic[DeviceT]): """ topic = self.announce_topic - data_json = to_json(self.get_announce()) - logger.info(f'Announcing {topic} with {data_json}') + data = self.get_announce() + data_json = to_json(data) + + logger.info(f'{get_prefix(ANNOUNCE)}: {data} {Constants.ARROW_RIGHT} {topic}') + await self.device.client.publish(topic, data_json, retain=True) diff --git a/haco/device.py b/haco/device.py index 718cc60..e0587ac 100644 --- a/haco/device.py +++ b/haco/device.py @@ -34,11 +34,8 @@ class Device(Base): for control in self.controls: control.set_parent(self) - #self.announce = self.get_announce() self.subscriptions = self.get_subscriptions() - self - @cached_property def topic(self): return self.client.topic / self.name_san diff --git a/haco/topics.py b/haco/topics.py index 583fce6..3367062 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -4,8 +4,9 @@ from dataclasses import dataclass, field from functools import cached_property from typing import ClassVar, TYPE_CHECKING, Callable -from fmtr.tools import aio +from fmtr.tools import aio, Constants from haco.obs import logger +from haco.utils import get_prefix if TYPE_CHECKING: from capabilities import Capability @@ -107,6 +108,9 @@ class AnnounceTopicState(AnnounceTopic): value_raw = self.capability.converters.state(value) await self.capability.control.device.client.publish(self.topic, value_raw) + + logger.info(f'{get_prefix(self.IO)}: {self.topic} {Constants.ARROW_RIGHT} {value_raw}') + return value_raw @dataclass(kw_only=True) @@ -119,14 +123,17 @@ class AnnounceTopicCommand(AnnounceTopic): async def handle(self, message): + value = message.payload.decode('utf-8') + value = self.capability.converters.command(value) + + logger.info(f'{get_prefix(self.IO)}: {value} {Constants.ARROW_LEFT} {self.topic}') + + if not self.control_method: logger.error(f'Incomplete base class: {self.callback_class_method_name}') return is_async = aio.is_async(self.control_method) - value = message.payload.decode('utf-8') - value = self.capability.converters.command(value) - try: if is_async: @@ -138,7 +145,6 @@ class AnnounceTopicCommand(AnnounceTopic): logger.warning(f'Subclass has not implemented method: {self.callback_class_method_name} {self.topic} {value}') return - # Echo back as new state topic_state = self.state if topic_state: await topic_state.handle(value_raw) diff --git a/haco/utils.py b/haco/utils.py index c223482..4d12e1e 100644 --- a/haco/utils.py +++ b/haco/utils.py @@ -57,3 +57,7 @@ class ConvertersNumeric(Converters): @dataclass class Metadata: exclude: bool = False + + +def get_prefix(io: str) -> str: + return io[:2].upper() diff --git a/haco/version b/haco/version index 446ba66..def9a01 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.1.4 \ No newline at end of file +0.1.5 \ No newline at end of file From 7b0e27407a0354204117020537e6d859634ee092 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 24 Dec 2025 13:43:53 +0000 Subject: [PATCH 06/72] Remove redundant log message --- haco/client.py | 4 +--- haco/version | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/haco/client.py b/haco/client.py index 341937d..74ab41b 100644 --- a/haco/client.py +++ b/haco/client.py @@ -1,7 +1,7 @@ import aiomqtt import asyncio -from fmtr.tools import mqtt, Constants +from fmtr.tools import mqtt from haco import constants from haco.constants import SUBSCRIBE from haco.obs import logger @@ -30,8 +30,6 @@ class ClientHaco(mqtt.Client): await self.subscribe(topic_sub) async for message in self.messages: - payload = message.payload.decode() - logger.info(f"{message.topic.value}{Constants.ARROW}{payload}") topic_command = self.device.subscriptions[message.topic.value] await topic_command.handle(message) diff --git a/haco/version b/haco/version index def9a01..a192233 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.1.5 \ No newline at end of file +0.1.6 \ No newline at end of file From e16df74960fa16befbf425e4bb13d9d5c9bcef3d Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 25 Dec 2025 19:37:36 +0000 Subject: [PATCH 07/72] Move binary_sensor module --- haco/{v0/haco => }/binary_sensor.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename haco/{v0/haco => }/binary_sensor.py (100%) diff --git a/haco/v0/haco/binary_sensor.py b/haco/binary_sensor.py similarity index 100% rename from haco/v0/haco/binary_sensor.py rename to haco/binary_sensor.py From 55404d43d311ff60a5caa7f71f109e3e3310b146 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 25 Dec 2025 22:32:35 +0000 Subject: [PATCH 08/72] Add BinarySensor control --- haco/binary_sensor.py | 61 +++++++++++++++++++++++++++++++++++++++++++ haco/version | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/haco/binary_sensor.py b/haco/binary_sensor.py index b28b04f..15b5f24 100644 --- a/haco/binary_sensor.py +++ b/haco/binary_sensor.py @@ -1,3 +1,64 @@ +from dataclasses import dataclass +from enum import StrEnum + +from haco.capabilities import Capability +from haco.control import Control +class DeviceClass(StrEnum): + """ + Sourced from: + https://www.home-assistant.io/integrations/binary_sensor/#device-class + + """ + + BATTERY = "battery" # on means low, off means normal + BATTERY_CHARGING = "battery_charging" # on means charging, off means not charging + CARBON_MONOXIDE = "carbon_monoxide" # on means carbon monoxide detected, off no carbon monoxide (clear) + COLD = "cold" # on means cold, off means normal + CONNECTIVITY = "connectivity" # on means connected, off means disconnected + DOOR = "door" # on means open, off means closed + GARAGE_DOOR = "garage_door" # on means open, off means closed + GAS = "gas" # on means gas detected, off means no gas (clear) + HEAT = "heat" # on means hot, off means normal + LIGHT = "light" # on means light detected, off means no light + LOCK = "lock" # on means open (unlocked), off means closed (locked) + MOISTURE = "moisture" # on means moisture detected (wet), off means no moisture (dry) + MOTION = "motion" # on means motion detected, off means no motion (clear) + MOVING = "moving" # on means moving, off means not moving (stopped) + OCCUPANCY = "occupancy" # on means occupied (detected), off means not occupied (clear) + OPENING = "opening" # on means open, off means closed + PLUG = "plug" # on means device is plugged in, off means device is unplugged + POWER = "power" # on means power detected, off means no power + PRESENCE = "presence" # on means home, off means away + PROBLEM = "problem" # on means problem detected, off means no problem (OK) + RUNNING = "running" # on means running, off means not running + SAFETY = "safety" # on means unsafe, off means safe + SMOKE = "smoke" # on means smoke detected, off means no smoke (clear) + SOUND = "sound" # on means sound detected, off means no sound (clear) + TAMPER = "tamper" # on means tampering detected, off means no tampering (clear) + UPDATE = "update" # on means update available, off means up-to-date + VIBRATION = "vibration" # on means vibration detected, off means no vibration (clear) + WINDOW = "window" # on means open, off means closed + + +@dataclass(kw_only=True) +class BinarySensor(Control): + DATA = dict( + platform='binary_sensor' + ) + + device_class: DeviceClass | None = None + + def command(self, value): + raise NotImplementedError() + + def state(self, value): + raise NotImplementedError() + + @classmethod + def get_capabilities(cls): + return [ + Capability(name=None, command=None) + ] diff --git a/haco/version b/haco/version index a192233..a1e1395 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.1.6 \ No newline at end of file +0.1.7 \ No newline at end of file From 11a74b4e987dfd5bfa0c35f81aa5bff755a79f12 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 31 Dec 2025 14:48:13 +0000 Subject: [PATCH 09/72] Fix state topics not being retained by default --- haco/topics.py | 2 +- haco/version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/haco/topics.py b/haco/topics.py index 3367062..963f2b0 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -107,7 +107,7 @@ class AnnounceTopicState(AnnounceTopic): return value_raw = self.capability.converters.state(value) - await self.capability.control.device.client.publish(self.topic, value_raw) + await self.capability.control.device.client.publish(self.topic, value_raw, retain=True) logger.info(f'{get_prefix(self.IO)}: {self.topic} {Constants.ARROW_RIGHT} {value_raw}') diff --git a/haco/version b/haco/version index a1e1395..84aa3a7 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.1.7 \ No newline at end of file +0.1.8 \ No newline at end of file From 2dd44145c7b8e416e93aee3e49ba1801ee6f76cf Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 16 Jan 2026 11:22:58 +0000 Subject: [PATCH 10/72] Disable Actions trigger --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fc26a17..9f2da3b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,10 +1,10 @@ name: Version and Deploy -on: - push: - paths: - - 'haco/version' - workflow_dispatch: +#on: +# push: +# paths: +# - 'haco/version' +# workflow_dispatch: jobs: From 58a32ad116fb0bbcd3dd6f2104bdd01f2558e2de Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 16 Jan 2026 11:27:05 +0000 Subject: [PATCH 11/72] Add project module --- haco/project.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 haco/project.py diff --git a/haco/project.py b/haco/project.py new file mode 100644 index 0000000..f7aef59 --- /dev/null +++ b/haco/project.py @@ -0,0 +1,22 @@ +from fmtr.tools import infra +from haco.paths import paths + + +class Project(infra.Project): + """""" + + def __init__(self, entrypoint='launch', hostname='ws.lan', channel='dev', extras=None): + super().__init__( + + # project + base='python', + name=paths.name, + port=6, + + is_pypi=True, # public release + + entrypoint=entrypoint, + hostname=hostname, + channel=channel, + extras=extras + ) From 7b2801c7cab50569401a1bf7786be115a4d502cc Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 16 Jan 2026 11:27:21 +0000 Subject: [PATCH 12/72] Release version 0.1.9 --- haco/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haco/version b/haco/version index 84aa3a7..82551ad 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.1.8 \ No newline at end of file +0.1.9 \ No newline at end of file From a1fde8df18ac7fe58c93f92c0319cc049757f94e Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 15 Feb 2026 11:23:54 +0000 Subject: [PATCH 13/72] Replace tools with corio --- .github/workflows/main.yml | 67 -------------------------------------- build.env | 9 ----- haco/capabilities.py | 2 +- haco/client.py | 2 +- haco/constants.py | 2 +- haco/control.py | 4 +-- haco/meta.json | 5 +++ haco/obs.py | 6 ++-- haco/paths.py | 2 +- haco/project.py | 22 ------------- haco/topics.py | 2 +- haco/utils.py | 4 +-- haco/version | 1 - haco/version.py | 3 -- pyproject.toml | 2 +- setup.py | 2 +- 16 files changed, 19 insertions(+), 116 deletions(-) delete mode 100644 .github/workflows/main.yml delete mode 100644 build.env create mode 100644 haco/meta.json delete mode 100644 haco/project.py delete mode 100644 haco/version delete mode 100644 haco/version.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 9f2da3b..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Version and Deploy - -#on: -# push: -# paths: -# - 'haco/version' -# workflow_dispatch: - - -jobs: - build: - runs-on: ubuntu-latest - - env: - VERSION: ${{ github.event.inputs.version }} - NAME: ${{ github.event.repository.name }} - NAME_SHORT: ${{ github.event.repository.name }} - ORG: ${{ github.repository_owner }} - PATH_VERSION: haco/version - #SHLINK_API_KEY: ${{ secrets.SHLINK_API_KEY }} - #LINK_ID: haco/tapp - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set Version Environment Variable - run: | - VERSION=$(cat ${PATH_VERSION}) - echo "VERSION=$VERSION" >> $GITHUB_ENV - - - name: Install Tools - run: | - pip install twine - pip install -U packaging setuptools twine pip build #https://github.com/pypa/twine/issues/1216 - - - - name: Increment Version - env: - GIT_EMAIL: ${{ secrets.GIT_EMAIL }} - run: | - git config --global user.name 'Frontmatter Actions' - git config --global user.email "$GIT_EMAIL" - VERSION=${{ env.VERSION }} - git tag -a v${VERSION} -m "Release version ${VERSION}" - git checkout --track origin/release - git rebase main - git push --follow-tags - - - name: Release - uses: softprops/action-gh-release@v1 - with: - tag_name: v${{ env.VERSION }} - generate_release_notes: true - #prerelease: true - - - name: Build Wheel - run: | - python -m build - - - name: Push Wheel - env: - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} - TWINE_USERNAME: __token__ - run: | - twine upload dist/* diff --git a/build.env b/build.env deleted file mode 100644 index 40d5026..0000000 --- a/build.env +++ /dev/null @@ -1,9 +0,0 @@ -CHANNEL="dev" -#ORG="fmtr" -PACKAGE="haco" -PORT="06" -BASE="python" -HOST="ws.lan" -COMPUTE="cpu" -EXTRAS="all" -#ENTRYPOINT="fmtr-dns-launch" \ No newline at end of file diff --git a/haco/capabilities.py b/haco/capabilities.py index fa9e1ca..e30e62d 100644 --- a/haco/capabilities.py +++ b/haco/capabilities.py @@ -3,7 +3,7 @@ from __future__ import annotations from dataclasses import dataclass, field from typing import TYPE_CHECKING, Type -from fmtr.tools.iterator_tools import strip_none +from corio.iterator_tools import strip_none from haco.base import Base from haco.topics import AnnounceTopicState, AnnounceTopicCommand from haco.utils import Converters diff --git a/haco/client.py b/haco/client.py index 74ab41b..ab319c1 100644 --- a/haco/client.py +++ b/haco/client.py @@ -1,7 +1,7 @@ import aiomqtt import asyncio -from fmtr.tools import mqtt +from corio import mqtt from haco import constants from haco.constants import SUBSCRIBE from haco.obs import logger diff --git a/haco/constants.py b/haco/constants.py index 3e66065..0e39799 100644 --- a/haco/constants.py +++ b/haco/constants.py @@ -1,6 +1,6 @@ from __future__ import annotations -from fmtr.tools import env, Path, net +from corio import env, Path, net from haco.paths import paths STATUS = 'status' diff --git a/haco/control.py b/haco/control.py index 6a7f27a..c4e9636 100644 --- a/haco/control.py +++ b/haco/control.py @@ -3,8 +3,8 @@ from __future__ import annotations from dataclasses import dataclass, field from typing import TYPE_CHECKING, TypeVar, Generic, Type, ClassVar -from fmtr.tools import Constants -from fmtr.tools.json_tools import to_json +from corio import Constants +from corio.json_tools import to_json from haco.base import Base from haco.capabilities import Capability from haco.constants import PREFIX_MDI, ANNOUNCE diff --git a/haco/meta.json b/haco/meta.json new file mode 100644 index 0000000..071fbf8 --- /dev/null +++ b/haco/meta.json @@ -0,0 +1,5 @@ +{ + "version": "0.1.9", + "port": 6, + "is_pypi": true +} \ No newline at end of file diff --git a/haco/obs.py b/haco/obs.py index 105e55c..5bf7afa 100644 --- a/haco/obs.py +++ b/haco/obs.py @@ -1,11 +1,11 @@ -from fmtr.tools import logging, debug, Constants +from corio import logging, debug, Constants from haco.paths import paths -from haco.version import __version__ + debug.trace() logger = logging.get_logger( name=paths.name_ns, stream=Constants.INFRA, - version=__version__, + version=paths.metadata.version, ) diff --git a/haco/paths.py b/haco/paths.py index 11c1c70..47ebd8b 100644 --- a/haco/paths.py +++ b/haco/paths.py @@ -1,3 +1,3 @@ -from fmtr.tools import sets +from corio import sets paths = sets.PackagePaths() diff --git a/haco/project.py b/haco/project.py deleted file mode 100644 index f7aef59..0000000 --- a/haco/project.py +++ /dev/null @@ -1,22 +0,0 @@ -from fmtr.tools import infra -from haco.paths import paths - - -class Project(infra.Project): - """""" - - def __init__(self, entrypoint='launch', hostname='ws.lan', channel='dev', extras=None): - super().__init__( - - # project - base='python', - name=paths.name, - port=6, - - is_pypi=True, # public release - - entrypoint=entrypoint, - hostname=hostname, - channel=channel, - extras=extras - ) diff --git a/haco/topics.py b/haco/topics.py index 963f2b0..d67c44f 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -4,7 +4,7 @@ from dataclasses import dataclass, field from functools import cached_property from typing import ClassVar, TYPE_CHECKING, Callable -from fmtr.tools import aio, Constants +from corio import aio, Constants from haco.obs import logger from haco.utils import get_prefix diff --git a/haco/utils.py b/haco/utils.py index 4d12e1e..5de1833 100644 --- a/haco/utils.py +++ b/haco/utils.py @@ -2,8 +2,8 @@ import string from dataclasses import dataclass from typing import Callable -from fmtr.tools import json -from fmtr.tools.datatype_tools import to_bool +from corio import json +from corio.datatype_tools import to_bool CHARS_ALLOWED = string.ascii_lowercase + string.digits SEPS = '_- /' diff --git a/haco/version b/haco/version deleted file mode 100644 index 82551ad..0000000 --- a/haco/version +++ /dev/null @@ -1 +0,0 @@ -0.1.9 \ No newline at end of file diff --git a/haco/version.py b/haco/version.py deleted file mode 100644 index 7fcd766..0000000 --- a/haco/version.py +++ /dev/null @@ -1,3 +0,0 @@ -from fmtr.tools import version - -__version__ = version.read() diff --git a/pyproject.toml b/pyproject.toml index c2d6e8d..b8f655b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["fmtr.tools[setup,debug]"] +requires = ["fmtr.tools[setup,debug]==1.5.0"] build-backend = "setuptools.build_meta" # \ No newline at end of file diff --git a/setup.py b/setup.py index d966648..cea9fba 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup = Setup( org=None, dependencies=dict( install=[ - 'fmtr.tools[version.dev,logging,sets,yaml,debug,caching,api,mqtt]', + 'corio[version.dev,logging,sets,yaml,debug,caching,api,mqtt]==2.0.0a3', ] ), description='Home Assistant Control Objects', From ff7792383cf4fc5f41d3c3b4676db7ea15d953ee Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 15 Feb 2026 11:25:53 +0000 Subject: [PATCH 14/72] Release version 0.2.0-alpha000 --- haco/meta.json | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/haco/meta.json b/haco/meta.json index 071fbf8..4a7293e 100644 --- a/haco/meta.json +++ b/haco/meta.json @@ -1,5 +1,17 @@ { - "version": "0.1.9", - "port": 6, - "is_pypi": true + "version": "0.2.0-alpha000", + "port": 6, + "entrypoint": null, + "base": "python", + "description": null, + "org_singleton": null, + "org_github": "fmtr", + "org_friendly": "Frontmatter AI", + "is_client": false, + "scripts": [], + "services": [], + "docs": {}, + "setup": {}, + "is_pypi": true, + "is_dockerhub": false } \ No newline at end of file From e975b34fb57e34b711212e0e8fb26d1cf3b69b45 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 15 Feb 2026 11:45:45 +0000 Subject: [PATCH 15/72] Use production corio --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index cea9fba..133e83f 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup = Setup( org=None, dependencies=dict( install=[ - 'corio[version.dev,logging,sets,yaml,debug,caching,api,mqtt]==2.0.0a3', + 'corio[version.dev,logging,sets,yaml,debug,caching,api,mqtt]', ] ), description='Home Assistant Control Objects', From 9dda2625504673e202541678db863a5b2c5cd9da Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 15 Feb 2026 11:46:12 +0000 Subject: [PATCH 16/72] Release version 0.2.0 --- haco/meta.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haco/meta.json b/haco/meta.json index 4a7293e..b35929e 100644 --- a/haco/meta.json +++ b/haco/meta.json @@ -1,5 +1,5 @@ { - "version": "0.2.0-alpha000", + "version": "0.2.0", "port": 6, "entrypoint": null, "base": "python", From 8dc96d708d285c759b7d02de13781a32af38f7c7 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 31 Mar 2026 15:07:01 +0100 Subject: [PATCH 17/72] Move build system to corio --- pyproject.toml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b8f655b..96c0041 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["fmtr.tools[setup,debug]==1.5.0"] +requires = ["corio[setup,debug]"] build-backend = "setuptools.build_meta" # \ No newline at end of file diff --git a/setup.py b/setup.py index 133e83f..724e820 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from fmtr.tools import Setup +from corio import Setup setup = Setup( org=None, From f42becceb04b9210e4666dfc8f7893b5c542bb53 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 29 Apr 2026 10:47:13 +0100 Subject: [PATCH 18/72] Add prototype doc --- README.md | 32 +++++++++++--- docs/controls.md | 99 +++++++++++++++++++++++++++++++++++++++++++ docs/index.md | 7 +++ docs/quick-start.md | 48 +++++++++++++++++++++ haco/base.py | 11 +++++ haco/binary_sensor.py | 26 ++++++++++-- haco/button.py | 19 ++++++++- haco/capabilities.py | 37 ++++++++++++++-- haco/client.py | 26 +++++++++++- haco/climate.py | 53 ++++++++++++++++++++--- haco/constants.py | 6 +++ haco/control.py | 70 +++++++++++++++++++++++++++--- haco/device.py | 46 ++++++++++++++++++-- haco/meta.json | 14 +++++- haco/number.py | 19 ++++++++- haco/obs.py | 9 +++- haco/paths.py | 5 +++ haco/select.py | 19 ++++++++- haco/sensor.py | 27 ++++++++++-- haco/switch.py | 18 +++++++- haco/text.py | 19 ++++++++- haco/topics.py | 58 +++++++++++++++++++++++-- haco/uom.py | 2 + haco/utils.py | 38 ++++++++++++++++- 24 files changed, 657 insertions(+), 51 deletions(-) create mode 100644 docs/controls.md create mode 100644 docs/index.md create mode 100644 docs/quick-start.md diff --git a/README.md b/README.md index f3bb28c..408d50d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,30 @@ # `haco` Home Assistant Control Objects -`haco` is a Python/Berry library to greatly simplify the process of -exposing Home -Assistant controls (e.g. Pull-down Lists, Number Sliders, Sensors, etc.) from a device - and handling the -communication between both sides. +`haco` is a to greatly simplify the process of exposing Home Assistant controls (e.g. Pull-down Lists, Number Sliders, Sensors, etc.) from a device - and handling the communication between both sides. -It is in very early release. Documentation is (may) be forthcoming. +While the current implementation is in Python, the capability definitions for controls are designed to be shared across different languages. Support for additional languages (namely native support for Tasmota Berry) is planned. + +### Why MQTT? + +You might wonder why we use MQTT instead of directly using Home Assistant's APIs. The reason is flexibility: using MQTT allows +`haco` to target any device or environment that has an MQTT client, not just those that can easily make HTTP requests or run a full HA integration. This makes it ideal for lightweight embedded systems and cross-platform utility. + +### Why Would I Want Such a Thing? + +Integrating custom hardware or scripts with Home Assistant often involves a lot of boilerplate: defining MQTT topics, crafting JSON payloads for discovery, and managing state updates. +`haco` handles the heavy lifting, letting you define your device and its controls in clean, declarative Python. + +If you're building a custom IoT device, a script to monitor your system, or just want a simpler way to bridge your code to Home Assistant, then you might find +`haco` useful. + +### How it Works + +`haco` uses MQTT to communicate with Home Assistant. It automatically generates the discovery configurations required for Home Assistant to "see" your device and its entities. All you need to do is define a +`Device` with some `Controls` and start the `ClientHaco`. + +## Documentation + +[See Documentation](docs/index.md) + +- [Quick Start](docs/quick-start.md) +- [Control Types](docs/controls.md) diff --git a/docs/controls.md b/docs/controls.md new file mode 100644 index 0000000..07beb5c --- /dev/null +++ b/docs/controls.md @@ -0,0 +1,99 @@ +`haco` provides several control types that correspond to Home Assistant platforms. Each control typically has a +`state` and a `command` method that you can override to handle communication. + +# Supported Controls + +## Button + +A button in Home Assistant that can be pressed to trigger an action in your script. + +- **Platform**: `button` +- **Overridable Methods**: + - `command(self, value)`: Called when the button is pressed in Home Assistant. + +```python +from haco import Button + +class MyButton(Button): + def command(self, value): + print("Button was pressed!") +``` + +## Switch + +A toggle switch that can be turned on or off. + +- **Platform**: `switch` +- **Overridable Methods**: + - `state(self, value)`: Should return the current state of the switch (`True` for on, `False` for off). + - `command(self, value)`: Called when the switch is toggled in Home Assistant. + +```python +from haco import Switch + +class MySwitch(Switch): + def __init__(self, **kwargs): + super().__init__(**kwargs) + self._on = False + + def state(self, value): + return self._on + + def command(self, value): + self._on = value + print(f"Switch is now {'ON' if self._on else 'OFF'}") +``` + +## Sensor + +A read-only sensor that displays a value in Home Assistant. + +- **Platform**: `sensor` +- **Overridable Methods**: + - `state(self, value)`: Should return the current value of the sensor. + +```python +from haco import Sensor + +class MySensor(Sensor): + def state(self, value): + return 42 # Or some dynamic value +``` + +## Number + +A slider or input box for numeric values. + +- **Platform**: `number` +- **Overridable Methods**: + - `state(self, value)`: Should return the current numeric value. + - `command(self, value)`: Called when the value is changed in Home Assistant. + +## Select + +A dropdown list of options. + +- **Platform**: `select` +- **Parameters**: `options` (list of strings) +- **Overridable Methods**: + - `state(self, value)`: Should return the currently selected option. + - `command(self, value)`: Called when a new option is selected in Home Assistant. + +# Customizing Controls + +Most controls accept common parameters in their constructor: + +- `name`: The display name in Home Assistant. +- `icon`: An optional MDI icon (e.g., `mdi:lightbulb` or just `lightbulb`). + +Example: + +```python +btn = Button(name="Panic Button", icon="alert") +``` + +# Advanced: Custom Capabilities + +For more complex platforms like `climate`, +`haco` uses "Capabilities". A capability groups a state and a command topic. You can see how these are implemented in +`haco/climate.py`. diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..2ffdb68 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,7 @@ +!!! tip "How Do I Get Started?" + + See the [Quick Start](quick-start.md) section. + +--8<-- +README.md +--8<-- diff --git a/docs/quick-start.md b/docs/quick-start.md new file mode 100644 index 0000000..28be7b8 --- /dev/null +++ b/docs/quick-start.md @@ -0,0 +1,48 @@ +The easiest way to get started with `haco` is to define a simple device and run the client. + +# Installation + +`haco` can be installed via pip: + +```bash +pip install haco +``` + +!!! tip "MQTT Broker Required" + + `haco` communicates with Home Assistant via MQTT. Ensure you have an MQTT broker (like Mosquitto) running and accessible. + +# Basic Usage + +Here is a minimal example that creates a device with a single button: + +```python +import asyncio +from haco import Button, Device, ClientHaco + +async def main(): + # 1. Define your controls + btn = Button(name="My Awesome Button") + + # 2. Group them into a device + device = Device(name="My Cool Device", controls=[btn]) + + # 3. Create and start the client + # Replace 'mqtt.service' with your MQTT broker's address + client = ClientHaco(hostname='mqtt.service', device=device) + + print("Starting haco client...") + await client.start() + +if __name__ == "__main__": + asyncio.run(main()) +``` + +# What Happens Next? + +1. **Discovery**: When the script runs, it sends discovery messages to Home Assistant. +2. **Entity Created + **: A new device named "My Cool Device" will appear in Home Assistant with a button entity named "My Awesome Button". +3. **Control**: When you press the button in the Home Assistant UI, + `haco` will receive the command. You can then handle this command in your Python script by overriding the + `command` method or providing a callback (see [Control Types](controls.md) for more details). diff --git a/haco/base.py b/haco/base.py index 2828af6..a24c157 100644 --- a/haco/base.py +++ b/haco/base.py @@ -6,9 +6,20 @@ from typing import Any @dataclass(kw_only=True) class Base: + """ + + Base class for haco objects. Provides model dumping functionality. + + """ + DATA = dict() def model_dump(self) -> dict[str, Any]: + """ + + Dump the object to a dictionary, excluding fields marked with `exclude=True` in metadata. + + """ data = {} | self.DATA for fld in fields(self): meta = fld.metadata diff --git a/haco/binary_sensor.py b/haco/binary_sensor.py index 15b5f24..480fa20 100644 --- a/haco/binary_sensor.py +++ b/haco/binary_sensor.py @@ -45,20 +45,40 @@ class DeviceClass(StrEnum): @dataclass(kw_only=True) class BinarySensor(Control): + """ + + A binary sensor for reporting on/off states to Home Assistant. + + """ DATA = dict( platform='binary_sensor' ) device_class: DeviceClass | None = None - def command(self, value): + def command(self, value: bool): + """ + + Binary sensors do not support commands. + + """ raise NotImplementedError() - def state(self, value): + def state(self, value: bool | None) -> bool: + """ + + Return the current state of the binary sensor. + + """ raise NotImplementedError() @classmethod - def get_capabilities(cls): + def get_capabilities(cls) -> list[Capability]: + """ + + Get the capabilities for the binary sensor (state only). + + """ return [ Capability(name=None, command=None) ] diff --git a/haco/button.py b/haco/button.py index 9364177..2329a64 100644 --- a/haco/button.py +++ b/haco/button.py @@ -6,15 +6,30 @@ from haco.control import Control @dataclass(kw_only=True) class Button(Control): + """ + + A button control that can be pressed in Home Assistant. + + """ DATA = dict( platform='button' ) - def command(self, value): + def command(self, value: None): + """ + + Handle button press commands from Home Assistant. + + """ raise NotImplementedError() @classmethod - def get_capabilities(cls): + def get_capabilities(cls) -> list[Capability]: + """ + + Get the capabilities for the button (command only). + + """ return [ Capability(name=None, state=None) ] diff --git a/haco/capabilities.py b/haco/capabilities.py index e30e62d..cf6506c 100644 --- a/haco/capabilities.py +++ b/haco/capabilities.py @@ -4,6 +4,7 @@ from dataclasses import dataclass, field from typing import TYPE_CHECKING, Type from corio.iterator_tools import strip_none + from haco.base import Base from haco.topics import AnnounceTopicState, AnnounceTopicCommand from haco.utils import Converters @@ -14,6 +15,11 @@ if TYPE_CHECKING: @dataclass(kw_only=True) class Capability(Base): + """ + + A capability groups a state and a command topic. + + """ name: str | None = None converters: Type[Converters] | None = field(default=None, metadata=dict(exclude=True)) @@ -25,7 +31,12 @@ class Capability(Base): parent: Control | None = None announce = None - def set_parent(self, control): + def set_parent(self, control: Control): + """ + + Set the parent control for the capability and its topics. + + """ self.parent = control for topic in self.topics: topic.set_parent(self) @@ -33,21 +44,41 @@ class Capability(Base): self.converters = self.converters or self.control.converters def get_announce(self) -> dict: + """ + + Get the discovery announcement data for the capability's topics. + + """ data = {} for topic in self.topics: data |= topic.get_announce() return data def get_subscriptions(self) -> dict: + """ + + Get the MQTT topic subscriptions for the capability's command topics. + + """ data = {} for topic in self.topics: data |= topic.get_subscriptions() return data @property - def topics(self): + def topics(self) -> list: + """ + + The state and command topics for the capability. + + """ return strip_none(self.state, self.command) @property - def control(self): + def control(self) -> Control: + """ + + The parent control of the capability. + + """ return self.parent diff --git a/haco/client.py b/haco/client.py index ab319c1..02d1654 100644 --- a/haco/client.py +++ b/haco/client.py @@ -1,7 +1,9 @@ -import aiomqtt import asyncio +from pathlib import Path +import aiomqtt from corio import mqtt + from haco import constants from haco.constants import SUBSCRIBE from haco.obs import logger @@ -9,6 +11,11 @@ from haco.utils import get_prefix class ClientHaco(mqtt.Client): + """ + + MQTT Client for haco, handling communication between Home Assistant and a device. + + """ ONLINE = 'online' OFFLINE = 'offline' @@ -20,10 +27,20 @@ class ClientHaco(mqtt.Client): super().__init__(*args, will=self.will, identifier=identifier, **kwargs) @property - def topic(self): + def topic(self) -> Path: + """ + + The MQTT topic prefix for the client. + + """ return constants.TOPIC_CLIENT async def handle(self): + """ + + Handle incoming MQTT messages by delegating them to the device's controls. + + """ for topic_sub in self.device.subscriptions.keys(): logger.info(f"{get_prefix(SUBSCRIBE)}: {topic_sub}") @@ -36,6 +53,11 @@ class ClientHaco(mqtt.Client): async def start(self): + """ + + Start the MQTT client and handle reconnection. + + """ while True: try: async with self: diff --git a/haco/climate.py b/haco/climate.py index f18d880..69635da 100644 --- a/haco/climate.py +++ b/haco/climate.py @@ -7,6 +7,11 @@ from haco.control import Control @dataclass(kw_only=True) class Climate(Control): + """ + + A climate control for managing HVAC systems. + + """ DATA = dict( platform='climate' ) @@ -23,27 +28,61 @@ class Climate(Control): fan_modes: list[str] | None = None swing_modes: list[str] | None = None + def temperature_command(self, value: float) -> float: + """ - def temperature_command(self, value): + Handle target temperature commands. + + """ raise NotImplementedError() - def mode_command(self, value): + def mode_command(self, value: str) -> str: + """ + + Handle HVAC mode commands. + + """ raise NotImplementedError() - def fan_mode_command(self, value): + def fan_mode_command(self, value: str) -> str: + """ + + Handle fan mode commands. + + """ raise NotImplementedError() - def fan_mode_state(self, value): + def fan_mode_state(self, value: str | None) -> str: + """ + + Return the current fan mode. + + """ raise NotImplementedError() - def power_command(self, value): + def power_command(self, value: bool) -> bool: + """ + + Handle power toggle commands. + + """ raise NotImplementedError() - def power_state(self, value): + def power_state(self, value: bool | None) -> bool: + """ + + Return the current power state. + + """ raise NotImplementedError() @classmethod - def get_capabilities(cls): + def get_capabilities(cls) -> list[Capability]: + """ + + Get the capabilities for the climate control. + + """ return [ Capability(name="current_temperature", command=None), Capability(name="temperature"), diff --git a/haco/constants.py b/haco/constants.py index 0e39799..989496f 100644 --- a/haco/constants.py +++ b/haco/constants.py @@ -1,6 +1,12 @@ +""" + +Global constants for the haco library. + +""" from __future__ import annotations from corio import env, Path, net + from haco.paths import paths STATUS = 'status' diff --git a/haco/control.py b/haco/control.py index c4e9636..b635c3c 100644 --- a/haco/control.py +++ b/haco/control.py @@ -4,7 +4,9 @@ from dataclasses import dataclass, field from typing import TYPE_CHECKING, TypeVar, Generic, Type, ClassVar from corio import Constants +from corio import Path from corio.json_tools import to_json + from haco.base import Base from haco.capabilities import Capability from haco.constants import PREFIX_MDI, ANNOUNCE @@ -19,6 +21,11 @@ DeviceT = TypeVar("DeviceT", bound="Device") @dataclass(kw_only=True) class Control(Base, Generic[DeviceT]): + """ + + Base class for Home Assistant controls. + + """ converters: ClassVar[Type[Converters]] = ConvertersBool name: str @@ -39,8 +46,12 @@ class Control(Base, Generic[DeviceT]): if not self.icon.startswith(PREFIX_MDI): self.icon = f"{PREFIX_MDI}{self.icon}" + def set_parent(self, device: DeviceT): + """ - def set_parent(self, device): + Set the parent device for the control and its capabilities. + + """ self.device = device for cap in self.capabilities: @@ -51,10 +62,20 @@ class Control(Base, Generic[DeviceT]): self.subscriptions = self.get_subscriptions() @property - def parent(self): + def parent(self) -> DeviceT: + """ + + The parent device of the control. + + """ return self.device - def get_announce(self): + def get_announce(self) -> dict: + """ + + Get the discovery announcement data for the control. + + """ data = self.model_dump() for cap in self.capabilities: data |= cap.get_announce() @@ -62,7 +83,12 @@ class Control(Base, Generic[DeviceT]): return data @classmethod - def get_capabilities(cls): + def get_capabilities(cls) -> list[Capability]: + """ + + Get the capabilities of the control. + + """ return [ Capability(name=None) ] @@ -72,20 +98,45 @@ class Control(Base, Generic[DeviceT]): @property def name_san(self) -> str: + """ + + Sanitized name of the control. + + """ return sanitize_name(self.name) @property - def topic(self): + def topic(self) -> Path: + """ + + The MQTT topic prefix for the control. + + """ return self.device.topic / self.name_san @property - def announce_topic(self): + def announce_topic(self) -> str: + """ + + The MQTT topic for discovery announcement. + + """ return f"homeassistant/{self.DATA['platform']}/{self.unique_id}/config" def get_availability_topic(self) -> str: + """ + + Get the availability topic for the control (uses the client's will topic). + + """ return self.device.client.will.topic def get_subscriptions(self) -> dict: + """ + + Get the MQTT topic subscriptions for the control's capabilities. + + """ data = {} @@ -95,6 +146,11 @@ class Control(Base, Generic[DeviceT]): return data async def initialise(self): + """ + + Initialise the control by announcing it and setting its initial state. + + """ await self.announce() for capability in self.capabilities: if not capability.state: @@ -104,7 +160,7 @@ class Control(Base, Generic[DeviceT]): async def announce(self): """ - Entities must be able to announce themselves to Home Assistant, e.g. when a pulldown changes its options, etc. + Announce the control to Home Assistant via MQTT discovery. """ topic = self.announce_topic diff --git a/haco/device.py b/haco/device.py index e0587ac..e66cffd 100644 --- a/haco/device.py +++ b/haco/device.py @@ -2,6 +2,7 @@ from __future__ import annotations from dataclasses import dataclass, field from functools import cached_property +from pathlib import Path from typing import List, TYPE_CHECKING from haco.base import Base @@ -14,6 +15,11 @@ if TYPE_CHECKING: @dataclass(kw_only=True) class Device(Base): + """ + + A Home Assistant device, containing one or more controls. + + """ name: str manufacturer: str | None = None model: str | None = None @@ -26,8 +32,12 @@ class Device(Base): parent: ClientHaco | None = field(metadata=dict(exclude=True), init=False) subscriptions: dict | None = field(default=None, metadata=dict(exclude=True), init=False) + def set_parent(self, client: ClientHaco): + """ - def set_parent(self, client): + Set the parent client for the device and its controls. + + """ self.parent = client self.identifiers = [self.name_san] @@ -37,27 +47,57 @@ class Device(Base): self.subscriptions = self.get_subscriptions() @cached_property - def topic(self): + def topic(self) -> Path: + """ + + The MQTT topic prefix for the device. + + """ return self.client.topic / self.name_san @property def name_san(self) -> str: + """ + + Sanitized name of the device. + + """ return sanitize_name(self.name) async def announce(self): + """ + + Announce all controls of the device to Home Assistant. + + """ for control in self.controls: await control.announce() async def initialise(self): + """ + + Initialise all controls of the device. + + """ for control in self.controls: await control.initialise() @property - def client(self): + def client(self) -> ClientHaco: + """ + + The parent client of the device. + + """ return self.parent def get_subscriptions(self) -> dict: + """ + + Get all MQTT topic subscriptions for the device's controls. + + """ data = {} for control in self.controls: data |= control.subscriptions diff --git a/haco/meta.json b/haco/meta.json index b35929e..eddd78f 100644 --- a/haco/meta.json +++ b/haco/meta.json @@ -10,7 +10,19 @@ "is_client": false, "scripts": [], "services": [], - "docs": {}, + "docs": { + "nav": [ + { + "Home": "index.md" + }, + { + "Quick Start": "quick-start.md" + }, + { + "Control Types": "controls.md" + } + ] + }, "setup": {}, "is_pypi": true, "is_dockerhub": false diff --git a/haco/number.py b/haco/number.py index e60574a..8604d9b 100644 --- a/haco/number.py +++ b/haco/number.py @@ -14,6 +14,11 @@ class Mode(StrEnum): @dataclass(kw_only=True) class Number(Control): + """ + + A number control (slider or box) for numeric input in Home Assistant. + + """ DATA = dict( platform='number' ) @@ -25,8 +30,18 @@ class Number(Control): step: float = 1. uom: Uom | None = None - def command(self, value): + def command(self, value: float) -> float: + """ + + Handle numeric value commands from Home Assistant. + + """ raise NotImplementedError() - def state(self, value): + def state(self, value: float | None) -> float: + """ + + Return the current numeric state. + + """ raise NotImplementedError() diff --git a/haco/obs.py b/haco/obs.py index 5bf7afa..f8832b6 100644 --- a/haco/obs.py +++ b/haco/obs.py @@ -1,6 +1,11 @@ -from corio import logging, debug, Constants -from haco.paths import paths +""" +Observability and logging setup for the haco library. + +""" +from corio import logging, debug, Constants + +from haco.paths import paths debug.trace() diff --git a/haco/paths.py b/haco/paths.py index 47ebd8b..aa2a0b4 100644 --- a/haco/paths.py +++ b/haco/paths.py @@ -1,3 +1,8 @@ +""" + +Path definitions for the haco library. + +""" from corio import sets paths = sets.PackagePaths() diff --git a/haco/select.py b/haco/select.py index 716bd7c..1a1db28 100644 --- a/haco/select.py +++ b/haco/select.py @@ -6,6 +6,11 @@ from haco.utils import ConvertersString @dataclass(kw_only=True) class Select(Control): + """ + + A select control (dropdown) for choosing from a list of options in Home Assistant. + + """ DATA = dict( platform='select' ) @@ -13,8 +18,18 @@ class Select(Control): options: list[str] - def command(self, value): + def command(self, value: str) -> str: + """ + + Handle option selection commands from Home Assistant. + + """ raise NotImplementedError() - def state(self, value): + def state(self, value: str | None) -> str: + """ + + Return the currently selected option. + + """ raise NotImplementedError() diff --git a/haco/sensor.py b/haco/sensor.py index a430d32..91dc1df 100644 --- a/haco/sensor.py +++ b/haco/sensor.py @@ -1,5 +1,6 @@ from dataclasses import dataclass from enum import StrEnum +from typing import Any from haco.capabilities import Capability from haco.control import Control @@ -68,6 +69,11 @@ class DeviceClass(StrEnum): @dataclass(kw_only=True) class Sensor(Control): + """ + + A sensor control for reporting numeric or string values to Home Assistant. + + """ DATA = dict( platform='sensor' ) @@ -76,14 +82,29 @@ class Sensor(Control): unit_of_measurement: Uom | None = None device_class: DeviceClass | None = None - def command(self, value): + def command(self, value: Any): + """ + + Sensors do not support commands. + + """ raise NotImplementedError() - def state(self, value): + def state(self, value: Any) -> Any: + """ + + Return the current state of the sensor. + + """ raise NotImplementedError() @classmethod - def get_capabilities(cls): + def get_capabilities(cls) -> list[Capability]: + """ + + Get the capabilities for the sensor (state only). + + """ return [ Capability(name=None, command=None) ] diff --git a/haco/switch.py b/haco/switch.py index 6c9ab22..09eb5c4 100644 --- a/haco/switch.py +++ b/haco/switch.py @@ -5,13 +5,27 @@ from haco.control import Control @dataclass(kw_only=True) class Switch(Control): + """ + + A switch control that can be toggled on or off. + + """ DATA = dict( platform='switch' ) + def command(self, value: bool) -> bool: + """ - def command(self, value): + Handle toggle commands from Home Assistant. + + """ raise NotImplementedError() - def state(self, value): + def state(self, value: bool | None) -> bool: + """ + + Return the current state of the switch. + + """ raise NotImplementedError() diff --git a/haco/text.py b/haco/text.py index e9132bb..d511a74 100644 --- a/haco/text.py +++ b/haco/text.py @@ -12,6 +12,11 @@ class Mode(StrEnum): @dataclass(kw_only=True) class Text(Control): + """ + + A text control for text input in Home Assistant. + + """ DATA = dict( platform='text' ) @@ -22,8 +27,18 @@ class Text(Control): max: int | None = None mode: Mode = Mode.TEXT - def command(self, value): + def command(self, value: str) -> str: + """ + + Handle text input commands from Home Assistant. + + """ raise NotImplementedError() - def state(self, value): + def state(self, value: str | None) -> str: + """ + + Return the current text state. + + """ raise NotImplementedError() diff --git a/haco/topics.py b/haco/topics.py index d67c44f..eaed85b 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -5,6 +5,7 @@ from functools import cached_property from typing import ClassVar, TYPE_CHECKING, Callable from corio import aio, Constants + from haco.obs import logger from haco.utils import get_prefix @@ -14,6 +15,11 @@ if TYPE_CHECKING: @dataclass(kw_only=True) class AnnounceTopic: + """ + + Base class for MQTT topics used for discovery and communication. + + """ IO: ClassVar[str | None] = None KEY_DEFAULTS: ClassVar[dict] = {True: '{capability}_{io}_topic', False: '{io}_topic'} @@ -28,6 +34,11 @@ class AnnounceTopic: control_method: Callable | None = field(default=None, metadata=dict(exclude=True)) def set_parent(self, capability: Capability): + """ + + Set the parent capability for the topic and link it to the control's method. + + """ self.parent = capability if self.key is None: self.key = self.KEY_DEFAULTS[bool(self.capability.name)] @@ -56,7 +67,12 @@ class AnnounceTopic: def topic(self): return self.fill(self.value) - def get_announce(self): + def get_announce(self) -> dict: + """ + + Get the discovery announcement data for the topic. + + """ return {self.topic_key: self.topic} @property @@ -70,7 +86,12 @@ class AnnounceTopic: def callback_class_method_name(self): return f'{self.capability.control.__class__.__name__}.{self.callback_name}' - def get_subscriptions(self): + def get_subscriptions(self) -> dict: + """ + + Get the MQTT topic subscriptions for this topic (empty for base class). + + """ return {} @cached_property @@ -83,12 +104,27 @@ class AnnounceTopic: @dataclass(kw_only=True) class AnnounceTopicState(AnnounceTopic): + """ + + MQTT topic for reporting state to Home Assistant. + + """ IO: ClassVar[str] = 'state' - def get_subscriptions(self): + def get_subscriptions(self) -> dict: + """ + + Get the MQTT topic subscriptions for this state topic (empty as it is output only). + + """ return {} async def handle(self, value=None): + """ + + Handle state reporting. Calls the linked control method and publishes the result. + + """ if not self.control_method: logger.error(f'Incomplete base class: {self.callback_class_method_name}') @@ -115,6 +151,11 @@ class AnnounceTopicState(AnnounceTopic): @dataclass(kw_only=True) class AnnounceTopicCommand(AnnounceTopic): + """ + + MQTT topic for receiving commands from Home Assistant. + + """ IO: ClassVar[str] = 'command' @property @@ -122,6 +163,11 @@ class AnnounceTopicCommand(AnnounceTopic): return self.capability.state async def handle(self, message): + """ + + Handle incoming command messages. Decodes, converts, calls the linked control method, and updates state. + + """ value = message.payload.decode('utf-8') value = self.capability.converters.command(value) @@ -149,6 +195,10 @@ class AnnounceTopicCommand(AnnounceTopic): if topic_state: await topic_state.handle(value_raw) + def get_subscriptions(self) -> dict: + """ - def get_subscriptions(self): + Get the MQTT topic subscriptions for this command topic. + + """ return {self.topic: self} diff --git a/haco/uom.py b/haco/uom.py index 3986da8..dc579ac 100644 --- a/haco/uom.py +++ b/haco/uom.py @@ -4,6 +4,8 @@ from enum import StrEnum class Uom(StrEnum): """ + Units of measurement for sensors. + Sourced from: https://github.com/home-assistant/core/blob/03b1c7ad1deb4b9494df01b27ef8e1d7dfe179ba/homeassistant/const.py#L489 """ diff --git a/haco/utils.py b/haco/utils.py index 5de1833..5c99117 100644 --- a/haco/utils.py +++ b/haco/utils.py @@ -18,7 +18,13 @@ BOOL_MAP = {True: ON, False: OFF} from_bool = BOOL_MAP.get -def sanitize_name(s, sep='-'): + +def sanitize_name(s: str, sep: str = '-') -> str: + """ + + Sanitize a string for use in MQTT topics and Home Assistant identifiers. + + """ chars = [] for c in s.lower(): @@ -36,28 +42,58 @@ def sanitize_name(s, sep='-'): class Converters: + """ + + Base class for message converters. + + """ command: Callable = None state: Callable = None class ConvertersBool(Converters): + """ + + Converters for boolean values. + + """ command: Callable = to_bool state: Callable = from_bool class ConvertersString(Converters): + """ + + Converters for string values. + + """ command: Callable = str state: Callable = str class ConvertersNumeric(Converters): + """ + + Converters for numeric values. + + """ command: Callable = json.from_json state: Callable = json.to_json @dataclass class Metadata: + """ + + Metadata for dataclass fields. + + """ exclude: bool = False def get_prefix(io: str) -> str: + """ + + Get a short prefix for IO operations (e.g. 'ST' for state, 'CO' for command). + + """ return io[:2].upper() From c8d6d66641086fb5a4a18c1579b6d8ae7a622ce2 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 29 Apr 2026 10:48:23 +0100 Subject: [PATCH 19/72] Release version 0.2.1 --- haco/meta.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haco/meta.json b/haco/meta.json index eddd78f..93fe239 100644 --- a/haco/meta.json +++ b/haco/meta.json @@ -1,5 +1,5 @@ { - "version": "0.2.0", + "version": "0.2.1", "port": 6, "entrypoint": null, "base": "python", From f1b1cac91a9d11209276576b8ccb694b5742783a Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 May 2026 09:43:46 +0100 Subject: [PATCH 20/72] Migrate Fan control from v0 --- haco/fan.py | 101 ++++++++++++++++++++++++++++++++++++++++++++ haco/v0/haco/fan.py | 57 ------------------------- 2 files changed, 101 insertions(+), 57 deletions(-) create mode 100644 haco/fan.py delete mode 100644 haco/v0/haco/fan.py diff --git a/haco/fan.py b/haco/fan.py new file mode 100644 index 0000000..5c729c2 --- /dev/null +++ b/haco/fan.py @@ -0,0 +1,101 @@ +from dataclasses import dataclass + +from haco.capabilities import Capability +from haco.control import Control +from haco.utils import ON, OFF, ConvertersNumeric, ConvertersString + + +@dataclass(kw_only=True) +class Fan(Control): + """ + + A fan control with support for speed percentage, preset modes, and oscillation. + + """ + DATA = dict( + platform="fan" + ) + + speed_range_min: int | None = None + speed_range_max: int | None = None + preset_modes: list[str] | None = None + payload_oscillation_on: str = ON + payload_oscillation_off: str = OFF + + def command(self, value: bool) -> bool: + """ + + Handle on/off commands for the fan. + + """ + raise NotImplementedError() + + def state(self, value: bool | None) -> bool: + """ + + Return the current on/off state of the fan. + + """ + raise NotImplementedError() + + def preset_mode_command(self, value: str) -> str: + """ + + Handle preset mode commands. + + """ + raise NotImplementedError() + + def preset_mode_state(self, value: str | None) -> str: + """ + + Return the current preset mode. + + """ + raise NotImplementedError() + + def percentage_command(self, value: int) -> int: + """ + + Handle percentage (speed) commands. + + """ + raise NotImplementedError() + + def percentage_state(self, value: int | None) -> int: + """ + + Return the current speed percentage. + + """ + raise NotImplementedError() + + def oscillation_command(self, value: bool) -> bool: + """ + + Handle oscillation toggle commands. + + """ + raise NotImplementedError() + + def oscillation_state(self, value: bool | None) -> bool: + """ + + Return the current oscillation state. + + """ + raise NotImplementedError() + + @classmethod + def get_capabilities(cls) -> list[Capability]: + """ + + Get the capabilities for the fan control. + + """ + return [ + Capability(name=None), + Capability(name="preset_mode", converters=ConvertersString), + Capability(name="percentage", converters=ConvertersNumeric), + Capability(name="oscillation"), + ] diff --git a/haco/v0/haco/fan.py b/haco/v0/haco/fan.py deleted file mode 100644 index c6472d7..0000000 --- a/haco/v0/haco/fan.py +++ /dev/null @@ -1,57 +0,0 @@ -from haco.control import Control -from haco.schema import Schema, Capability, AnnounceTopic, Tasmota, ControlType, HomeAssistant -from haco.tools import get_range_pair, invert_bool - -from haco import constants - - -class Fan(Control): - NAME = 'fan' - - @classmethod - def get_schema(cls): - schema = Schema( - capabilities=[ - Capability( - ha=HomeAssistant(announce_data=AnnounceTopic(key='{io_ha}_topic')), - tasmota=Tasmota(announce_data=AnnounceTopic(key='{io_ha}_topic')) - ), - Capability( - name='preset_mode', - type=str - ), - Capability( - name='percentage', - type=int - ), - Capability( - name='oscillation', - type=ControlType - ) - - ] - ) - return schema - - def __init__(self, name=None, preset_modes=None, icon=None, speed_range=None): - self.temperature_unit = speed_range - self.speed_min, self.speed_max = get_range_pair(speed_range) - self.preset_modes = preset_modes - - super().__init__(name, icon=icon) - - def get_config_ha_ex(self): - data = { - 'speed_range_min': self.speed_min, - 'speed_range_max': self.speed_max, - 'preset_modes': self.preset_modes, - 'payload_oscillation_on': constants.ON, - 'payload_oscillation_off': constants.OFF, - - } - - return data - - @property - def control_type(self): - return invert_bool From 4d65bf6a59e901e0c3e8f138271fed52564c77e6 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 May 2026 12:56:23 +0100 Subject: [PATCH 21/72] Refactor data models: Replace `dataclass` with `pydantic` and simplify imports --- haco/base.py | 51 +++++++++++++++++++++--------------------- haco/binary_sensor.py | 5 ++--- haco/button.py | 5 ++--- haco/capabilities.py | 21 ++++++++++------- haco/climate.py | 6 ++--- haco/control.py | 18 +++++++-------- haco/device.py | 17 +++++++++----- haco/fan.py | 5 ++--- haco/number.py | 4 +--- haco/obs.py | 2 +- haco/sb3.py | 3 +-- haco/select.py | 5 ++--- haco/sensor.py | 6 ++--- haco/switch.py | 5 ++--- haco/tests/__init__.py | 0 haco/text.py | 5 ++--- haco/topics.py | 24 +++++++++++--------- haco/utils.py | 11 --------- pyproject.toml | 10 ++++++++- setup.py | 7 +++++- 20 files changed, 107 insertions(+), 103 deletions(-) create mode 100644 haco/tests/__init__.py diff --git a/haco/base.py b/haco/base.py index a24c157..5a3d662 100644 --- a/haco/base.py +++ b/haco/base.py @@ -1,38 +1,39 @@ from __future__ import annotations -from dataclasses import dataclass, fields -from typing import Any +from typing import Any, ClassVar + +from pydantic import ConfigDict + +from corio import dm -@dataclass(kw_only=True) -class Base: +class Base(dm.Base): """ Base class for haco objects. Provides model dumping functionality. """ + model_config = ConfigDict(arbitrary_types_allowed=True, extra='allow') + DATA: ClassVar[dict[str, Any]] = {} - DATA = dict() - - def model_dump(self) -> dict[str, Any]: + def model_dump(self, *args, **kwargs) -> dict[str, Any]: """ + Dump this model for Home Assistant discovery payloads. - Dump the object to a dictionary, excluding fields marked with `exclude=True` in metadata. - + Behavior differences from vanilla Pydantic: + - Defaults to `exclude_none=True`. + - Merges class-level `DATA` into the dumped mapping. + - Excludes runtime extra attributes (used for dynamic callbacks) so they + do not leak into announce payloads. """ - data = {} | self.DATA - for fld in fields(self): - meta = fld.metadata - if meta.get('exclude', False): - continue - - value = getattr(self, fld.name) - - if hasattr(value, self.model_dump.__name__): - value = value.model_dump() - elif isinstance(value, list): - value = [v.model_dump() if hasattr(v, self.model_dump.__name__) else v for v in value] - - if value is not None: - data[fld.name] = value - return data + kwargs.setdefault("exclude_none", True) + exclude = kwargs.pop("exclude", None) + extra = getattr(self, "__pydantic_extra__", None) or {} + extra_keys = set(extra.keys()) + if exclude is None: + exclude = extra_keys + elif isinstance(exclude, set): + exclude |= extra_keys + else: + exclude = set(exclude) | extra_keys + return self.DATA | super().model_dump(*args, exclude=exclude, **kwargs) diff --git a/haco/binary_sensor.py b/haco/binary_sensor.py index 480fa20..fe3e23c 100644 --- a/haco/binary_sensor.py +++ b/haco/binary_sensor.py @@ -1,5 +1,5 @@ -from dataclasses import dataclass from enum import StrEnum +from typing import ClassVar from haco.capabilities import Capability from haco.control import Control @@ -43,14 +43,13 @@ class DeviceClass(StrEnum): WINDOW = "window" # on means open, off means closed -@dataclass(kw_only=True) class BinarySensor(Control): """ A binary sensor for reporting on/off states to Home Assistant. """ - DATA = dict( + DATA: ClassVar[dict] = dict( platform='binary_sensor' ) diff --git a/haco/button.py b/haco/button.py index 2329a64..113fbf6 100644 --- a/haco/button.py +++ b/haco/button.py @@ -1,17 +1,16 @@ -from dataclasses import dataclass +from typing import ClassVar from haco.capabilities import Capability from haco.control import Control -@dataclass(kw_only=True) class Button(Control): """ A button control that can be pressed in Home Assistant. """ - DATA = dict( + DATA: ClassVar[dict] = dict( platform='button' ) diff --git a/haco/capabilities.py b/haco/capabilities.py index cf6506c..2a09a9f 100644 --- a/haco/capabilities.py +++ b/haco/capabilities.py @@ -1,7 +1,8 @@ from __future__ import annotations -from dataclasses import dataclass, field -from typing import TYPE_CHECKING, Type +from typing import TYPE_CHECKING, Type, ClassVar + +from pydantic import Field from corio.iterator_tools import strip_none @@ -13,7 +14,6 @@ if TYPE_CHECKING: from haco.control import Control -@dataclass(kw_only=True) class Capability(Base): """ @@ -22,14 +22,19 @@ class Capability(Base): """ name: str | None = None - converters: Type[Converters] | None = field(default=None, metadata=dict(exclude=True)) + converters: Type[Converters] | None = Field(default=None, exclude=True, repr=False) - state: AnnounceTopicState | None = field(default_factory=AnnounceTopicState) - command: AnnounceTopicCommand | None = field(default_factory=AnnounceTopicCommand) + state: AnnounceTopicState | None = Field(default_factory=AnnounceTopicState) + command: AnnounceTopicCommand | None = Field(default_factory=AnnounceTopicCommand) - parent: Control | None = None - announce = None + parent: Control | None = Field(default=None, exclude=True, repr=False) + announce: ClassVar[None] = None + + def __init__(self, **kwargs): + from haco.control import Control + Control == Control + super().__init__(**kwargs) def set_parent(self, control: Control): """ diff --git a/haco/climate.py b/haco/climate.py index 69635da..c616fff 100644 --- a/haco/climate.py +++ b/haco/climate.py @@ -1,18 +1,16 @@ -from dataclasses import dataclass -from typing import Literal +from typing import Literal, ClassVar from haco.capabilities import Capability from haco.control import Control -@dataclass(kw_only=True) class Climate(Control): """ A climate control for managing HVAC systems. """ - DATA = dict( + DATA: ClassVar[dict] = dict( platform='climate' ) diff --git a/haco/control.py b/haco/control.py index b635c3c..bce7d3e 100644 --- a/haco/control.py +++ b/haco/control.py @@ -1,8 +1,9 @@ from __future__ import annotations -from dataclasses import dataclass, field from typing import TYPE_CHECKING, TypeVar, Generic, Type, ClassVar +from pydantic import Field + from corio import Constants from corio import Path from corio.json_tools import to_json @@ -16,10 +17,9 @@ from haco.utils import sanitize_name, Converters, ConvertersBool, get_prefix if TYPE_CHECKING: from haco.device import Device -DeviceT = TypeVar("DeviceT", bound="Device") +DeviceT = TypeVar("DeviceT") -@dataclass(kw_only=True) class Control(Base, Generic[DeviceT]): """ @@ -30,14 +30,14 @@ class Control(Base, Generic[DeviceT]): name: str icon: str | None = None - device: DeviceT = field(default=None, init=False) - capabilities: None | list[Capability] = field(default=None, metadata=dict(exclude=True)) - unique_id: str | None = field(default=None, init=False) - availability_topic: str | None = field(default=None, init=False) + device: DeviceT | None = Field(default=None, exclude=True, repr=False) + capabilities: list = Field(default_factory=list, exclude=True, repr=False) + unique_id: str | None = None + availability_topic: str | None = None - subscriptions: dict | None = field(default=None, metadata=dict(exclude=True), init=False) + subscriptions: dict | None = Field(default=None, exclude=True, repr=False) - def __post_init__(self): + def model_post_init(self, __context): self.capabilities = self.get_capabilities() if not self.icon: diff --git a/haco/device.py b/haco/device.py index e66cffd..64f8d6b 100644 --- a/haco/device.py +++ b/haco/device.py @@ -1,10 +1,11 @@ from __future__ import annotations -from dataclasses import dataclass, field from functools import cached_property from pathlib import Path from typing import List, TYPE_CHECKING +from pydantic import Field + from haco.base import Base from haco.control import Control from haco.utils import sanitize_name @@ -13,7 +14,6 @@ if TYPE_CHECKING: from haco.client import ClientHaco -@dataclass(kw_only=True) class Device(Base): """ @@ -25,12 +25,17 @@ class Device(Base): model: str | None = None sw_version: str | None = None - identifiers: list[str] | None = field(default=None, init=False) + identifiers: list[str] | None = None - controls: List[Control] = field(default_factory=list, metadata=dict(exclude=True)) + controls: List[Control] = Field(default_factory=list, exclude=True, repr=False) - parent: ClientHaco | None = field(metadata=dict(exclude=True), init=False) - subscriptions: dict | None = field(default=None, metadata=dict(exclude=True), init=False) + parent: ClientHaco | None = Field(default=None, exclude=True, repr=False) + subscriptions: dict | None = Field(default=None, exclude=True, repr=False) + + def __init__(self, **kwargs): + from haco.client import ClientHaco + ClientHaco == ClientHaco + super().__init__(**kwargs) def set_parent(self, client: ClientHaco): """ diff --git a/haco/fan.py b/haco/fan.py index 5c729c2..b46d4cd 100644 --- a/haco/fan.py +++ b/haco/fan.py @@ -1,18 +1,17 @@ -from dataclasses import dataclass +from typing import ClassVar from haco.capabilities import Capability from haco.control import Control from haco.utils import ON, OFF, ConvertersNumeric, ConvertersString -@dataclass(kw_only=True) class Fan(Control): """ A fan control with support for speed percentage, preset modes, and oscillation. """ - DATA = dict( + DATA: ClassVar[dict] = dict( platform="fan" ) diff --git a/haco/number.py b/haco/number.py index 8604d9b..e7e58d4 100644 --- a/haco/number.py +++ b/haco/number.py @@ -1,4 +1,3 @@ -from dataclasses import dataclass from enum import StrEnum from typing import ClassVar, Type @@ -12,14 +11,13 @@ class Mode(StrEnum): SLIDER = "slider" -@dataclass(kw_only=True) class Number(Control): """ A number control (slider or box) for numeric input in Home Assistant. """ - DATA = dict( + DATA: ClassVar[dict] = dict( platform='number' ) converters: ClassVar[Type[Converters]] = ConvertersNumeric diff --git a/haco/obs.py b/haco/obs.py index f8832b6..74ade85 100644 --- a/haco/obs.py +++ b/haco/obs.py @@ -11,6 +11,6 @@ debug.trace() logger = logging.get_logger( name=paths.name_ns, - stream=Constants.INFRA, + stream=Constants.DEVELOPMENT, version=paths.metadata.version, ) diff --git a/haco/sb3.py b/haco/sb3.py index 3a206c2..3ca3d93 100644 --- a/haco/sb3.py +++ b/haco/sb3.py @@ -4,7 +4,6 @@ import logging from haco.button import Button from haco.client import ClientHaco from haco.climate import Climate -from haco.constants import MQTT_HOST from haco.device import Device from haco.obs import logger from haco.select import Select @@ -23,7 +22,7 @@ async def main(): sel1 = Select(name="Dev Select 1", options=['a', 'b', 'c']) device = Device(name="Dev Device", controls=[climate_a, climate_b, b1, s1, sel1]) - client = ClientHaco(hostname=MQTT_HOST, device=device, logger=logging.getLogger(__name__)) + client = ClientHaco(hostname='mqtt.service', device=device, logger=logging.getLogger(__name__)) await client.start() diff --git a/haco/select.py b/haco/select.py index 1a1db28..e6c8235 100644 --- a/haco/select.py +++ b/haco/select.py @@ -1,17 +1,16 @@ -from dataclasses import dataclass +from typing import ClassVar from haco.control import Control from haco.utils import ConvertersString -@dataclass(kw_only=True) class Select(Control): """ A select control (dropdown) for choosing from a list of options in Home Assistant. """ - DATA = dict( + DATA: ClassVar[dict] = dict( platform='select' ) converters = ConvertersString diff --git a/haco/sensor.py b/haco/sensor.py index 91dc1df..6b5451d 100644 --- a/haco/sensor.py +++ b/haco/sensor.py @@ -1,6 +1,5 @@ -from dataclasses import dataclass from enum import StrEnum -from typing import Any +from typing import Any, ClassVar from haco.capabilities import Capability from haco.control import Control @@ -67,14 +66,13 @@ class DeviceClass(StrEnum): WIND_SPEED = "wind_speed" # Wind speed in ft/s, km/h, kn, m/s, or mph. -@dataclass(kw_only=True) class Sensor(Control): """ A sensor control for reporting numeric or string values to Home Assistant. """ - DATA = dict( + DATA: ClassVar[dict] = dict( platform='sensor' ) converters = ConvertersString diff --git a/haco/switch.py b/haco/switch.py index 09eb5c4..4e15d09 100644 --- a/haco/switch.py +++ b/haco/switch.py @@ -1,16 +1,15 @@ -from dataclasses import dataclass +from typing import ClassVar from haco.control import Control -@dataclass(kw_only=True) class Switch(Control): """ A switch control that can be toggled on or off. """ - DATA = dict( + DATA: ClassVar[dict] = dict( platform='switch' ) diff --git a/haco/tests/__init__.py b/haco/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/haco/text.py b/haco/text.py index d511a74..237fffd 100644 --- a/haco/text.py +++ b/haco/text.py @@ -1,5 +1,5 @@ -from dataclasses import dataclass from enum import StrEnum +from typing import ClassVar from haco.control import Control from haco.utils import ConvertersString @@ -10,14 +10,13 @@ class Mode(StrEnum): PASSWORD = "password" -@dataclass(kw_only=True) class Text(Control): """ A text control for text input in Home Assistant. """ - DATA = dict( + DATA: ClassVar[dict] = dict( platform='text' ) converters = ConvertersString diff --git a/haco/topics.py b/haco/topics.py index eaed85b..72894fb 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -1,20 +1,21 @@ from __future__ import annotations -from dataclasses import dataclass, field from functools import cached_property from typing import ClassVar, TYPE_CHECKING, Callable +from pydantic import Field + from corio import aio, Constants +from haco.base import Base from haco.obs import logger from haco.utils import get_prefix if TYPE_CHECKING: - from capabilities import Capability + from haco.capabilities import Capability -@dataclass(kw_only=True) -class AnnounceTopic: +class AnnounceTopic(Base): """ Base class for MQTT topics used for discovery and communication. @@ -27,11 +28,16 @@ class AnnounceTopic: key: str | None = None value: str = '{path}/{capability}/{io}' - parent: Capability | None = None - announce: dict | None = field(default=None, metadata=dict(exclude=True)) - subscriptions: dict | None = field(default=None, metadata=dict(exclude=True), init=False) + parent: Capability | None = Field(default=None, exclude=True, repr=False) + announce: dict | None = Field(default=None, exclude=True, repr=False) + subscriptions: dict | None = Field(default=None, exclude=True, repr=False) - control_method: Callable | None = field(default=None, metadata=dict(exclude=True)) + control_method: Callable | None = Field(default=None, exclude=True, repr=False) + + def __init__(self, **kwargs): + from haco.capabilities import Capability + Capability == Capability + super().__init__(**kwargs) def set_parent(self, capability: Capability): """ @@ -102,7 +108,6 @@ class AnnounceTopic: raise NotImplementedError() -@dataclass(kw_only=True) class AnnounceTopicState(AnnounceTopic): """ @@ -149,7 +154,6 @@ class AnnounceTopicState(AnnounceTopic): return value_raw -@dataclass(kw_only=True) class AnnounceTopicCommand(AnnounceTopic): """ diff --git a/haco/utils.py b/haco/utils.py index 5c99117..f9bb484 100644 --- a/haco/utils.py +++ b/haco/utils.py @@ -1,5 +1,4 @@ import string -from dataclasses import dataclass from typing import Callable from corio import json @@ -80,16 +79,6 @@ class ConvertersNumeric(Converters): command: Callable = json.from_json state: Callable = json.to_json -@dataclass -class Metadata: - """ - - Metadata for dataclass fields. - - """ - exclude: bool = False - - def get_prefix(io: str) -> str: """ diff --git a/pyproject.toml b/pyproject.toml index 96c0041..78fdce7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,11 @@ [build-system] requires = ["corio[setup,debug]"] -build-backend = "setuptools.build_meta" # \ No newline at end of file +build-backend = "setuptools.build_meta" # + +[project] +name= "haco" +dynamic = ["description", "readme", "version", "dependencies", "optional-dependencies"] + +[tool.uv.sources] +corio = { path = "../corio", editable = true } + diff --git a/setup.py b/setup.py index 724e820..77553f0 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,12 @@ setup = Setup( dependencies=dict( install=[ 'corio[version.dev,logging,sets,yaml,debug,caching,api,mqtt]', - ] + 'psutil' + ], + test=[ + 'pytest>=8.0', + 'pytest-cov>=5.0', + ], ), description='Home Assistant Control Objects', keywords='homeassistant controls python tasmota', From e965ce23c9a093c23ac78d2741c099566552c49f Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 May 2026 13:00:11 +0100 Subject: [PATCH 22/72] Release version 0.3.0-alpha000 --- haco/meta.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haco/meta.json b/haco/meta.json index 93fe239..8993c4c 100644 --- a/haco/meta.json +++ b/haco/meta.json @@ -1,5 +1,5 @@ { - "version": "0.2.1", + "version": "0.3.0-alpha000", "port": 6, "entrypoint": null, "base": "python", From 122639356478df7945ab9907f9f00b69442e4a10 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 May 2026 13:14:23 +0100 Subject: [PATCH 23/72] Update documentation links --- README.md | 5 +---- docs/changelog/changelog.md | 6 ++++++ pyproject.toml | 12 ++++++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 docs/changelog/changelog.md diff --git a/README.md b/README.md index 408d50d..d77f9f3 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,4 @@ If you're building a custom IoT device, a script to monitor your system, or just ## Documentation -[See Documentation](docs/index.md) - -- [Quick Start](docs/quick-start.md) -- [Control Types](docs/controls.md) +[See Documentation](https://fmtr.link/haco/doc) diff --git a/docs/changelog/changelog.md b/docs/changelog/changelog.md new file mode 100644 index 0000000..1502b84 --- /dev/null +++ b/docs/changelog/changelog.md @@ -0,0 +1,6 @@ +- Refactored core models from `dataclass` to Pydantic across active entities (`Base`, `Device`, `Control`, `Capability`, topic models, and concrete control types like `Switch`, `Climate`, `Sensor`, etc.). +- Replaced dataclass-specific field metadata (`metadata=dict(exclude=True)`, `field(...)`, `__post_init__`) with native Pydantic patterns (`Field(...)`, `model_post_init`, class inheritance from `corio.dm.Base`). +- Updated parent/back-reference handling to follow the parent-typing pattern, including explicit in-`__init__` imports for forward references (e.g. `Device.parent: ClientHaco | None`). +- Reworked `Base.model_dump()` to preserve discovery behavior by merging class `DATA`, defaulting to `exclude_none=True`, and excluding runtime extra attributes so dynamic callbacks do not leak into HA announce payloads. +- Cleaned up dataclass leftovers by removing the unused `Metadata` helper from `haco/utils.py` and simplifying related imports. +- Added packaging metadata and testing support updates: `pyproject.toml` project metadata/uv source config, `setup.py` test extras (`pytest`, `pytest-cov`), and initial `haco/tests` package scaffolding. diff --git a/pyproject.toml b/pyproject.toml index 78fdce7..aafd9d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,8 +4,16 @@ build-backend = "setuptools.build_meta" # [project] name= "haco" -dynamic = ["description", "readme", "version", "dependencies", "optional-dependencies"] +dynamic = [ + "description", + "readme", + "version", + "dependencies", + "optional-dependencies", + "license", + "authors", + "keywords", +] [tool.uv.sources] corio = { path = "../corio", editable = true } - From d9bc3b222a9b3801b914cc25a68d18cafd6a65a6 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 May 2026 13:14:52 +0100 Subject: [PATCH 24/72] Release version 0.3.0-alpha001 --- haco/meta.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haco/meta.json b/haco/meta.json index 8993c4c..9fb18e9 100644 --- a/haco/meta.json +++ b/haco/meta.json @@ -1,5 +1,5 @@ { - "version": "0.3.0-alpha000", + "version": "0.3.0-alpha001", "port": 6, "entrypoint": null, "base": "python", From 5e676d8bb7f0756cd68f758905a2553459a0a0ca Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 May 2026 13:15:30 +0100 Subject: [PATCH 25/72] Release version 0.3.0 --- CHANGELOG.md | 1 + docs/changelog/0.3.0.md | 6 ++++++ haco/meta.json | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) create mode 120000 CHANGELOG.md create mode 100644 docs/changelog/0.3.0.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 120000 index 0000000..41c198d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1 @@ +docs/changelog/0.3.0.md \ No newline at end of file diff --git a/docs/changelog/0.3.0.md b/docs/changelog/0.3.0.md new file mode 100644 index 0000000..1502b84 --- /dev/null +++ b/docs/changelog/0.3.0.md @@ -0,0 +1,6 @@ +- Refactored core models from `dataclass` to Pydantic across active entities (`Base`, `Device`, `Control`, `Capability`, topic models, and concrete control types like `Switch`, `Climate`, `Sensor`, etc.). +- Replaced dataclass-specific field metadata (`metadata=dict(exclude=True)`, `field(...)`, `__post_init__`) with native Pydantic patterns (`Field(...)`, `model_post_init`, class inheritance from `corio.dm.Base`). +- Updated parent/back-reference handling to follow the parent-typing pattern, including explicit in-`__init__` imports for forward references (e.g. `Device.parent: ClientHaco | None`). +- Reworked `Base.model_dump()` to preserve discovery behavior by merging class `DATA`, defaulting to `exclude_none=True`, and excluding runtime extra attributes so dynamic callbacks do not leak into HA announce payloads. +- Cleaned up dataclass leftovers by removing the unused `Metadata` helper from `haco/utils.py` and simplifying related imports. +- Added packaging metadata and testing support updates: `pyproject.toml` project metadata/uv source config, `setup.py` test extras (`pytest`, `pytest-cov`), and initial `haco/tests` package scaffolding. diff --git a/haco/meta.json b/haco/meta.json index 9fb18e9..8ab7d3a 100644 --- a/haco/meta.json +++ b/haco/meta.json @@ -1,5 +1,5 @@ { - "version": "0.3.0-alpha001", + "version": "0.3.0", "port": 6, "entrypoint": null, "base": "python", From 430d92346410e2e0c44e9257a7af67838e876b49 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 May 2026 13:18:28 +0100 Subject: [PATCH 26/72] Add changelog to doc structure --- docs/changelog/changelog.md | 6 ------ haco/meta.json | 5 ++++- 2 files changed, 4 insertions(+), 7 deletions(-) delete mode 100644 docs/changelog/changelog.md diff --git a/docs/changelog/changelog.md b/docs/changelog/changelog.md deleted file mode 100644 index 1502b84..0000000 --- a/docs/changelog/changelog.md +++ /dev/null @@ -1,6 +0,0 @@ -- Refactored core models from `dataclass` to Pydantic across active entities (`Base`, `Device`, `Control`, `Capability`, topic models, and concrete control types like `Switch`, `Climate`, `Sensor`, etc.). -- Replaced dataclass-specific field metadata (`metadata=dict(exclude=True)`, `field(...)`, `__post_init__`) with native Pydantic patterns (`Field(...)`, `model_post_init`, class inheritance from `corio.dm.Base`). -- Updated parent/back-reference handling to follow the parent-typing pattern, including explicit in-`__init__` imports for forward references (e.g. `Device.parent: ClientHaco | None`). -- Reworked `Base.model_dump()` to preserve discovery behavior by merging class `DATA`, defaulting to `exclude_none=True`, and excluding runtime extra attributes so dynamic callbacks do not leak into HA announce payloads. -- Cleaned up dataclass leftovers by removing the unused `Metadata` helper from `haco/utils.py` and simplifying related imports. -- Added packaging metadata and testing support updates: `pyproject.toml` project metadata/uv source config, `setup.py` test extras (`pytest`, `pytest-cov`), and initial `haco/tests` package scaffolding. diff --git a/haco/meta.json b/haco/meta.json index 8ab7d3a..aa61388 100644 --- a/haco/meta.json +++ b/haco/meta.json @@ -20,10 +20,13 @@ }, { "Control Types": "controls.md" + }, + { + "Changelog": "changelog/" } ] }, "setup": {}, "is_pypi": true, "is_dockerhub": false -} \ No newline at end of file +} From d8c1eca13a10e51e35d6dad65ef3e6032171cf7c Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 May 2026 13:18:40 +0100 Subject: [PATCH 27/72] Release version 0.3.1 --- haco/meta.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/haco/meta.json b/haco/meta.json index aa61388..a37082d 100644 --- a/haco/meta.json +++ b/haco/meta.json @@ -1,5 +1,5 @@ { - "version": "0.3.0", + "version": "0.3.1", "port": 6, "entrypoint": null, "base": "python", @@ -29,4 +29,4 @@ "setup": {}, "is_pypi": true, "is_dockerhub": false -} +} \ No newline at end of file From c661788d3ea6ede1f2c77757909bd82e717c07d4 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 3 May 2026 07:58:18 +0100 Subject: [PATCH 28/72] Migrate to `pyproject.toml` for project configuration. --- haco/meta.json | 32 ------------------- haco/pyproject.toml | 1 + pyproject.toml | 78 +++++++++++++++++++++++++++++++++++++-------- setup.py | 18 ----------- 4 files changed, 65 insertions(+), 64 deletions(-) delete mode 100644 haco/meta.json create mode 120000 haco/pyproject.toml delete mode 100644 setup.py diff --git a/haco/meta.json b/haco/meta.json deleted file mode 100644 index a37082d..0000000 --- a/haco/meta.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "version": "0.3.1", - "port": 6, - "entrypoint": null, - "base": "python", - "description": null, - "org_singleton": null, - "org_github": "fmtr", - "org_friendly": "Frontmatter AI", - "is_client": false, - "scripts": [], - "services": [], - "docs": { - "nav": [ - { - "Home": "index.md" - }, - { - "Quick Start": "quick-start.md" - }, - { - "Control Types": "controls.md" - }, - { - "Changelog": "changelog/" - } - ] - }, - "setup": {}, - "is_pypi": true, - "is_dockerhub": false -} \ No newline at end of file diff --git a/haco/pyproject.toml b/haco/pyproject.toml new file mode 120000 index 0000000..1e11d78 --- /dev/null +++ b/haco/pyproject.toml @@ -0,0 +1 @@ +../pyproject.toml \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index aafd9d1..31380c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,19 +1,69 @@ [build-system] -requires = ["corio[setup,debug]"] -build-backend = "setuptools.build_meta" # +requires = ["setuptools>=82", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.corio.metadata] +version = "0.3.1" +port = 6 +base = "python" +description = "Home Assistant Control Objects" +org_github = "fmtr" +org_friendly = "Frontmatter AI" +is_client = false +scripts = [] +services = [] +keywords = ["homeassistant", "controls", "python", "tasmota"] +is_pypi = true +is_dockerhub = false + +[[tool.corio.metadata.docs.nav]] +Home = "index.md" + +[[tool.corio.metadata.docs.nav]] +"Quick Start" = "quick-start.md" + +[[tool.corio.metadata.docs.nav]] +"Control Types" = "controls.md" + +[[tool.corio.metadata.docs.nav]] +Changelog = "changelog/" + +[tool.corio.metadata.setup] + +[tool.setuptools.packages.find] +where = ["."] +include = ["haco*"] +namespaces = false + +[tool.setuptools.package-data] +haco = ["pyproject.toml"] + +[tool.uv.sources.corio] +path = "../corio" +editable = true [project] -name= "haco" -dynamic = [ - "description", - "readme", - "version", - "dependencies", - "optional-dependencies", - "license", - "authors", - "keywords", +name = "haco" +version = "0.3.1" +description = "Home Assistant Control Objects" +readme = "README.md" +license = "Apache-2.0" +license-files = ["LICENSE"] +keywords = ["homeassistant", "controls", "python", "tasmota"] +dependencies = [ + "corio[version.dev,logging,sets,yaml,debug,caching,api,mqtt]", + "psutil", ] -[tool.uv.sources] -corio = { path = "../corio", editable = true } +[[project.authors]] +name = "Frontmatter AI" +email = "innovative.fowler@mask.pro.fmtr.dev" + +[project.optional-dependencies] +test = [ + "pytest>=8.0", + "pytest-cov>=5.0", +] + +[project.urls] +Homepage = "https://github.com/fmtr/haco" diff --git a/setup.py b/setup.py deleted file mode 100644 index 77553f0..0000000 --- a/setup.py +++ /dev/null @@ -1,18 +0,0 @@ -from corio import Setup - -setup = Setup( - org=None, - dependencies=dict( - install=[ - 'corio[version.dev,logging,sets,yaml,debug,caching,api,mqtt]', - 'psutil' - ], - test=[ - 'pytest>=8.0', - 'pytest-cov>=5.0', - ], - ), - description='Home Assistant Control Objects', - keywords='homeassistant controls python tasmota', - # url=f'https://fmtr.link/{name}', -) From 5df14eec2f6f871cccfac130f3e9ac91b0885ee3 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 3 May 2026 07:58:50 +0100 Subject: [PATCH 29/72] Release version 0.3.2 --- pyproject.toml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 31380c1..4512fc2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.1" +version = "0.3.2" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -44,26 +44,22 @@ editable = true [project] name = "haco" -version = "0.3.1" +version = "0.3.2" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" license-files = ["LICENSE"] keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = [ - "corio[version.dev,logging,sets,yaml,debug,caching,api,mqtt]", - "psutil", -] +dependencies = ["corio[version.dev,logging,sets,yaml,debug,caching,api,mqtt]", "psutil"] [[project.authors]] name = "Frontmatter AI" email = "innovative.fowler@mask.pro.fmtr.dev" [project.optional-dependencies] -test = [ - "pytest>=8.0", - "pytest-cov>=5.0", -] +test = ["pytest>=8.0", "pytest-cov>=5.0"] [project.urls] Homepage = "https://github.com/fmtr/haco" + +[project.scripts] From 893c50ad87b1d657b378facac15da4c8ffaf6176 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Mon, 4 May 2026 14:07:07 +0100 Subject: [PATCH 30/72] chore: adopt pyproject.package.toml package marker --- haco/{pyproject.toml => pyproject.package.toml} | 0 pyproject.toml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename haco/{pyproject.toml => pyproject.package.toml} (100%) diff --git a/haco/pyproject.toml b/haco/pyproject.package.toml similarity index 100% rename from haco/pyproject.toml rename to haco/pyproject.package.toml diff --git a/pyproject.toml b/pyproject.toml index 4512fc2..65e8441 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ include = ["haco*"] namespaces = false [tool.setuptools.package-data] -haco = ["pyproject.toml"] +haco = ["pyproject.package.toml"] [tool.uv.sources.corio] path = "../corio" From 5e202dfc1bd3f3e69de8f07879b269b7713a03c8 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Mon, 4 May 2026 16:44:05 +0100 Subject: [PATCH 31/72] Release version 0.3.3-alpha000 --- pyproject.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 65e8441..f7fc7c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.2" +version = "0.3.3-alpha000" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -44,11 +44,10 @@ editable = true [project] name = "haco" -version = "0.3.2" +version = "0.3.3-alpha000" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" -license-files = ["LICENSE"] keywords = ["homeassistant", "controls", "python", "tasmota"] dependencies = ["corio[version.dev,logging,sets,yaml,debug,caching,api,mqtt]", "psutil"] From 3b2dd8666994f43cb2dda9cb461ae96ded827c91 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Mon, 4 May 2026 16:45:18 +0100 Subject: [PATCH 32/72] Release version 0.3.3-alpha001 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f7fc7c6..47c1276 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.3-alpha000" +version = "0.3.3-alpha001" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -44,7 +44,7 @@ editable = true [project] name = "haco" -version = "0.3.3-alpha000" +version = "0.3.3-alpha001" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" From 4c39fa60c3f65d95f69327dcb8ccf6bb9536e797 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Mon, 4 May 2026 16:55:10 +0100 Subject: [PATCH 33/72] Release version 0.3.3 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 47c1276..c073b5e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.3-alpha001" +version = "0.3.3" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -44,7 +44,7 @@ editable = true [project] name = "haco" -version = "0.3.3-alpha001" +version = "0.3.3" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" From d6fe7dbfeed6b204c032a2c6e509eff82744b122 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 7 May 2026 13:50:39 +0100 Subject: [PATCH 34/72] Release version 0.3.4-alpha000 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c073b5e..ab67e8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.3" +version = "0.3.4-alpha000" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -44,7 +44,7 @@ editable = true [project] name = "haco" -version = "0.3.3" +version = "0.3.4-alpha000" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" From 76a099433fe31f28922283133513d7b2fd1ff15a Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 7 May 2026 13:54:01 +0100 Subject: [PATCH 35/72] Release version 0.3.4-alpha001 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ab67e8d..4bf6c07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.4-alpha000" +version = "0.3.4-alpha001" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -44,7 +44,7 @@ editable = true [project] name = "haco" -version = "0.3.4-alpha000" +version = "0.3.4-alpha001" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" From f60594fc457400a8b5c09a1a644c6342a1329ca9 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 7 May 2026 14:36:48 +0100 Subject: [PATCH 36/72] Release version 0.3.4-alpha002 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4bf6c07..671236a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.4-alpha001" +version = "0.3.4-alpha002" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -44,7 +44,7 @@ editable = true [project] name = "haco" -version = "0.3.4-alpha001" +version = "0.3.4-alpha002" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" From c9f3385661f3127fa24d308e000df8ba8b7ba233 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 7 May 2026 14:38:23 +0100 Subject: [PATCH 37/72] Release version 0.3.4-alpha003 --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 671236a..ce724c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.4-alpha002" +version = "0.3.4-alpha003" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -44,12 +44,12 @@ editable = true [project] name = "haco" -version = "0.3.4-alpha002" +version = "0.3.4-alpha003" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = ["corio[version.dev,logging,sets,yaml,debug,caching,api,mqtt]", "psutil"] +dependencies = ["corio", "corio[version.dev,logging,sets,yaml,debug,caching,api,mqtt]", "psutil"] [[project.authors]] name = "Frontmatter AI" From cafe6fbcec440245f7f73eb914a8b952ce918739 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 7 May 2026 14:39:17 +0100 Subject: [PATCH 38/72] Release version 0.3.4-alpha004 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ce724c9..33f0f7b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.4-alpha003" +version = "0.3.4-alpha004" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -44,7 +44,7 @@ editable = true [project] name = "haco" -version = "0.3.4-alpha003" +version = "0.3.4-alpha004" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" From 10cd893a90abb8148097909ad3c618219bae9a10 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 7 May 2026 14:40:31 +0100 Subject: [PATCH 39/72] Release version 0.3.4-alpha005 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 33f0f7b..e7a861b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.4-alpha004" +version = "0.3.4-alpha005" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -44,7 +44,7 @@ editable = true [project] name = "haco" -version = "0.3.4-alpha004" +version = "0.3.4-alpha005" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" From 243cb5982d469ca6eb902c8e309705c90a103ca4 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 7 May 2026 14:51:52 +0100 Subject: [PATCH 40/72] Release version 0.3.4-alpha006 --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e7a861b..d8211d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.4-alpha005" +version = "0.3.4-alpha006" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -44,12 +44,12 @@ editable = true [project] name = "haco" -version = "0.3.4-alpha005" +version = "0.3.4-alpha006" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = ["corio", "corio[version.dev,logging,sets,yaml,debug,caching,api,mqtt]", "psutil"] +dependencies = ["corio[version.dev,logging,sets,yaml,debug,caching,api,mqtt]", "psutil"] [[project.authors]] name = "Frontmatter AI" From c82b8f9a0b5176d46957d8443dce197289df7bed Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 7 May 2026 14:54:09 +0100 Subject: [PATCH 41/72] Release version 0.3.4-alpha007 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d8211d7..1f927c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.4-alpha006" +version = "0.3.4-alpha007" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -44,7 +44,7 @@ editable = true [project] name = "haco" -version = "0.3.4-alpha006" +version = "0.3.4-alpha007" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" From bf87c832518b83a8c125ca5342af4f34de871314 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 7 May 2026 15:03:49 +0100 Subject: [PATCH 42/72] Release version 0.3.4-alpha008 --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1f927c0..fb25fed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.4-alpha007" +version = "0.3.4-alpha008" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -44,12 +44,12 @@ editable = true [project] name = "haco" -version = "0.3.4-alpha007" +version = "0.3.4-alpha008" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = ["corio[version.dev,logging,sets,yaml,debug,caching,api,mqtt]", "psutil"] +dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]==2.2.2-alpha002", "psutil"] [[project.authors]] name = "Frontmatter AI" From 107e62081d64fc3ae2991eb0239de925b64e7b5c Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 8 May 2026 09:20:06 +0100 Subject: [PATCH 43/72] Account for corio import changes and add tests for pydantic models --- haco/capabilities.py | 2 +- haco/control.py | 2 +- haco/obs.py | 4 +- haco/tests/test_pydantic_models.py | 84 ++++++++++++++++++++++++++++++ haco/utils.py | 8 +-- 5 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 haco/tests/test_pydantic_models.py diff --git a/haco/capabilities.py b/haco/capabilities.py index 2a09a9f..17b1d83 100644 --- a/haco/capabilities.py +++ b/haco/capabilities.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Type, ClassVar from pydantic import Field -from corio.iterator_tools import strip_none +from corio.iterator import strip_none from haco.base import Base from haco.topics import AnnounceTopicState, AnnounceTopicCommand diff --git a/haco/control.py b/haco/control.py index bce7d3e..009cd02 100644 --- a/haco/control.py +++ b/haco/control.py @@ -6,7 +6,7 @@ from pydantic import Field from corio import Constants from corio import Path -from corio.json_tools import to_json +from corio.jsn import to_json from haco.base import Base from haco.capabilities import Capability diff --git a/haco/obs.py b/haco/obs.py index 74ade85..b0b1d93 100644 --- a/haco/obs.py +++ b/haco/obs.py @@ -3,13 +3,13 @@ Observability and logging setup for the haco library. """ -from corio import logging, debug, Constants +from corio import logs, debug, Constants from haco.paths import paths debug.trace() -logger = logging.get_logger( +logger = logs.get_logger( name=paths.name_ns, stream=Constants.DEVELOPMENT, version=paths.metadata.version, diff --git a/haco/tests/test_pydantic_models.py b/haco/tests/test_pydantic_models.py new file mode 100644 index 0000000..1c33d4e --- /dev/null +++ b/haco/tests/test_pydantic_models.py @@ -0,0 +1,84 @@ +from __future__ import annotations + +from types import SimpleNamespace + +import pytest + +from corio import Path + +from haco.climate import Climate +from haco.device import Device +from haco.switch import Switch + + +@pytest.fixture +def client_stub(): + return SimpleNamespace( + topic=Path("root/client"), + will=SimpleNamespace(topic="root/status"), + ) + + +def test_switch_announce_payload_matches_expected(client_stub): + switch = Switch(name="Main", icon="power") + device = Device(name="Dev", controls=[switch]) + device.set_parent(client_stub) + + data = switch.get_announce() + assert data == { + "platform": "switch", + "name": "Main", + "icon": "mdi:power", + "unique_id": "dev-main", + "availability_topic": "root/status", + "state_topic": "root/client/dev/main/default/state", + "command_topic": "root/client/dev/main/default/command", + } + + +def test_climate_announce_payload_has_expected_ha_keys(client_stub): + climate = Climate(name="Cl") + device = Device(name="Dev", controls=[climate]) + device.set_parent(client_stub) + + data = climate.get_announce() + + expected_subset = { + "platform", + "name", + "unique_id", + "availability_topic", + "temperature_unit", + "temperature_min", + "temperature_max", + "mode_command_topic", + "mode_state_topic", + "temperature_command_topic", + "temperature_state_topic", + "power_command_topic", + "power_state_topic", + } + assert expected_subset.issubset(set(data)) + assert not any(key in data for key in {"capabilities", "subscriptions", "device", "parent"}) + assert not any(callable(value) for value in data.values()) + + +def test_model_dump_excludes_runtime_extra_attributes(): + switch = Switch(name="Main") + switch.dynamic_callback = lambda value: value + + dumped = switch.model_dump() + assert "dynamic_callback" not in dumped + + +def test_parent_wiring_sets_control_subscriptions(client_stub): + switch = Switch(name="Main") + device = Device(name="Dev", controls=[switch]) + device.set_parent(client_stub) + + assert switch.unique_id == "dev-main" + assert switch.availability_topic == "root/status" + assert device.subscriptions is not None + assert "root/client/dev/main/default/command" in device.subscriptions + handler = device.subscriptions["root/client/dev/main/default/command"] + assert hasattr(handler, "handle") diff --git a/haco/utils.py b/haco/utils.py index f9bb484..67dc687 100644 --- a/haco/utils.py +++ b/haco/utils.py @@ -1,8 +1,8 @@ import string from typing import Callable -from corio import json -from corio.datatype_tools import to_bool +from corio import jsn +from corio.datatype import to_bool CHARS_ALLOWED = string.ascii_lowercase + string.digits SEPS = '_- /' @@ -76,8 +76,8 @@ class ConvertersNumeric(Converters): Converters for numeric values. """ - command: Callable = json.from_json - state: Callable = json.to_json + command: Callable = jsn.from_json + state: Callable = jsn.to_json def get_prefix(io: str) -> str: """ From 8bd1ba75d92f116d4b6436b4aaad5d25ebba1d09 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 8 May 2026 09:21:30 +0100 Subject: [PATCH 44/72] Release version 0.3.4-alpha009 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fb25fed..20bafba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.4-alpha008" +version = "0.3.4-alpha009" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -44,7 +44,7 @@ editable = true [project] name = "haco" -version = "0.3.4-alpha008" +version = "0.3.4-alpha009" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" From d5b6cee0a1474ee38f262b00ee97d784b1a1ca4e Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 8 May 2026 09:48:09 +0100 Subject: [PATCH 45/72] Release version 0.3.4 --- CHANGELOG.md | 2 +- docs/changelog/0.3.4.md | 3 +++ pyproject.toml | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 docs/changelog/0.3.4.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 41c198d..0904e18 120000 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1 @@ -docs/changelog/0.3.0.md \ No newline at end of file +docs/changelog/0.3.4.md \ No newline at end of file diff --git a/docs/changelog/0.3.4.md b/docs/changelog/0.3.4.md new file mode 100644 index 0000000..58b84ad --- /dev/null +++ b/docs/changelog/0.3.4.md @@ -0,0 +1,3 @@ +- Updated for `corio` module refactors by switching imports to current paths (`corio.iterator`, `corio.jsn`, `corio.datatype`, and `corio.logs`) across capabilities, control serialization, converters, and logging setup. +- Added `haco/tests/test_pydantic_models.py` coverage to verify Home Assistant announce payload shape for `Switch` and `Climate`, runtime-attribute exclusion from `model_dump()`, and parent/subscription wiring behavior. + diff --git a/pyproject.toml b/pyproject.toml index 20bafba..d9775af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.4-alpha009" +version = "0.3.4" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -44,7 +44,7 @@ editable = true [project] name = "haco" -version = "0.3.4-alpha009" +version = "0.3.4" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" From efd3030406c9842041aa456758d38f4380ec405d Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 8 May 2026 09:49:27 +0100 Subject: [PATCH 46/72] Remove obsolete documentation navigation entries from pyproject.toml --- pyproject.toml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d9775af..61d66b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,18 +16,6 @@ keywords = ["homeassistant", "controls", "python", "tasmota"] is_pypi = true is_dockerhub = false -[[tool.corio.metadata.docs.nav]] -Home = "index.md" - -[[tool.corio.metadata.docs.nav]] -"Quick Start" = "quick-start.md" - -[[tool.corio.metadata.docs.nav]] -"Control Types" = "controls.md" - -[[tool.corio.metadata.docs.nav]] -Changelog = "changelog/" - [tool.corio.metadata.setup] [tool.setuptools.packages.find] From b41b852735d1d0ca76f819497b2754a8d4455b84 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 8 May 2026 09:49:40 +0100 Subject: [PATCH 47/72] Release version 0.3.5 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 61d66b1..ddc8aa1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.4" +version = "0.3.5" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -32,7 +32,7 @@ editable = true [project] name = "haco" -version = "0.3.4" +version = "0.3.5" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" From 4ca01121e1a7a826e0554b145c3869ab00c04a74 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 8 May 2026 10:14:43 +0100 Subject: [PATCH 48/72] Release version 0.3.6 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ddc8aa1..a380071 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.5" +version = "0.3.6" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -32,7 +32,7 @@ editable = true [project] name = "haco" -version = "0.3.5" +version = "0.3.6" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" From e9440745c3b111568b276cd14f2dce71fe6b46de Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 8 May 2026 10:22:18 +0100 Subject: [PATCH 49/72] Release version 0.3.7 --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a380071..b1adaf8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.6" +version = "0.3.7" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -32,12 +32,12 @@ editable = true [project] name = "haco" -version = "0.3.6" +version = "0.3.7" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]==2.2.2-alpha002", "psutil"] +dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]==2.2.2", "psutil"] [[project.authors]] name = "Frontmatter AI" From d9a8561e41ce236b927627873331010f71795cca Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sat, 9 May 2026 16:04:33 +0100 Subject: [PATCH 50/72] Release version 0.3.8-alpha000 --- pyproject.toml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b1adaf8..753a64e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.7" +version = "0.3.8-alpha000" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -30,14 +30,20 @@ haco = ["pyproject.package.toml"] path = "../corio" editable = true +[tool.tox] +requires = ["tox>=4.22", "tox-uv>=1"] +env_list = [] + +[tool.tox.env] + [project] name = "haco" -version = "0.3.7" +version = "0.3.8-alpha000" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]==2.2.2", "psutil"] +dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]~=2.3.0", "psutil"] [[project.authors]] name = "Frontmatter AI" From 09f451348b8a702eb2f635c6b8260df1138e8ac4 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sat, 9 May 2026 16:05:17 +0100 Subject: [PATCH 51/72] Release version 0.3.8 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 753a64e..dc58141 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.8-alpha000" +version = "0.3.8" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -38,7 +38,7 @@ env_list = [] [project] name = "haco" -version = "0.3.8-alpha000" +version = "0.3.8" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" From 26a93e9a89f881f85166d4dbfc6450e8d60063c1 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sat, 9 May 2026 16:43:53 +0100 Subject: [PATCH 52/72] Update test dep --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index dc58141..866151c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ name = "Frontmatter AI" email = "innovative.fowler@mask.pro.fmtr.dev" [project.optional-dependencies] -test = ["pytest>=8.0", "pytest-cov>=5.0"] +test = ["corio[test]"] [project.urls] Homepage = "https://github.com/fmtr/haco" From b4b7c44a64b282ab3a849d229759fc7d84bb651b Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 17 May 2026 13:38:57 +0100 Subject: [PATCH 53/72] Fix device announce data not being including in control announce --- haco/control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haco/control.py b/haco/control.py index 009cd02..114d62e 100644 --- a/haco/control.py +++ b/haco/control.py @@ -30,7 +30,7 @@ class Control(Base, Generic[DeviceT]): name: str icon: str | None = None - device: DeviceT | None = Field(default=None, exclude=True, repr=False) + device: DeviceT | None = Field(default=None, repr=False) capabilities: list = Field(default_factory=list, exclude=True, repr=False) unique_id: str | None = None availability_topic: str | None = None From 57a5f5c3299ba643eb14efc77aa76648a61217ca Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 17 May 2026 13:39:47 +0100 Subject: [PATCH 54/72] Release version 0.3.9 --- pyproject.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 866151c..0702c72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.8" +version = "0.3.9" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -38,19 +38,19 @@ env_list = [] [project] name = "haco" -version = "0.3.8" +version = "0.3.9" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]~=2.3.0", "psutil"] +dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]~=2.3.6", "psutil"] [[project.authors]] name = "Frontmatter AI" email = "innovative.fowler@mask.pro.fmtr.dev" [project.optional-dependencies] -test = ["corio[test]"] +test = ["corio[test]~=2.3.6"] [project.urls] Homepage = "https://github.com/fmtr/haco" From aacb79ab61ed2f672a772970073b6ca778789ed4 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 17 May 2026 13:42:50 +0100 Subject: [PATCH 55/72] Add unit test to ensure device announce data included in control announce --- haco/tests/test_pydantic_models.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/haco/tests/test_pydantic_models.py b/haco/tests/test_pydantic_models.py index 1c33d4e..7893131 100644 --- a/haco/tests/test_pydantic_models.py +++ b/haco/tests/test_pydantic_models.py @@ -31,6 +31,10 @@ def test_switch_announce_payload_matches_expected(client_stub): "icon": "mdi:power", "unique_id": "dev-main", "availability_topic": "root/status", + "device": { + "name": "Dev", + "identifiers": ["dev"], + }, "state_topic": "root/client/dev/main/default/state", "command_topic": "root/client/dev/main/default/command", } @@ -59,10 +63,34 @@ def test_climate_announce_payload_has_expected_ha_keys(client_stub): "power_state_topic", } assert expected_subset.issubset(set(data)) - assert not any(key in data for key in {"capabilities", "subscriptions", "device", "parent"}) + assert not any(key in data for key in {"capabilities", "subscriptions", "parent"}) assert not any(callable(value) for value in data.values()) +def test_control_announce_includes_device_announce_data(client_stub): + switch = Switch(name="Main") + device = Device( + name="Dev", + manufacturer="ACME", + model="Model X", + sw_version="1.2.3", + controls=[switch], + ) + device.set_parent(client_stub) + + data = switch.get_announce() + assert data["device"] == { + "name": "Dev", + "manufacturer": "ACME", + "model": "Model X", + "sw_version": "1.2.3", + "identifiers": ["dev"], + } + assert "controls" not in data["device"] + assert "parent" not in data["device"] + assert "subscriptions" not in data["device"] + + def test_model_dump_excludes_runtime_extra_attributes(): switch = Switch(name="Main") switch.dynamic_callback = lambda value: value From 953d31db553d8a657cb14c728872f6c1f27307bf Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Mon, 18 May 2026 11:57:19 +0100 Subject: [PATCH 56/72] Fix README typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d77f9f3..e7c780a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # `haco` Home Assistant Control Objects -`haco` is a to greatly simplify the process of exposing Home Assistant controls (e.g. Pull-down Lists, Number Sliders, Sensors, etc.) from a device - and handling the communication between both sides. +`haco` greatly simplifies the process of exposing Home Assistant controls (e.g. Pull-down Lists, Number Sliders, Sensors, etc.) from a device - and handling the communication between both sides. While the current implementation is in Python, the capability definitions for controls are designed to be shared across different languages. Support for additional languages (namely native support for Tasmota Berry) is planned. From 1dc5b3711c128b080657fb14791828d17efa678e Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sat, 15 Aug 2026 12:35:10 +0100 Subject: [PATCH 57/72] Release version 0.3.10-alpha000 --- pyproject.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0702c72..560ffab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.9" +version = "0.3.10-alpha000" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -38,19 +38,19 @@ env_list = [] [project] name = "haco" -version = "0.3.9" +version = "0.3.10-alpha000" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]~=2.3.6", "psutil"] +dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]~=2.7.3", "psutil"] [[project.authors]] name = "Frontmatter AI" email = "innovative.fowler@mask.pro.fmtr.dev" [project.optional-dependencies] -test = ["corio[test]~=2.3.6"] +test = ["corio[test]~=2.7.3"] [project.urls] Homepage = "https://github.com/fmtr/haco" From 5fc71ce126e994006b4d680947442deb8c33b591 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sat, 15 Aug 2026 12:37:36 +0100 Subject: [PATCH 58/72] Release version 0.4.0 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 560ffab..5e67c3c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.3.10-alpha000" +version = "0.4.0" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -38,7 +38,7 @@ env_list = [] [project] name = "haco" -version = "0.3.10-alpha000" +version = "0.4.0" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" From 0d6872797a4354c6f16b33b29321dd5bd933bc95 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 16 Aug 2026 16:15:50 +0100 Subject: [PATCH 59/72] Update paths import statement --- haco/paths.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/haco/paths.py b/haco/paths.py index aa2a0b4..25f0abf 100644 --- a/haco/paths.py +++ b/haco/paths.py @@ -3,6 +3,6 @@ Path definitions for the haco library. """ -from corio import sets +from corio import paths -paths = sets.PackagePaths() +paths = paths.PackagePaths() From c3299ab0c1f0aa248db9aea78e2b941569159d6b Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 16 Aug 2026 16:20:38 +0100 Subject: [PATCH 60/72] Release version 0.4.1 --- pyproject.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5e67c3c..21273e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.4.0" +version = "0.4.1" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -24,7 +24,7 @@ include = ["haco*"] namespaces = false [tool.setuptools.package-data] -haco = ["pyproject.package.toml"] +haco = ["pyproject.package.toml", "assets/**"] [tool.uv.sources.corio] path = "../corio" @@ -38,19 +38,19 @@ env_list = [] [project] name = "haco" -version = "0.4.0" +version = "0.4.1" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]~=2.7.3", "psutil"] +dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]~=2.8.0", "psutil"] [[project.authors]] name = "Frontmatter AI" email = "innovative.fowler@mask.pro.fmtr.dev" [project.optional-dependencies] -test = ["corio[test]~=2.7.3"] +test = ["corio[test]~=2.8.0"] [project.urls] Homepage = "https://github.com/fmtr/haco" From 61ea555cf2e24c7c1fd24a923a242c78694978de Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Mon, 17 Aug 2026 18:21:33 +0100 Subject: [PATCH 61/72] Release version 0.4.2 --- pyproject.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 21273e7..6b7e94f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.4.1" +version = "0.4.2" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -38,19 +38,19 @@ env_list = [] [project] name = "haco" -version = "0.4.1" +version = "0.4.2" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]~=2.8.0", "psutil"] +dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]~=2.8.2", "psutil"] [[project.authors]] name = "Frontmatter AI" email = "innovative.fowler@mask.pro.fmtr.dev" [project.optional-dependencies] -test = ["corio[test]~=2.8.0"] +test = ["corio[test]~=2.8.2"] [project.urls] Homepage = "https://github.com/fmtr/haco" From 84402eedcc8889bff3bfc3c89176cb6b30eb2665 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 28 Oct 2026 14:01:03 +0000 Subject: [PATCH 62/72] Release version 0.4.3 --- CHANGELOG.md | 2 +- docs/changelog/0.4.3.md | 1 + pyproject.toml | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 docs/changelog/0.4.3.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 0904e18..79e9d1e 120000 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1 @@ -docs/changelog/0.3.4.md \ No newline at end of file +docs/changelog/0.4.3.md \ No newline at end of file diff --git a/docs/changelog/0.4.3.md b/docs/changelog/0.4.3.md new file mode 100644 index 0000000..0b09f2b --- /dev/null +++ b/docs/changelog/0.4.3.md @@ -0,0 +1 @@ +- Updated the Corio dependency to the current compatible release. diff --git a/pyproject.toml b/pyproject.toml index 6b7e94f..21656a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.4.2" +version = "0.4.3" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -38,19 +38,19 @@ env_list = [] [project] name = "haco" -version = "0.4.2" +version = "0.4.3" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]~=2.8.2", "psutil"] +dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]~=2.15.9", "psutil"] [[project.authors]] name = "Frontmatter AI" email = "innovative.fowler@mask.pro.fmtr.dev" [project.optional-dependencies] -test = ["corio[test]~=2.8.2"] +test = ["corio[test]~=2.15.9"] [project.urls] Homepage = "https://github.com/fmtr/haco" From 8daac7342d33ae04c325e690eec9c0f001a0eb21 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 28 Oct 2026 16:10:32 +0000 Subject: [PATCH 63/72] Fix Corio package path logging --- haco/obs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haco/obs.py b/haco/obs.py index b0b1d93..121b056 100644 --- a/haco/obs.py +++ b/haco/obs.py @@ -10,7 +10,7 @@ from haco.paths import paths debug.trace() logger = logs.get_logger( - name=paths.name_ns, + name=paths.name, stream=Constants.DEVELOPMENT, version=paths.metadata.version, ) From 362081a883161672cecc9e44108b7f6a91b33fbf Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 28 Oct 2026 16:11:35 +0000 Subject: [PATCH 64/72] Add move completion tests --- haco/tests/test_move_complete.py | 155 +++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 haco/tests/test_move_complete.py diff --git a/haco/tests/test_move_complete.py b/haco/tests/test_move_complete.py new file mode 100644 index 0000000..47d2bbe --- /dev/null +++ b/haco/tests/test_move_complete.py @@ -0,0 +1,155 @@ +from __future__ import annotations + +import asyncio +from types import SimpleNamespace +from unittest.mock import AsyncMock + +import pytest + +from corio import Path + +from haco.device import Device +from haco.switch import Switch + + +def run(coro): + return asyncio.run(coro) + + +def message(payload: str) -> SimpleNamespace: + return SimpleNamespace(payload=payload.encode("utf-8")) + + +@pytest.fixture +def client_stub(): + return SimpleNamespace( + topic=Path("root/client"), + will=SimpleNamespace(topic="root/status"), + publish=AsyncMock(), + ) + + +_UNSET = object() + + +def build_switch(client_stub, *, command=_UNSET, state=_UNSET): + switch = Switch(name="Main") + if command is not _UNSET: + switch.command = command + if state is not _UNSET: + switch.state = state + + device = Device(name="Dev", controls=[switch]) + device.set_parent(client_stub) + return switch + + +def test_move_complete_sync_command_updates_state_and_publishes(client_stub): + seen_command = [] + seen_state = [] + + def command(value): + seen_command.append(value) + return value + + def state(value): + seen_state.append(value) + return value + + switch = build_switch(client_stub, command=command, state=state) + command_topic = switch.capabilities[0].command + + run(command_topic.handle(message("ON"))) + + assert seen_command == [True] + assert seen_state == [True] + client_stub.publish.assert_awaited_once_with( + "root/client/dev/main/default/state", + "ON", + retain=True, + ) + + +def test_move_complete_async_command_updates_state_and_publishes(client_stub): + seen_command = [] + seen_state = [] + + async def command(value): + seen_command.append(value) + return not value + + async def state(value): + seen_state.append(value) + return value + + switch = build_switch(client_stub, command=command, state=state) + command_topic = switch.capabilities[0].command + + run(command_topic.handle(message("OFF"))) + + assert seen_command == [False] + assert seen_state == [True] + client_stub.publish.assert_awaited_once_with( + "root/client/dev/main/default/state", + "ON", + retain=True, + ) + + +def test_move_complete_state_handler_sync_publish_path(client_stub): + seen_state = [] + + def state(value): + seen_state.append(value) + return value + + switch = build_switch(client_stub, state=state) + state_topic = switch.capabilities[0].state + + value_raw = run(state_topic.handle(False)) + + assert seen_state == [False] + assert value_raw == "OFF" + client_stub.publish.assert_awaited_once_with( + "root/client/dev/main/default/state", + "OFF", + retain=True, + ) + + +def test_move_complete_command_missing_handler_stops_before_state(client_stub): + seen_state = [] + switch = build_switch( + client_stub, + command=None, + state=lambda value: seen_state.append(value) or value, + ) + command_topic = switch.capabilities[0].command + + result = run(command_topic.handle(message("ON"))) + + assert result is None + assert seen_state == [] + client_stub.publish.assert_not_awaited() + + +def test_move_complete_state_missing_handler_stops(client_stub): + switch = build_switch(client_stub, state=None) + state_topic = switch.capabilities[0].state + + result = run(state_topic.handle(True)) + + assert result is None + client_stub.publish.assert_not_awaited() + + +def test_move_complete_not_implemented_command_stops_before_state(client_stub): + seen_state = [] + switch = build_switch(client_stub, state=lambda value: seen_state.append(value) or value) + command_topic = switch.capabilities[0].command + + result = run(command_topic.handle(message("ON"))) + + assert result is None + assert seen_state == [] + client_stub.publish.assert_not_awaited() From d13fd9a236ab33d8f2a9a002b0410311ae897e5a Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 28 Oct 2026 16:12:44 +0000 Subject: [PATCH 65/72] Release version 0.4.4 --- CHANGELOG.md | 2 +- docs/changelog/0.4.4.md | 2 ++ pyproject.toml | 12 ++++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 docs/changelog/0.4.4.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 79e9d1e..1bd4739 120000 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1 @@ -docs/changelog/0.4.3.md \ No newline at end of file +docs/changelog/0.4.4.md \ No newline at end of file diff --git a/docs/changelog/0.4.4.md b/docs/changelog/0.4.4.md new file mode 100644 index 0000000..be96460 --- /dev/null +++ b/docs/changelog/0.4.4.md @@ -0,0 +1,2 @@ +- Updated Corio integration for the current package paths API. +- Added an automated test environment for the package test suite. diff --git a/pyproject.toml b/pyproject.toml index 21656a9..d8127a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.4.3" +version = "0.4.4" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -18,6 +18,9 @@ is_dockerhub = false [tool.corio.metadata.setup] +[tool.corio.dependencies] +test = ["corio[test]"] + [tool.setuptools.packages.find] where = ["."] include = ["haco*"] @@ -38,19 +41,20 @@ env_list = [] [project] name = "haco" -version = "0.4.3" +version = "0.4.4" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]~=2.15.9", "psutil"] +dependencies = [] [[project.authors]] name = "Frontmatter AI" email = "innovative.fowler@mask.pro.fmtr.dev" [project.optional-dependencies] -test = ["corio[test]~=2.15.9"] +test = ["corio[test]~=2.15.10"] +all = ["corio[test]~=2.15.10"] [project.urls] Homepage = "https://github.com/fmtr/haco" From a8359d46b1021035c81c77dd078554225cb878b0 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 28 Oct 2026 17:40:59 +0000 Subject: [PATCH 66/72] Release version 0.4.5 --- CHANGELOG.md | 2 +- docs/changelog/0.4.5.md | 2 ++ pyproject.toml | 10 +++------- 3 files changed, 6 insertions(+), 8 deletions(-) create mode 100644 docs/changelog/0.4.5.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bd4739..6fa8d06 120000 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1 @@ -docs/changelog/0.4.4.md \ No newline at end of file +docs/changelog/0.4.5.md \ No newline at end of file diff --git a/docs/changelog/0.4.5.md b/docs/changelog/0.4.5.md new file mode 100644 index 0000000..cbe3fb3 --- /dev/null +++ b/docs/changelog/0.4.5.md @@ -0,0 +1,2 @@ +- Restored the runtime dependency metadata for installations. +- Added the automated Haco test environment to release validation. diff --git a/pyproject.toml b/pyproject.toml index d8127a0..1ab8771 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.4.4" +version = "0.4.5" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -18,9 +18,6 @@ is_dockerhub = false [tool.corio.metadata.setup] -[tool.corio.dependencies] -test = ["corio[test]"] - [tool.setuptools.packages.find] where = ["."] include = ["haco*"] @@ -41,12 +38,12 @@ env_list = [] [project] name = "haco" -version = "0.4.4" +version = "0.4.5" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = [] +dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]~=2.15.10", "psutil"] [[project.authors]] name = "Frontmatter AI" @@ -54,7 +51,6 @@ email = "innovative.fowler@mask.pro.fmtr.dev" [project.optional-dependencies] test = ["corio[test]~=2.15.10"] -all = ["corio[test]~=2.15.10"] [project.urls] Homepage = "https://github.com/fmtr/haco" From 06e5d43bca5dfe87c870d0673c539e0204836f61 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 28 Oct 2026 18:19:03 +0000 Subject: [PATCH 67/72] Configure Haco development environment --- pyproject.toml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1ab8771..ef91fb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,9 +32,12 @@ editable = true [tool.tox] requires = ["tox>=4.22", "tox-uv>=1"] -env_list = [] +env_list = ["haco"] -[tool.tox.env] +[tool.tox.env.haco] +description = "Run haco tests." +deps = ["corio[test]~=2.15.10"] +commands = [["python", "-m", "pytest", "-q", "{posargs:haco/tests}"]] [project] name = "haco" @@ -50,9 +53,13 @@ name = "Frontmatter AI" email = "innovative.fowler@mask.pro.fmtr.dev" [project.optional-dependencies] +dev = ["corio[infra]~=2.15.10"] test = ["corio[test]~=2.15.10"] [project.urls] Homepage = "https://github.com/fmtr/haco" [project.scripts] + +[dependency-groups] +dev = ["corio[infra]~=2.15.10"] From 9dd13b4890c959372d0bdc6714307ed50b148f8f Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 13 Nov 2026 13:14:12 +0000 Subject: [PATCH 68/72] Release version 0.4.6-alpha.0 --- pyproject.toml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ef91fb6..507fafc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.4.5" +version = "0.4.6-alpha.0" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -15,6 +15,7 @@ services = [] keywords = ["homeassistant", "controls", "python", "tasmota"] is_pypi = true is_dockerhub = false +editables = ["corio"] [tool.corio.metadata.setup] @@ -30,31 +31,35 @@ haco = ["pyproject.package.toml", "assets/**"] path = "../corio" editable = true +[tool.uv.config-settings-package.corio] +editable_mode = "compat" + [tool.tox] requires = ["tox>=4.22", "tox-uv>=1"] env_list = ["haco"] [tool.tox.env.haco] description = "Run haco tests." -deps = ["corio[test]~=2.15.10"] +deps = ["corio[test]~=2.17.8"] commands = [["python", "-m", "pytest", "-q", "{posargs:haco/tests}"]] +install_command = ["uv", "pip", "install", "--refresh-package", "corio", "{opts}", "{packages}"] [project] name = "haco" -version = "0.4.5" +version = "0.4.6-alpha.0" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]~=2.15.10", "psutil"] +dependencies = ["corio[api,caching,debug,logging,mqtt,sets,yaml]~=2.17.8", "psutil"] [[project.authors]] name = "Frontmatter AI" email = "innovative.fowler@mask.pro.fmtr.dev" [project.optional-dependencies] -dev = ["corio[infra]~=2.15.10"] -test = ["corio[test]~=2.15.10"] +dev = ["corio[infra]~=2.17.8"] +test = ["corio[test]~=2.17.8"] [project.urls] Homepage = "https://github.com/fmtr/haco" @@ -62,4 +67,4 @@ Homepage = "https://github.com/fmtr/haco" [project.scripts] [dependency-groups] -dev = ["corio[infra]~=2.15.10"] +dev = ["corio[infra]~=2.17.8"] From a8c7f4ae6af3b6e8ba1eb0445f97c24b0dfd3048 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 13 Nov 2026 14:02:21 +0000 Subject: [PATCH 69/72] Release version 0.4.6 --- CHANGELOG.md | 2 +- docs/changelog/0.4.6.md | 1 + pyproject.toml | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 docs/changelog/0.4.6.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fa8d06..f23c2e4 120000 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1 @@ -docs/changelog/0.4.5.md \ No newline at end of file +docs/changelog/0.4.6.md \ No newline at end of file diff --git a/docs/changelog/0.4.6.md b/docs/changelog/0.4.6.md new file mode 100644 index 0000000..1885d7a --- /dev/null +++ b/docs/changelog/0.4.6.md @@ -0,0 +1 @@ +- Update the Corio dependency to its latest stable release. diff --git a/pyproject.toml b/pyproject.toml index 507fafc..450ff74 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.4.6-alpha.0" +version = "0.4.6" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -46,7 +46,7 @@ install_command = ["uv", "pip", "install", "--refresh-package", "corio", "{opts} [project] name = "haco" -version = "0.4.6-alpha.0" +version = "0.4.6" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" From 005fa9259d00ceea7cf989a5a784713fb0759877 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 1 Dec 2026 09:29:36 +0000 Subject: [PATCH 70/72] Update Corio logging and test configuration --- haco/obs.py | 8 ++------ haco/sb3.py | 4 +++- pyproject.toml | 32 ++++++++++++++++++++++++-------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/haco/obs.py b/haco/obs.py index 121b056..3dc4036 100644 --- a/haco/obs.py +++ b/haco/obs.py @@ -3,14 +3,10 @@ Observability and logging setup for the haco library. """ -from corio import logs, debug, Constants +from corio import debug, logs from haco.paths import paths debug.trace() -logger = logs.get_logger( - name=paths.name, - stream=Constants.DEVELOPMENT, - version=paths.metadata.version, -) +logger = logs.from_paths(paths) diff --git a/haco/sb3.py b/haco/sb3.py index 3ca3d93..ba65113 100644 --- a/haco/sb3.py +++ b/haco/sb3.py @@ -1,6 +1,8 @@ import asyncio import logging +from logfire import LogfireLoggingHandler + from haco.button import Button from haco.client import ClientHaco from haco.climate import Climate @@ -9,7 +11,7 @@ from haco.obs import logger from haco.select import Select from haco.switch import Switch -handler = logger.LogfireLoggingHandler() +handler = LogfireLoggingHandler(logfire_instance=logger) logging.basicConfig(handlers=[handler], level=logging.DEBUG) async def main(): diff --git a/pyproject.toml b/pyproject.toml index 450ff74..a887912 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,13 +19,19 @@ editables = ["corio"] [tool.corio.metadata.setup] +[tool.corio.test-envs] +dev = ["dev"] + +[tool.setuptools] +include-package-data = false + [tool.setuptools.packages.find] where = ["."] include = ["haco*"] namespaces = false [tool.setuptools.package-data] -haco = ["pyproject.package.toml", "assets/**"] +haco = ["pyproject.package.toml", "**/assets/**"] [tool.uv.sources.corio] path = "../corio" @@ -36,13 +42,23 @@ editable_mode = "compat" [tool.tox] requires = ["tox>=4.22", "tox-uv>=1"] -env_list = ["haco"] +env_list = ["prod"] -[tool.tox.env.haco] +[tool.tox.env.dev] description = "Run haco tests." -deps = ["corio[test]~=2.17.8"] +deps = ["-e ../corio[api,caching,debug,mqtt,sets,test,yaml]", "psutil"] commands = [["python", "-m", "pytest", "-q", "{posargs:haco/tests}"]] install_command = ["uv", "pip", "install", "--refresh-package", "corio", "{opts}", "{packages}"] +skip_install = true + +[tool.tox.env.prod] +description = "Run haco tests." +deps = ["corio[test]~=2.21.5"] +commands = [["python", "-m", "pytest", "-q", "{posargs:haco/tests}"]] +install_command = ["uv", "pip", "install", "--refresh-package", "corio", "{opts}", "{packages}"] + +[tool.pytest.ini_options] +asyncio_default_fixture_loop_scope = "function" [project] name = "haco" @@ -51,15 +67,15 @@ description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = ["corio[api,caching,debug,logging,mqtt,sets,yaml]~=2.17.8", "psutil"] +dependencies = ["corio[api,caching,debug,mqtt,sets,yaml]~=2.21.5", "psutil"] [[project.authors]] name = "Frontmatter AI" email = "innovative.fowler@mask.pro.fmtr.dev" [project.optional-dependencies] -dev = ["corio[infra]~=2.17.8"] -test = ["corio[test]~=2.17.8"] +dev = ["corio[infra]~=2.21.5"] +test = ["corio[test]~=2.21.5"] [project.urls] Homepage = "https://github.com/fmtr/haco" @@ -67,4 +83,4 @@ Homepage = "https://github.com/fmtr/haco" [project.scripts] [dependency-groups] -dev = ["corio[infra]~=2.17.8"] +dev = ["corio[infra]~=2.21.5"] From fbdc97a0f91e90bb34259d27ae6619fa5c44d260 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 1 Dec 2026 09:30:52 +0000 Subject: [PATCH 71/72] Release version 0.4.7-alpha.0 --- pyproject.toml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a887912..db86c31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.4.6" +version = "0.4.7-alpha.0" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -33,6 +33,9 @@ namespaces = false [tool.setuptools.package-data] haco = ["pyproject.package.toml", "**/assets/**"] +[tool.uv] +prerelease = "if-necessary" + [tool.uv.sources.corio] path = "../corio" editable = true @@ -40,6 +43,9 @@ editable = true [tool.uv.config-settings-package.corio] editable_mode = "compat" +[tool.uv.prerelease-package] +corio = "if-necessary" + [tool.tox] requires = ["tox>=4.22", "tox-uv>=1"] env_list = ["prod"] @@ -53,7 +59,7 @@ skip_install = true [tool.tox.env.prod] description = "Run haco tests." -deps = ["corio[test]~=2.21.5"] +deps = ["corio[test]~=2.21.6"] commands = [["python", "-m", "pytest", "-q", "{posargs:haco/tests}"]] install_command = ["uv", "pip", "install", "--refresh-package", "corio", "{opts}", "{packages}"] @@ -62,20 +68,20 @@ asyncio_default_fixture_loop_scope = "function" [project] name = "haco" -version = "0.4.6" +version = "0.4.7-alpha.0" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0" keywords = ["homeassistant", "controls", "python", "tasmota"] -dependencies = ["corio[api,caching,debug,mqtt,sets,yaml]~=2.21.5", "psutil"] +dependencies = ["corio[api,caching,debug,mqtt,sets,yaml]~=2.21.6", "psutil"] [[project.authors]] name = "Frontmatter AI" email = "innovative.fowler@mask.pro.fmtr.dev" [project.optional-dependencies] -dev = ["corio[infra]~=2.21.5"] -test = ["corio[test]~=2.21.5"] +dev = ["corio[infra]~=2.21.6"] +test = ["corio[test]~=2.21.6"] [project.urls] Homepage = "https://github.com/fmtr/haco" @@ -83,4 +89,4 @@ Homepage = "https://github.com/fmtr/haco" [project.scripts] [dependency-groups] -dev = ["corio[infra]~=2.21.5"] +dev = ["corio[infra]~=2.21.6"] From 6aa0a6b41f04d2eeaa679851b9f2fb5f08507c1b Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 1 Dec 2026 09:39:48 +0000 Subject: [PATCH 72/72] Release version 0.4.7 --- CHANGELOG.md | 2 +- docs/changelog/0.4.7.md | 1 + pyproject.toml | 10 ++-------- 3 files changed, 4 insertions(+), 9 deletions(-) create mode 100644 docs/changelog/0.4.7.md diff --git a/CHANGELOG.md b/CHANGELOG.md index f23c2e4..612588c 120000 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1 @@ -docs/changelog/0.4.6.md \ No newline at end of file +docs/changelog/0.4.7.md \ No newline at end of file diff --git a/docs/changelog/0.4.7.md b/docs/changelog/0.4.7.md new file mode 100644 index 0000000..ef5baae --- /dev/null +++ b/docs/changelog/0.4.7.md @@ -0,0 +1 @@ +- Logs now use the package name and version and respect the configured development or production environment. \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index db86c31..8e8059d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"] build-backend = "setuptools.build_meta" [tool.corio.metadata] -version = "0.4.7-alpha.0" +version = "0.4.7" port = 6 base = "python" description = "Home Assistant Control Objects" @@ -33,9 +33,6 @@ namespaces = false [tool.setuptools.package-data] haco = ["pyproject.package.toml", "**/assets/**"] -[tool.uv] -prerelease = "if-necessary" - [tool.uv.sources.corio] path = "../corio" editable = true @@ -43,9 +40,6 @@ editable = true [tool.uv.config-settings-package.corio] editable_mode = "compat" -[tool.uv.prerelease-package] -corio = "if-necessary" - [tool.tox] requires = ["tox>=4.22", "tox-uv>=1"] env_list = ["prod"] @@ -68,7 +62,7 @@ asyncio_default_fixture_loop_scope = "function" [project] name = "haco" -version = "0.4.7-alpha.0" +version = "0.4.7" description = "Home Assistant Control Objects" readme = "README.md" license = "Apache-2.0"