From ed87be7a6e0883a2ab14fde20e0aed42fc78c6c3 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 29 Aug 2023 18:27:17 +0100 Subject: [PATCH 001/183] Implement HA addon config --- README.md | 1 + ha/addon/Dockerfile | 1 + ha/addon/README.md | 1 - ha/addon/config.yaml | 8 ++++---- ha/addon/translations/en.yaml | 2 -- repository.yaml | 3 +++ setup.py | 3 ++- 7 files changed, 11 insertions(+), 8 deletions(-) mode change 100644 => 120000 ha/addon/README.md delete mode 100644 ha/addon/translations/en.yaml create mode 100644 repository.yaml diff --git a/README.md b/README.md index e69de29..535b6c7 100644 --- a/README.md +++ b/README.md @@ -0,0 +1 @@ +# Home Assistant Control Objects \ No newline at end of file diff --git a/ha/addon/Dockerfile b/ha/addon/Dockerfile index 4d743a4..72ed76c 100644 --- a/ha/addon/Dockerfile +++ b/ha/addon/Dockerfile @@ -2,6 +2,7 @@ ARG BUILD_FROM FROM $BUILD_FROM ARG BUILD_VERSION +RUN apk add --no-cache py3-pip RUN pip install haco==${BUILD_VERSION} COPY run.sh / diff --git a/ha/addon/README.md b/ha/addon/README.md deleted file mode 100644 index fe84005..0000000 --- a/ha/addon/README.md +++ /dev/null @@ -1 +0,0 @@ -../../README.md \ No newline at end of file diff --git a/ha/addon/README.md b/ha/addon/README.md new file mode 120000 index 0000000..e69de29 diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index e22a05a..97048b4 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -4,14 +4,14 @@ arch: - armhf - armv7 - i386 -description: Python-based controls for Tasmota devices. +description: Home Assistant Control Objects init: false map: - config:rw name: haco -options: -#panel_icon: mdi:nature-people -schema: +options: { } +panel_icon: mdi:network-pos +schema: { } services: - mqtt:need slug: haco diff --git a/ha/addon/translations/en.yaml b/ha/addon/translations/en.yaml deleted file mode 100644 index d7356f1..0000000 --- a/ha/addon/translations/en.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -configuration: diff --git a/repository.yaml b/repository.yaml new file mode 100644 index 0000000..e267c3b --- /dev/null +++ b/repository.yaml @@ -0,0 +1,3 @@ +name: haco +url: 'https://github.com/fmtr/haco' +maintainer: Frontmatter \ No newline at end of file diff --git a/setup.py b/setup.py index 440ca38..3a8167d 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,8 @@ setup( name: [f'version'], }, install_requires=[ - 'aiomqtt' + 'aiomqtt', + 'pyyaml' ], extras_require={ 'tasmota': [ From 5ddc54b6b865f0dd4b9106a6a5c7b40f305167c8 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 29 Aug 2023 18:31:36 +0100 Subject: [PATCH 002/183] Add readme to addon via symlinks --- ha/addon/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ha/addon/README.md b/ha/addon/README.md index e69de29..fe84005 120000 --- a/ha/addon/README.md +++ b/ha/addon/README.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file From 1c180f7fe6dce6ffccb7bd7165427eaceae22025 Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Tue, 29 Aug 2023 17:34:20 +0000 Subject: [PATCH 003/183] Increment version number to 0.0.3 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index 85fad4a..c43d408 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.2' +var VERSION='0.0.3' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 97048b4..34df686 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -16,4 +16,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.2 +version: 0.0.3 diff --git a/haco/version b/haco/version index 7bcd0e3..6812f81 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.2 \ No newline at end of file +0.0.3 \ No newline at end of file From 465c9ba079cb9bdb970bdd57d30838ad0f13e100 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 29 Aug 2023 21:35:05 +0100 Subject: [PATCH 004/183] Add assignment addon options, improve logging --- ha/addon/config.yaml | 10 ++++++++-- ha/addon/run.sh | 2 ++ haco/tools.py | 12 +++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 34df686..22bd0ba 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -9,9 +9,15 @@ init: false map: - config:rw name: haco -options: { } +options: + assignments: + - config: null + identifier: null panel_icon: mdi:network-pos -schema: { } +schema: + assignments: + - config: str + identifier: str services: - mqtt:need slug: haco diff --git a/ha/addon/run.sh b/ha/addon/run.sh index 5a084cf..7789376 100644 --- a/ha/addon/run.sh +++ b/ha/addon/run.sh @@ -7,4 +7,6 @@ export MQTT_PASSWORD="$(bashio::services mqtt 'password')" export MQTT_PORT="$(bashio::services mqtt 'port')" export MQTT_USERNAME="$(bashio::services mqtt 'username')" +cp /data/options.json /config/haco/options.json + haco-daemon \ No newline at end of file diff --git a/haco/tools.py b/haco/tools.py index 2e18a75..720e3fe 100644 --- a/haco/tools.py +++ b/haco/tools.py @@ -1,8 +1,14 @@ import hashlib +import logging from haco import constants, tuya from haco.tasmota import Tasmota +logging.basicConfig(level=logging.DEBUG) +logger = logging.getLogger(__name__) + + + def split_into_chunks(input_string, chunk_size): return [input_string[i:i + chunk_size] for i in range(0, len(input_string), chunk_size)] @@ -30,20 +36,20 @@ def truncate_middle(input_string, max_length): async def log_publish(client, topic, payload, retain=False): log_retain = '|' if retain else ' ' message = f'mqtt->{log_retain} {topic} {truncate_middle(payload, 100)}' - print(message) + logger.debug(message) await client.publish(topic=topic, payload=payload, retain=retain) async def log_subscribe(client, topic): message = f'mqtt+{topic}' - print(message) + logger.debug(message) await client.subscribe(topic=topic) async def log_received(message): log_retain = '|' if message.retain else ' ' message = f'mqtt<-{log_retain} {message.topic} {truncate_middle(message.payload.decode("utf-8"), 100)}' - print(message) + logger.debug(message) def callback_default(value, data=None): From c17db5305381de0531d895dae556a57683c0f2b9 Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Tue, 29 Aug 2023 20:37:02 +0000 Subject: [PATCH 005/183] Increment version number to 0.0.4 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index c43d408..e087b37 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.3' +var VERSION='0.0.4' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 22bd0ba..f23c093 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.3 +version: 0.0.4 diff --git a/haco/version b/haco/version index 6812f81..05b19b1 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.3 \ No newline at end of file +0.0.4 \ No newline at end of file From 45d05df6f9aa976ce3da9fbb85bed03d64afd056 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 29 Aug 2023 22:15:33 +0100 Subject: [PATCH 006/183] Read in options.json --- berry/haco.be | 2 ++ ha/addon/run.sh | 3 +-- haco/load_configs.py | 27 ++++++++++++++++++--------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/berry/haco.be b/berry/haco.be index 2c2b793..e53f1af 100644 --- a/berry/haco.be +++ b/berry/haco.be @@ -4,6 +4,8 @@ var mod = module("haco") var logger=tools.logger.logger +logger.level=4 +logger.log_repl=true var CALLBACK_MAP={} var BRANCH='release' diff --git a/ha/addon/run.sh b/ha/addon/run.sh index 7789376..4419205 100644 --- a/ha/addon/run.sh +++ b/ha/addon/run.sh @@ -2,11 +2,10 @@ export HACO_IS_ADDON=true export HACO_CONFIGS_PATH="/config/haco" +export HACO_OPTIONS_PATH="/data/options.json" export MQTT_HOST="$(bashio::services mqtt 'host')" export MQTT_PASSWORD="$(bashio::services mqtt 'password')" export MQTT_PORT="$(bashio::services mqtt 'port')" export MQTT_USERNAME="$(bashio::services mqtt 'username')" -cp /data/options.json /config/haco/options.json - haco-daemon \ No newline at end of file diff --git a/haco/load_configs.py b/haco/load_configs.py index 90fd275..c727cd6 100644 --- a/haco/load_configs.py +++ b/haco/load_configs.py @@ -1,27 +1,36 @@ from importlib import reload import importlib.util +import json import os -import yaml from pathlib import Path +from haco import tools from haco.control import Control from haco.device import Device CONFIGS_PATH = Path(os.environ['HACO_CONFIGS_PATH']) +OPTIONS_PATH = Path(os.environ['HACO_OPTIONS_PATH']) -def load_yaml_file(file_path): - with open(file_path, 'r') as yaml_file: - data = yaml.safe_load(yaml_file) +def load_json(file_path): + with open(file_path, 'r') as json_file: + data = json.loads(json_file.read()) return data -def load_controls_from_directory(directory_path): - assn = load_yaml_file(directory_path / 'assignments.yaml') +def load_controls_from_directory(): + if not CONFIGS_PATH.exists(): + tools.logger.warning(f'Configs path does not exist. Will be created: {CONFIGS_PATH}') + CONFIGS_PATH.mkdir() + + options = load_json(OPTIONS_PATH) controls = [] - for name, macs in assn.items(): + for data in options['assignments']: + + name = data['config'] + macs = data['identifier'] if type(macs) is not list: macs = [macs] @@ -32,7 +41,7 @@ def load_controls_from_directory(directory_path): args = {'mac': mac} - py_file = directory_path / Path(name).with_suffix('.py') + py_file = CONFIGS_PATH / Path(name).with_suffix('.py') module_name = py_file.stem try: @@ -57,6 +66,6 @@ def load_controls_from_directory(directory_path): def load_devices(): - devices_args = load_controls_from_directory(CONFIGS_PATH) + devices_args = load_controls_from_directory() devices = [Device(**args) for args in devices_args] return devices From caa9920b544540d07969480704be700d73335b0e Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Tue, 29 Aug 2023 21:16:16 +0000 Subject: [PATCH 007/183] Increment version number to 0.0.5 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index e087b37..1db1d4b 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.4' +var VERSION='0.0.5' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index f23c093..1d5e3c8 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.4 +version: 0.0.5 diff --git a/haco/version b/haco/version index 05b19b1..fa3de58 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.4 \ No newline at end of file +0.0.5 \ No newline at end of file From cdbfacad2b84700d66494f2c9f6ded49fce2d350 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 29 Aug 2023 22:25:17 +0100 Subject: [PATCH 008/183] Remove redundant/relative imports --- haco/configs/development.py | 11 ----------- haco/sensor.py | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/haco/configs/development.py b/haco/configs/development.py index 39468c6..f48a507 100644 --- a/haco/configs/development.py +++ b/haco/configs/development.py @@ -1,6 +1,4 @@ from haco.climate import Climate -from haco.debugging import get_memory_sensor -from haco.device import Device from haco.number import Number from haco.pulldown import Pulldown from haco.sensor import Sensor @@ -152,9 +150,6 @@ def tasmota(value: str): text = Text('Dev Text Test Control') password = Password('Dev Password Test Control') -from haco.configs.development import text, password -from haco.tasmota import Tasmota - @text.callback() def ha(value: str) -> Tasmota[str, 'tasmota.cmd("var11 "+str(value))']: @@ -174,9 +169,3 @@ def ha(value: str) -> Tasmota[str, 'tasmota.cmd("var14 "+str(value))']: @password.callback('var14#state') def tasmota(value: str): return value - - -dev_dehum = Device( - mac='8C:4B:14:85:8D:98', - controls=[number, climate, text, password, sensor, pulldown, get_memory_sensor()] -) diff --git a/haco/sensor.py b/haco/sensor.py index 2fd5c33..c2b56ac 100644 --- a/haco/sensor.py +++ b/haco/sensor.py @@ -1,4 +1,4 @@ -import schema +from haco import schema from haco.control import Control From c641ba8d19c57cdd66ce71e597f64eb0064d064f Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Tue, 29 Aug 2023 21:27:32 +0000 Subject: [PATCH 009/183] Increment version number to 0.0.6 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index 1db1d4b..7999777 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.5' +var VERSION='0.0.6' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 1d5e3c8..2072070 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.5 +version: 0.0.6 diff --git a/haco/version b/haco/version index fa3de58..99d85ec 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.5 \ No newline at end of file +0.0.6 \ No newline at end of file From 6fecbec78c06aca07b0f74b4546bca13682c2716 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 29 Aug 2023 22:35:40 +0100 Subject: [PATCH 010/183] Remove redundant/relative imports --- haco/control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haco/control.py b/haco/control.py index c09743d..428e818 100644 --- a/haco/control.py +++ b/haco/control.py @@ -27,7 +27,7 @@ class Control: def __init__(self, name, icon=None): - from device import Device + from haco.device import Device self.name = name From 2a01e052c600830422f67949dfc7c4c072de5a8b Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Tue, 29 Aug 2023 21:36:16 +0000 Subject: [PATCH 011/183] Increment version number to 0.0.7 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index 7999777..206182f 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.6' +var VERSION='0.0.7' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 2072070..c943498 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.6 +version: 0.0.7 diff --git a/haco/version b/haco/version index 99d85ec..5c4511c 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.6 \ No newline at end of file +0.0.7 \ No newline at end of file From b1cd99609a0dde4df4a40d5feba5bd1f144572b7 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 30 Aug 2023 14:25:37 +0100 Subject: [PATCH 012/183] Add addon logo/icon --- ha/addon/icon.png | Bin 0 -> 5807 bytes ha/addon/logo.png | Bin 0 -> 23164 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 ha/addon/icon.png create mode 100644 ha/addon/logo.png diff --git a/ha/addon/icon.png b/ha/addon/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..083550ad2fd0fd3a6d879cc8da0945428c0fc6cd GIT binary patch literal 5807 zcmd^jX*|^L*Z&wycGEYaCe278B(m>gY>BbXQ1&JJ){t#v84_igB9VQ`HfV^D8I+RB zGIp|tvW#6c8QVSI-~aW0em}S$-S>m*b$!lt&b58cd7pEg^VrP9fScny2LJ%zHoU28 z0RS-RGMW?{h%rJ!e%oerOhFa~2*B&U3o8tQ#X}pZ4FJ^PIS-v#88rL7n|Fc$0AZzn z8=@yhk>#$L~^;{#l{-%EIKNf6rKfb`u zJ?)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LKDUd{1;te9F_{5M*n Xb5qhIT!6?ZG6M|tOmtr(oMQhAGfsy) literal 0 HcmV?d00001 diff --git a/ha/addon/logo.png b/ha/addon/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..f1cd97e31dfb133d90a1fac67451b83d1963dde9 GIT binary patch literal 23164 zcmeIacT|(x);=0#TWNwc=>kfVCRM2x2%><1fb~qgI#{J`ralY}pcQXdO14#0&cda>}`OIg|wIUvBL8;HP zo`*mn)c4fy>OvsDsDkgyXHSE_bOlOmgUbnbUFdB{X)pUS_~jS7Tbj2ZkdJYcN0z6+ z@8?|AjocxS%d+I}6OxZJeIXEIx_ftTJ@PhRoj#XlZezJb;(vPi(x>Z}gK_81@$soN zU*!wc9C&{J%HtRVVPoM5zues6nK#NM4cq1>Wmef$xmBXh!^rXv&)ClY63)Zzq&`-0 z`)o3fK%3*=IBM&JJH7KEM>pa01CXQc%C`#B(dF%Z0 z?2~u^*^BQ+~k3#iTS>J*BdN+a>20IB#cIo zc*AP!rMQ)P`~CLJe%wMd8<(+(@h3^hlA_KpS*P#P?Oq9uo8yPYthaF9Sero+lFW^_jr!jK<)Xr3oj$R7O~%mn&>-4YNN2Buj`AIQfv` z-PwBK)|XB$MrmdR(Jbm(nbN%7%I+?RQ>?EAPO8)bpp@p0yr3@}>cKSEaU{9Oa^p4{ zprHWs--c1zu+z)g{*pyfBdQ>lMF#2Ze4JO(iquu;WwKl?B_KrWU2lQW@cnZ%ud0j6 z4sSj7Afd;NMy-m&hs^Rc*+*AT=~**Gti)e4X{>{;qZ3$JBmQ~&_kyRRSnlpthdT=D zcFPCaWAmsvke6 z0GD)p4)RDPn%0k!hdDjS1)s}$i!buTRnbybXvlZL7=aTI_1{3yVEn58YdGEaPqZQe zYLSjn>++>WgZeB!Hd0^Gf%B_ufmzGCjXfKWl2(Yk^}YGj^o&j(J+}SADDCpiXj}l? z0P@V1I})ODswJMu>{L9`7J5{{*&BoV1CQ#uN^oHv$mX)U}?RteQJSH9$CvrLiM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oE+=QwonLaaALZ*lHYBD5uZIN(8p_Gh{A;4kD(jF-i&#Kwc*2Pw1aj zd)W*8t5fyoF8=otEo?tZu^pd@$El9rRVAZj7gB3H1755-85x-!v$vjQ%(42@R{pap z>tN~=qNe{Z?^XQkV7Py4ng4tHrb=RERgE1KvaLqm?)D3$0i)!SM(g|n(uUjVm z<5Lm-YI6oY{BP_3-*t(9v9_@4+n0f?!f$+rhU%X!wP1*RU;az`WB%p%DuwE75%O?i zZ&pf!%EA-!Q7J%#rfw1Vzm!AD!4F#(&40JnRtN+J&asQ3IK>re_;+*Y) zGPD$tL*q>Szk^`^`;h+M4IqEr?SDCf|4$1*&(KVwjSX&`p_SIR0!RqCr>b?g^!BgM F{}1==BS!!L literal 0 HcmV?d00001 From ab4540aff419747bcfcc7b5822f2ff49b0250fa4 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 30 Aug 2023 15:17:25 +0100 Subject: [PATCH 013/183] Implement Button control --- haco/button.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 haco/button.py diff --git a/haco/button.py b/haco/button.py new file mode 100644 index 0000000..0c288a7 --- /dev/null +++ b/haco/button.py @@ -0,0 +1,21 @@ +from haco import schema +from haco.control import Control + + +class Button(Control): + NAME = 'button' + + @classmethod + def get_schema(cls): + return schema.Schema( + capabilities=[ + schema.Capability( + name='state', + ha=schema.HomeAssistant(announce_data=schema.AnnounceTopic(key='{io_ha}_topic')), + tamota=None + ) + ] + ) + + def __init__(self, name, icon=None): + super().__init__(name, icon=icon) From b4bc004ac9eb5ec95950f5899ff40757dc0f3db4 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 30 Aug 2023 16:43:34 +0100 Subject: [PATCH 014/183] Refine imports, logging --- assets/air_fryer_cookbook.png | Bin 0 -> 48521 bytes assets/restart_button.png | Bin 0 -> 24256 bytes berry/haco.be | 2 +- haco/__init__.py | 17 +++++++++++++++++ haco/configs/air_fryer.py | 12 ++---------- haco/configs/demo.py | 8 ++++++++ haco/configs/development.py | 4 ++-- haco/device.py | 6 ++++-- haco/load_configs.py | 2 ++ haco/mqtt.py | 13 +++++++------ haco/pulldown.py | 2 +- 11 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 assets/air_fryer_cookbook.png create mode 100644 assets/restart_button.png create mode 100644 haco/configs/demo.py diff --git a/assets/air_fryer_cookbook.png b/assets/air_fryer_cookbook.png new file mode 100644 index 0000000000000000000000000000000000000000..fb2bfbeefb29dc4d414d0c1441b0a04f29b75cb1 GIT binary patch literal 48521 zcmeFZXEa>l`z|aIkr0xIL_(0JL{CAY6Cy@uhA2ZsbTitF&L|-XK|=KChA|kujTR(C zuVXN3L>(=J(Y<@}`=7Pmbv~SR-u14t{$I`qYwSJysrz~E=f1D&y61zAmMRkiI|B_3 z4U^gnWjz`iS_BQv>E?51fje=C&o;ovDK|Y;B^q4M%_ZRCjE$nEA`MMR6yu=<9dLc# z`Gt`i4b5#y>ffnHFVnnfXzIDtloi3AW-Al)zN}WqZGWbCGv4y@pL=l?oQ=U?UbO{X zl?4y!7pK+#N~uq+r>sr64wnfsgyp_g)X~+s1lGa6xU!USZ}h}BE#-WSmE@?x*r(oP zV)3K0vf8qk(TTmDt*))_zqn|D_Gy&0;!up#f8Jj|&H3*JYalcA^G=uoJ@xalN;>ty zfcJO$P63|^%9j_Zw{K;h14c?ib4mA%6!r5x|Nrme0qhRL1xA&{V@O!}Bk=RpQR}{HPk+-nV8U}YVrNiW zzUJs6FbV>FpvY_ggH_3cU*V#M_sh;-;T2NFL?KbpUS7?lH`=n>U$$3C#2zWKP_hIp z2_*`&gB|mx!zVtn*|#LGR}js%+H|7V8xDH>PmVlL9gdTAUJ{5!9h88ZdYsUoHWvEr ze8ZxhTjPXKm^B50$%2BU{SZINtygw6T3zJNLV>jGJJ5%}UtegWdDa_G8l;Pv5BAAL ztH5|Sb00o>^^L|bMMPSf#4NL+K(dO59{ONIm6|tZS~?%E)UG!iXXzSXUwa*G6G^C( zgQ?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PBccOm95Xo-0$C?GR&FB zgu6f|!6zrPvUdF*ts#$@E}`Y=>B$?v$!t&xZ1rqtYM{%=z+kY7?|vWs-M{Qpjb)$uxzd`2Xt;+0-Gd1`xE!#`rGthkJSIO-+CR} ZyCTy1Jx(64nT7W4mbSr7{PnwG{{<;^i*^72 literal 0 HcmV?d00001 diff --git a/assets/restart_button.png b/assets/restart_button.png new file mode 100644 index 0000000000000000000000000000000000000000..0a447fd95e6f01ba6772af9c3212ba683641621d GIT binary patch literal 24256 zcmeEuRa9JE(`FJ92n2U`cM0yn9fG^N1$PPBxVyX4xHklM2=0*J&@|S#4)6QT%+1`) z#r$i{#lP3;)%(;sz0W>Xb@q9x_ER09tSE(qfRFI*-8&>1Y4Pvx-oco>d-opiGwhq> zdLgy_?d!eEcd2jhYNrT~-VQ!miYkb{dsiR#<;nQd+cEqPX>FHx@5s3S`Ml@Q%JY8r z&Olv8TvW}|0J4FihiU!-cODl>o~fl@p5t6nh?6L>Ea6#dOK(K8Oj4*=$cMr(JG-0a zt!J*cR}rcst0!Y1<0_E~pM$UvVV;ndn1+^Oh3{SBnrRzJ+0k>5k+G5UJpN()^MluI zW_HfTN{-h)%Ctvr01@K{z`t#Tm8dx&;y+zd#DV_^5r;&g|06Q`uM$nME{tTbzJq}+ zSM8g%vFAm5Ybt9qz2sI<*VSaBp+HwmYoGx9DMn=7XAH@$_~@qP&mUo}9OGjV2TT&4 zLm%k3e}2c@!YS=0wJA+Jf{8b%2A$KRl06T&d56MZR8&ZJv#T){aP%$lN&}`POKuwW z$m8p~aaG}LSt0<3)&1!8?gLMLNc5ZIQa4Q>L!@H+c1!lk?SF4l7INhiH~Unn7-WaH zj~1Z{IkP*DO|JTgzcqISgn^sWjjGA!^-A@sCSGSW!l2*&1<0z>+z`PkQ%+jl?4X3C z1{Hs4T}ju}DuYa;s#HFsZ^$|&CN^b8CG+F=_(%|(pg)SMmen_@Wc=oYvxYS@*iBLm z1DggL9z#0zPMv>-E5~x?XBC%r9P$W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L=gWZeS>a1n+wE#4`gb?gsrvOSJL|xRy%gb4jgTCE<@FAX<}lpE95a8!D+T(&?XT3A+cs9gIP@0m0RU9262$o`@u+|AV>L57UT@O znsCNuD1{dhjKkaDKJ&eRkUBnInls1t_@juwFSNmhC3nHf1Qmk=&!nI3RYL5g)ydM{ zz%r#YSRM?C+z^#H$~C8cxKAG*4`)_DS3B*|f+MGBYg7$aS@#+(o(wVX2w!#zQ@gEZ zCAqz&IXQ@*PrDyXy8lJmw7)Zp@?8zu&!fP;$JNUqA!K5V`B}oVycer3r|g&&J;jTt zE*dZZnAYdTecPOWEh?jb?Cf4Z+Dgf^ z38NomnCt$kg<92A`iX{z^N-Rx`|uy+W#7MA#^4`7uMRsrlUQo}3|CO2H9G~=MvGg( z*-GfRH@5!@+#2K%qrGbDRM&6G50l@R0ooar5qwIp0WcCy!&q~(8r!JF<@PR}tYggR z>J6|bB^JmOYLETx23MkLU;fG literal 0 HcmV?d00001 diff --git a/berry/haco.be b/berry/haco.be index e53f1af..8832484 100644 --- a/berry/haco.be +++ b/berry/haco.be @@ -40,7 +40,7 @@ class ConfigDownloader if self.id_downloading && self.id_downloading==id - logger.error(string.format("Got duplicate new config (same as currently being download) ID: %s. Will be ignored.",id)) + logger.error(string.format("Got duplicate new config (same as currently being downloaded) ID: %s. Will be ignored.",id)) return end diff --git a/haco/__init__.py b/haco/__init__.py index e69de29..825ad5f 100644 --- a/haco/__init__.py +++ b/haco/__init__.py @@ -0,0 +1,17 @@ +from haco import tuya +from .button import Button +from .number import Number +from .pulldown import Select +from .sensor import Sensor +from .switch import Switch +from .tasmota import Tasmota + +__all__ = [ + "Button", + "Select", + "Sensor", + "Tasmota", + "Number", + "Switch", + "tuya" +] diff --git a/haco/configs/air_fryer.py b/haco/configs/air_fryer.py index 087d615..4999d4b 100644 --- a/haco/configs/air_fryer.py +++ b/haco/configs/air_fryer.py @@ -1,14 +1,11 @@ import math -from haco import tuya -from haco.pulldown import Pulldown -from haco.sensor import Sensor -from haco.tasmota import Tasmota +from haco import Tasmota, Number, Sensor, Select, Switch, tuya from haco.tools import add_tuya_io OPTIONS = ['Default', 'Fries', 'Shrimp', 'Pizza', 'Chicken', 'Fish', 'Steak', 'Cake', 'Bacon', 'Preheat', 'Custom'] -cookbook = Pulldown('Cookbook', options=OPTIONS, icon='mdi:chef-hat') +cookbook = Select('Cookbook', options=OPTIONS, icon='mdi:chef-hat') @cookbook.callback() @@ -34,11 +31,6 @@ def tasmota(value: int): return value -from haco.switch import Switch - -from haco.number import Number -from haco import tuya - cooking_time = Number( name='Cooking Time', number_range=range(1, 60), diff --git a/haco/configs/demo.py b/haco/configs/demo.py new file mode 100644 index 0000000..23731df --- /dev/null +++ b/haco/configs/demo.py @@ -0,0 +1,8 @@ +from haco import Button, Tasmota + +restart = Button('Restart Tasmota', icon='mdi:restart') + + +@restart.callback() +def ha(value) -> Tasmota[str, 'tasmota.cmd("restart 1")']: + return value diff --git a/haco/configs/development.py b/haco/configs/development.py index f48a507..4fd0197 100644 --- a/haco/configs/development.py +++ b/haco/configs/development.py @@ -1,6 +1,6 @@ from haco.climate import Climate from haco.number import Number -from haco.pulldown import Pulldown +from haco.pulldown import Select from haco.sensor import Sensor from haco.tasmota import Tasmota from haco.text import Text, Password @@ -123,7 +123,7 @@ def temperature_low_tasmota(value: int): return value -pulldown = Pulldown( +pulldown = Select( 'Dev Select Test Control', options=list('ABC') ) diff --git a/haco/device.py b/haco/device.py index 0d2d161..a68ecaf 100644 --- a/haco/device.py +++ b/haco/device.py @@ -9,8 +9,9 @@ from haco.tools import log_publish, split_into_chunks, log_subscribe class Device: - def __init__(self, mac, controls: List[Control], run_config_post=None): + def __init__(self, mac, config_module, controls: List[Control], run_config_post=None): self.name = None + self.config_module = config_module self.topic = None self.hostname = None self.mac = mac @@ -103,7 +104,8 @@ class Device: await log_subscribe(client, str(topic)) async def bind(self, client, data_announce): - print(f'Found match for self: {self}') + msg = f'Found device with matching config {self.config_module.__name__}: Hostname: {data_announce["hostname"]} MAC:{self.mac}' + tools.logger.info(msg) self.name = data_announce['device_name'] self.topic = data_announce['topic'] self.hostname = data_announce['hostname'] diff --git a/haco/load_configs.py b/haco/load_configs.py index c727cd6..f370bdb 100644 --- a/haco/load_configs.py +++ b/haco/load_configs.py @@ -52,6 +52,8 @@ def load_controls_from_directory(): module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) + args['config_module'] = module + for obj_name in dir(module): obj = getattr(module, obj_name) if obj_name == 'DEVICE_CONFIG': diff --git a/haco/mqtt.py b/haco/mqtt.py index ecb2110..4d0cf4f 100644 --- a/haco/mqtt.py +++ b/haco/mqtt.py @@ -1,11 +1,10 @@ import aiomqtt import asyncio import json -import logging import os from pathlib import Path -from haco import constants +from haco import constants, tools from haco.device import Device from haco.load_configs import load_devices from haco.tools import log_received @@ -27,25 +26,27 @@ async def listen(client, devices): if message.topic.matches(TOPIC_ANNOUNCE): if not message.payload: - logging.warning(f'Topic {message.topic.value} got empty payload. It may have been deleted.') + msg = f'Topic {message.topic.value} got empty payload. It may have been deleted.' + tools.logger.info(msg) continue data_announce = json.loads(message.payload) mac = data_announce['wifi']['mac'] if mac not in devices: - print(f'Got announce from device with no config: {data_announce}') + msg = f'Got announce from device with no config: Hostname: {data_announce["hostname"]} MAC:{data_announce["mac"]}. Publishing config data.' + tools.logger.info(msg) continue device: Device = devices[mac] if device.config_id and data_announce['config_id'] == device.config_id: - print(f'Device {device.name} ({device.hostname}:{device.mac}) successfully configured.') + msg = f'Device {device.name} successfully configured. Hostname: {device.hostname} MAC:{device.mac}' + tools.logger.info(msg) continue await device.bind(client, data_announce) devices[device.hostname] = device - device else: _, _, device_name, _, control, capability_id, platform, io = Path(message.topic.value).parts diff --git a/haco/pulldown.py b/haco/pulldown.py index b5276ee..5c51951 100644 --- a/haco/pulldown.py +++ b/haco/pulldown.py @@ -3,7 +3,7 @@ from typing import List from haco.control import Control -class Pulldown(Control): +class Select(Control): NAME = 'select' def __init__(self, name, options: List[str], icon=None): From a48b538cf1a1fbdd863a72743d4a6379a530e979 Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Wed, 30 Aug 2023 15:44:34 +0000 Subject: [PATCH 015/183] Increment version number to 0.0.8 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index 206182f..959b90f 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.7' +var VERSION='0.0.8' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index c943498..0cc0a4e 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.7 +version: 0.0.8 diff --git a/haco/version b/haco/version index 5c4511c..7d6b3eb 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.7 \ No newline at end of file +0.0.8 \ No newline at end of file From ed5685bac88c76a3a015f176695791e2ee8429f8 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 30 Aug 2023 17:57:35 +0100 Subject: [PATCH 016/183] Add logging timestamps --- haco/tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haco/tools.py b/haco/tools.py index 720e3fe..f42987a 100644 --- a/haco/tools.py +++ b/haco/tools.py @@ -4,7 +4,7 @@ import logging from haco import constants, tuya from haco.tasmota import Tasmota -logging.basicConfig(level=logging.DEBUG) +logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(message)s', datefmt='%Y-%m-%d %H:%M:%S') logger = logging.getLogger(__name__) From 328b367bc3b071f5aadade24975d507e6b5afe2c Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 30 Aug 2023 17:58:04 +0100 Subject: [PATCH 017/183] Fix air fryer config duplicate temperature controls --- haco/configs/air_fryer.py | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/haco/configs/air_fryer.py b/haco/configs/air_fryer.py index 4999d4b..c8ca5c4 100644 --- a/haco/configs/air_fryer.py +++ b/haco/configs/air_fryer.py @@ -48,25 +48,6 @@ def tasmota(value: int): def ha(value: int) -> Tasmota[int, tuya.send(2, 7)]: return value - -cooking_temp = Number( - name='Cooking Temperature (F)', - number_range=range(1, 60), - uom='minutes', - icon='mdi:timer' -) - - -@cooking_temp.callback(trigger=tuya.received(2, 7)) -def tasmota(value: int): - return value - - -@cooking_temp.callback() -def ha(value: int) -> Tasmota[int, tuya.send(2, 7)]: - return value - - cooking_temp_f = Number( 'Cooking Temperature (F)', number_range=range(170, 399), From 37ff4f17a45e8b24d8c1330ca671f011dd8e465d Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 30 Aug 2023 20:45:43 +0100 Subject: [PATCH 018/183] Add UOM and Sensor device class data --- haco/binary_sensor.py | 3 + haco/configs/air_fryer.py | 20 ++--- haco/configs/demo.py | 12 ++- haco/control.py | 3 +- haco/data/__init__.py | 0 haco/data/type_binary_sensor.py | 36 +++++++++ haco/data/type_sensor.py | 58 ++++++++++++++ haco/data/uom.py | 138 ++++++++++++++++++++++++++++++++ haco/sensor.py | 6 ++ 9 files changed, 264 insertions(+), 12 deletions(-) create mode 100644 haco/binary_sensor.py create mode 100644 haco/data/__init__.py create mode 100644 haco/data/type_binary_sensor.py create mode 100644 haco/data/type_sensor.py create mode 100644 haco/data/uom.py diff --git a/haco/binary_sensor.py b/haco/binary_sensor.py new file mode 100644 index 0000000..b28b04f --- /dev/null +++ b/haco/binary_sensor.py @@ -0,0 +1,3 @@ + + + diff --git a/haco/configs/air_fryer.py b/haco/configs/air_fryer.py index c8ca5c4..4d5eb8e 100644 --- a/haco/configs/air_fryer.py +++ b/haco/configs/air_fryer.py @@ -5,7 +5,7 @@ from haco.tools import add_tuya_io OPTIONS = ['Default', 'Fries', 'Shrimp', 'Pizza', 'Chicken', 'Fish', 'Steak', 'Cake', 'Bacon', 'Preheat', 'Custom'] -cookbook = Select('Cookbook', options=OPTIONS, icon='mdi:chef-hat') +cookbook = Select('Cookbook', options=OPTIONS, icon='chef-hat') @cookbook.callback() @@ -21,7 +21,7 @@ def tasmota(value: int): time_remaining = Sensor( name='Time Remaining', uom='minutes', - icon='mdi:timer', + icon='timer', device_class='DURATION' ) @@ -35,7 +35,7 @@ cooking_time = Number( name='Cooking Time', number_range=range(1, 60), uom='minutes', - icon='mdi:timer' + icon='timer' ) @@ -53,7 +53,7 @@ cooking_temp_f = Number( number_range=range(170, 399), mode='slider', uom='°F', - icon='mdi:temperature-fahrenheit' + icon='temperature-fahrenheit' ) @@ -72,7 +72,7 @@ cooking_temp_c = Number( number_range=range(77, 204), mode='slider', uom='°C', - icon='mdi:temperature-celsius' + icon='temperature-celsius' ) @@ -88,14 +88,14 @@ def tasmota(value: float): cook_pause = Switch( name='Cook/Pause', - icon='mdi:play-pause' + icon='play-pause' ) add_tuya_io(cook_pause, int, 1, 2) power = Switch( name='Power', - icon='mdi:power' + icon='power' ) add_tuya_io(power, int, 1, 1) @@ -104,14 +104,14 @@ delay_time = Number( name='Delay Time', number_range=range(0, 720), uom='minutes', - icon='mdi:timer-pause' + icon='timer-pause' ) add_tuya_io(delay_time, int, 2, 6) status = Sensor( name='Status', - icon='mdi:playlist-play', + icon='playlist-play', device_class='ENUM' ) @@ -119,7 +119,7 @@ keep_warm_time = Number( name='Keep Warm Time', number_range=range(0, 120), uom='minutes', - icon='mdi:timer-sync' + icon='timer-sync' ) add_tuya_io(keep_warm_time, int, 2, 105) diff --git a/haco/configs/demo.py b/haco/configs/demo.py index 23731df..0e68df9 100644 --- a/haco/configs/demo.py +++ b/haco/configs/demo.py @@ -1,6 +1,16 @@ +from haco import Sensor + +memory = Sensor('Memory Free', icon='memory', uom=Sensor.UOM.DATA_KILOBYTES, device_class=Sensor.DEVICE_CLASS.DATA_SIZE) + + +@memory.callback(trigger='Tele#Heap') +def tasmota(value: int): + return value + + from haco import Button, Tasmota -restart = Button('Restart Tasmota', icon='mdi:restart') +restart = Button('Restart Tasmota', icon='restart') @restart.callback() diff --git a/haco/control.py b/haco/control.py index 428e818..d0638bf 100644 --- a/haco/control.py +++ b/haco/control.py @@ -36,7 +36,8 @@ class Control: self.get = self.schema.get self.schema.control = self - self.icon = icon + self.icon = f'mdi:{icon}' if icon else icon + self.icon @property def name_sanitized(self): diff --git a/haco/data/__init__.py b/haco/data/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/haco/data/type_binary_sensor.py b/haco/data/type_binary_sensor.py new file mode 100644 index 0000000..dc4b1b0 --- /dev/null +++ b/haco/data/type_binary_sensor.py @@ -0,0 +1,36 @@ +class DeviceClassBinarySensor: + """ + + Sourced from: + https://www.home-assistant.io/integrations/binary_sensor/#device-class + + """ + NONE: type(None) = None # Generic on/off. This is the default and doesn’t need to be set. + BATTERY: str = "battery" # on means low, off means normal + BATTERY_CHARGING: str = "battery_charging" # on means charging, off means not charging + CARBON_MONOXIDE: str = "carbon_monoxide" # on means carbon monoxide detected, off no carbon monoxide (clear) + COLD: str = "cold" # on means cold, off means normal + CONNECTIVITY: str = "connectivity" # on means connected, off means disconnected + DOOR: str = "door" # on means open, off means closed + GARAGE_DOOR: str = "garage_door" # on means open, off means closed + GAS: str = "gas" # on means gas detected, off means no gas (clear) + HEAT: str = "heat" # on means hot, off means normal + LIGHT: str = "light" # on means light detected, off means no light + LOCK: str = "lock" # on means open (unlocked), off means closed (locked) + MOISTURE: str = "moisture" # on means moisture detected (wet), off means no moisture (dry) + MOTION: str = "motion" # on means motion detected, off means no motion (clear) + MOVING: str = "moving" # on means moving, off means not moving (stopped) + OCCUPANCY: str = "occupancy" # on means occupied (detected), off means not occupied (clear) + OPENING: str = "opening" # on means open, off means closed + PLUG: str = "plug" # on means device is plugged in, off means device is unplugged + POWER: str = "power" # on means power detected, off means no power + PRESENCE: str = "presence" # on means home, off means away + PROBLEM: str = "problem" # on means problem detected, off means no problem (OK) + RUNNING: str = "running" # on means running, off means not running + SAFETY: str = "safety" # on means unsafe, off means safe + SMOKE: str = "smoke" # on means smoke detected, off means no smoke (clear) + SOUND: str = "sound" # on means sound detected, off means no sound (clear) + TAMPER: str = "tamper" # on means tampering detected, off means no tampering (clear) + UPDATE: str = "update" # on means update available, off means up-to-date + VIBRATION: str = "vibration" # on means vibration detected, off means no vibration (clear) + WINDOW: str = "window" # on means open, off means closed diff --git a/haco/data/type_sensor.py b/haco/data/type_sensor.py new file mode 100644 index 0000000..3ba873e --- /dev/null +++ b/haco/data/type_sensor.py @@ -0,0 +1,58 @@ +class DeviceClassSensor: + """ + + Sourced from: + https://www.home-assistant.io/integrations/sensor/#device-class + + """ + NONE: type(None) = None # Generic sensor. This is the default and doesn’t need to be set. + APPARENT_POWER: str = "apparent_power" # Apparent power in VA. + AQI: str = "aqi" # Air Quality Index (unitless). + ATMOSPHERIC_PRESSURE: str = "atmospheric_pressure" # Atmospheric pressure in cbar, bar, hPa, inHg, kPa, mbar, Pa, or psi. + BATTERY: str = "battery" # Percentage of battery that is left in %. + CARBON_DIOXIDE: str = "carbon_dioxide" # Carbon Dioxide in CO2 (Smoke) in ppm. + CARBON_MONOXIDE: str = "carbon_monoxide" # Carbon Monoxide in CO (Gas CNG/LPG) in ppm. + CURRENT: str = "current" # Current in A or mA. + DATA_RATE: str = "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: str = "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: str = "date" # Date string (ISO 8601). + DISTANCE: str = "distance" # Generic distance in km, m, cm, mm, mi, yd, or in. + DURATION: str = "duration" # Duration in d, h, min, or s. + ENERGY: str = "energy" # Energy in Wh, kWh, MWh, MJ, or GJ. + ENERGY_STORAGE: str = "energy_storage" # Stored energy in Wh, kWh, MWh, MJ, or GJ. + ENUM: str = "enum" # Has a limited set of (non-numeric) states. + FREQUENCY: str = "frequency" # Frequency in Hz, kHz, MHz, or GHz. + GAS: str = "gas" # Gas volume in m³, ft³, or CCF. + HUMIDITY: str = "humidity" # Percentage of humidity in the air in %. + ILLUMINANCE: str = "illuminance" # The current light level in lx. + IRRADIANCE: str = "irradiance" # Irradiance in W/m² or BTU/(h⋅ft²). + MOISTURE: str = "moisture" # Percentage of water in a substance in %. + MONETARY: str = "monetary" # The monetary value (ISO 4217). + NITROGEN_DIOXIDE: str = "nitrogen_dioxide" # Concentration of Nitrogen Dioxide in µg/m³. + NITROGEN_MONOXIDE: str = "nitrogen_monoxide" # Concentration of Nitrogen Monoxide in µg/m³. + NITROUS_OXIDE: str = "nitrous_oxide" # Concentration of Nitrous Oxide in µg/m³. + OZONE: str = "ozone" # Concentration of Ozone in µg/m³. + PH: str = "ph" # Potential hydrogen (pH) value of a water solution. + PM1: str = "pm1" # Concentration of particulate matter less than 1 micrometer in µg/m³. + PM25: str = "pm25" # Concentration of particulate matter less than 2.5 micrometers in µg/m³. + PM10: str = "pm10" # Concentration of particulate matter less than 10 micrometers in µg/m³. + POWER_FACTOR: str = "power_factor" # Power factor (unitless), unit may be None or %. + POWER: str = "power" # Power in W or kW. + PRECIPITATION: str = "precipitation" # Accumulated precipitation in cm, in, or mm. + PRECIPITATION_INTENSITY: str = "precipitation_intensity" # Precipitation intensity in in/d, in/h, mm/d, or mm/h. + PRESSURE: str = "pressure" # Pressure in Pa, kPa, hPa, bar, cbar, mbar, mmHg, inHg, or psi. + REACTIVE_POWER: str = "reactive_power" # Reactive power in var. + SIGNAL_STRENGTH: str = "signal_strength" # Signal strength in dB or dBm. + SOUND_PRESSURE: str = "sound_pressure" # Sound pressure in dB or dBA. + SPEED: str = "speed" # Generic speed in ft/s, in/d, in/h, km/h, kn, m/s, mph, or mm/d. + SULPHUR_DIOXIDE: str = "sulphur_dioxide" # Concentration of sulphur dioxide in µg/m³. + TEMPERATURE: str = "temperature" # Temperature in °C, °F, or K. + TIMESTAMP: str = "timestamp" # Datetime object or timestamp string (ISO 8601). + VOLATILE_ORGANIC_COMPOUNDS: str = "volatile_organic_compounds" # Concentration of volatile organic compounds in µg/m³. + VOLATILE_ORGANIC_COMPOUNDS_PARTS: str = "volatile_organic_compounds_parts" # Ratio of volatile organic compounds in ppm or ppb. + VOLTAGE: str = "voltage" # Voltage in V or mV. + VOLUME: str = "volume" # Generic volume in L, mL, gal, fl. oz., m³, ft³, or CCF. + VOLUME_STORAGE: str = "volume_storage" # Generic stored volume in L, mL, gal, fl. oz., m³, ft³, or CCF. + WATER: str = "water" # Water consumption in L, gal, m³, ft³, or CCF. + WEIGHT: str = "weight" # Generic mass in kg, g, mg, µg, oz, lb, or st. + WIND_SPEED: str = "wind_speed" # Wind speed in ft/s, km/h, kn, m/s, or mph. diff --git a/haco/data/uom.py b/haco/data/uom.py new file mode 100644 index 0000000..2d2c0dc --- /dev/null +++ b/haco/data/uom.py @@ -0,0 +1,138 @@ +class Uom: + """ + + Sourced from: https://github.com/home-assistant/core/blob/03b1c7ad1deb4b9494df01b27ef8e1d7dfe179ba/homeassistant/const.py#L489C1-L489C1 + + """ + POWER_WATT: str = "W" + POWER_KILO_WATT: str = "kW" + + VOLT: str = "V" + + ENERGY_WATT_HOUR: str = "Wh" + ENERGY_KILO_WATT_HOUR: str = "kWh" + + ELECTRICAL_CURRENT_AMPERE: str = "A" + ELECTRICAL_VOLT_AMPERE: str = "VA" + + DEGREE: str = "°" + + CURRENCY_EURO: str = "€" + CURRENCY_DOLLAR: str = "$" + CURRENCY_CENT: str = "¢" + + TEMP_CELSIUS: str = "°C" + TEMP_FAHRENHEIT: str = "°F" + TEMP_KELVIN: str = "K" + + TIME_MICROSECONDS: str = "μs" + TIME_MILLISECONDS: str = "ms" + TIME_SECONDS: str = "s" + TIME_MINUTES: str = "min" + TIME_HOURS: str = "h" + TIME_DAYS: str = "d" + TIME_WEEKS: str = "w" + TIME_MONTHS: str = "m" + TIME_YEARS: str = "y" + + LENGTH_MILLIMETERS: str = "mm" + LENGTH_CENTIMETERS: str = "cm" + LENGTH_METERS: str = "m" + LENGTH_KILOMETERS: str = "km" + + LENGTH_INCHES: str = "in" + LENGTH_FEET: str = "ft" + LENGTH_YARD: str = "yd" + LENGTH_MILES: str = "mi" + + FREQUENCY_HERTZ: str = "Hz" + FREQUENCY_GIGAHERTZ: str = "GHz" + + PRESSURE_PA: str = "Pa" + PRESSURE_HPA: str = "hPa" + PRESSURE_BAR: str = "bar" + PRESSURE_MBAR: str = "mbar" + PRESSURE_INHG: str = "inHg" + PRESSURE_PSI: str = "psi" + + VOLUME_LITERS: str = "L" + VOLUME_MILLILITERS: str = "mL" + VOLUME_CUBIC_METERS: str = "m³" + VOLUME_CUBIC_FEET: str = "ft³" + + VOLUME_GALLONS: str = "gal" + VOLUME_FLUID_OUNCE: str = "fl. oz." + + VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR: str = "m³/h" + VOLUME_FLOW_RATE_CUBIC_FEET_PER_MINUTE: str = "ft³/m" + + AREA_SQUARE_METERS: str = "m²" + + MASS_GRAMS: str = "g" + MASS_KILOGRAMS: str = "kg" + MASS_MILLIGRAMS: str = "mg" + MASS_MICROGRAMS: str = "µg" + + MASS_OUNCES: str = "oz" + MASS_POUNDS: str = "lb" + + CONDUCTIVITY: str = "µS/cm" + + LIGHT_LUX: str = "lx" + + UV_INDEX: str = "UV index" + + PERCENTAGE: str = "%" + + IRRADIATION_WATTS_PER_SQUARE_METER: str = "W/m²" + + PRECIPITATION_MILLIMETERS_PER_HOUR: str = "mm/h" + + CONCENTRATION_MICROGRAMS_PER_CUBIC_METER: str = "µg/m³" + CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER: str = "mg/m³" + CONCENTRATION_PARTS_PER_CUBIC_METER: str = "p/m³" + CONCENTRATION_PARTS_PER_MILLION: str = "ppm" + CONCENTRATION_PARTS_PER_BILLION: str = "ppb" + + SPEED_MILLIMETERS_PER_DAY: str = "mm/d" + SPEED_INCHES_PER_DAY: str = "in/d" + SPEED_METERS_PER_SECOND: str = "m/s" + SPEED_INCHES_PER_HOUR: str = "in/h" + SPEED_KILOMETERS_PER_HOUR: str = "km/h" + SPEED_MILES_PER_HOUR: str = "mph" + + SIGNAL_STRENGTH_DECIBELS: str = "dB" + SIGNAL_STRENGTH_DECIBELS_MILLIWATT: str = "dBm" + + DATA_BITS: str = "bit" + DATA_KILOBITS: str = "kbit" + DATA_MEGABITS: str = "Mbit" + DATA_GIGABITS: str = "Gbit" + DATA_BYTES: str = "B" + DATA_KILOBYTES: str = "kB" + DATA_MEGABYTES: str = "MB" + DATA_GIGABYTES: str = "GB" + DATA_TERABYTES: str = "TB" + DATA_PETABYTES: str = "PB" + DATA_EXABYTES: str = "EB" + DATA_ZETTABYTES: str = "ZB" + DATA_YOTTABYTES: str = "YB" + DATA_KIBIBYTES: str = "KiB" + DATA_MEBIBYTES: str = "MiB" + DATA_GIBIBYTES: str = "GiB" + DATA_TEBIBYTES: str = "TiB" + DATA_PEBIBYTES: str = "PiB" + DATA_EXBIBYTES: str = "EiB" + DATA_ZEBIBYTES: str = "ZiB" + DATA_YOBIBYTES: str = "YiB" + DATA_RATE_BITS_PER_SECOND: str = "bit/s" + DATA_RATE_KILOBITS_PER_SECOND: str = "kbit/s" + DATA_RATE_MEGABITS_PER_SECOND: str = "Mbit/s" + DATA_RATE_GIGABITS_PER_SECOND: str = "Gbit/s" + DATA_RATE_BYTES_PER_SECOND: str = "B/s" + DATA_RATE_KILOBYTES_PER_SECOND: str = "kB/s" + DATA_RATE_MEGABYTES_PER_SECOND: str = "MB/s" + DATA_RATE_GIGABYTES_PER_SECOND: str = "GB/s" + DATA_RATE_KIBIBYTES_PER_SECOND: str = "KiB/s" + DATA_RATE_MEBIBYTES_PER_SECOND: str = "MiB/s" + DATA_RATE_GIBIBYTES_PER_SECOND: str = "GiB/s" diff --git a/haco/sensor.py b/haco/sensor.py index c2b56ac..f145b7f 100644 --- a/haco/sensor.py +++ b/haco/sensor.py @@ -1,10 +1,16 @@ from haco import schema from haco.control import Control +from haco.data.type_sensor import DeviceClassSensor + +from haco.data.uom import Uom class Sensor(Control): NAME = 'sensor' + DEVICE_CLASS = DeviceClassSensor + UOM = Uom + @classmethod def get_schema(cls): return schema.Schema( From d5cd659e900092615c36de9268f6d48cbabca2b3 Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Wed, 30 Aug 2023 19:46:35 +0000 Subject: [PATCH 019/183] Increment version number to 0.0.9 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index 959b90f..31cab3e 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.8' +var VERSION='0.0.9' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 0cc0a4e..914620b 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.8 +version: 0.0.9 diff --git a/haco/version b/haco/version index 7d6b3eb..429d94a 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.8 \ No newline at end of file +0.0.9 \ No newline at end of file From d3242fd546bad3cfcbe9f724f9e645b3997c2f8f Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 31 Aug 2023 15:18:27 +0100 Subject: [PATCH 020/183] Fix daemon auto-start, refine logging --- berry/haco.be | 30 ++++++++++++++++++++---------- berry/haco_autoexec.be | 12 ++++++++++++ berry/haco_version.be | 3 +++ 3 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 berry/haco_autoexec.be diff --git a/berry/haco.be b/berry/haco.be index 8832484..b42671d 100644 --- a/berry/haco.be +++ b/berry/haco.be @@ -2,10 +2,17 @@ import tools, string, json, mqtt var mod = module("haco") -var logger=tools.logger.logger +import haco_version -logger.level=4 -logger.log_repl=true +var IS_DEVELOPMENT=haco_version.CHANNEL_ID=='development' + +var logger=tools.logging.Logger( + 'haco', + IS_DEVELOPMENT?tools.logging.Logger.DEBUG_MORE:tools.logging.Logger.INFO, + IS_DEVELOPMENT +) + +tools.logger.logger=logger var CALLBACK_MAP={} var BRANCH='release' @@ -40,16 +47,18 @@ class ConfigDownloader if self.id_downloading && self.id_downloading==id - logger.error(string.format("Got duplicate new config (same as currently being downloaded) ID: %s. Will be ignored.",id)) + logger.debug(string.format("Got duplicate new config (same as currently being downloaded) ID: %s. Will be ignored.",id)) return end - logger.debug(string.format("Received new config. ID: %s. Parts: %s",id,num_parts)) + if self.id_downloading logger.error(string.format("Got new config ID: %s while existing download ID: %s incomplete.",id,self.id_downloading)) end + logger.info(string.format("Downloading new config. ID: %s. Parts: %s",id,num_parts)) + self.id_downloading=id logger.debug(['Cancelling any existing downloads...']) @@ -164,7 +173,7 @@ class Daemon def init() - logger.info(['Starting haco daemon...']) + logger.info(string.format('Starting haco daemon in %s seconds...', self.DELAY_SUBSCRIBE)) self.registry_daemon=tools.callbacks.Registry() self.registry_config=tools.callbacks.Registry() @@ -189,6 +198,8 @@ class Daemon if mqtt.connected() self.publish_announce() end + logger.info(string.format('haco daemon has started.', self.DELAY_SUBSCRIBE)) + end def handle_config_message(data) @@ -258,7 +269,7 @@ class Daemon self.config_id=id self.publish_announce() - logger.info(string.format('New config ID %s applied.',id)) + logger.info(string.format('New config ID %s applied successfully.',id)) end @@ -315,8 +326,7 @@ class Daemon end - -mod.daemon=Daemon() - +mod.Daemon=Daemon +mod.daemon=nil return mod \ No newline at end of file diff --git a/berry/haco_autoexec.be b/berry/haco_autoexec.be new file mode 100644 index 0000000..bdcb1fe --- /dev/null +++ b/berry/haco_autoexec.be @@ -0,0 +1,12 @@ +def autoexec(metadata) + + import haco + global.haco=haco + + haco.daemon=haco.Daemon() + +end + +var mod = module("haco_autoexec") +mod.autoexec=autoexec +return mod \ No newline at end of file diff --git a/berry/haco_version.be b/berry/haco_version.be index 31cab3e..7990fd1 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -2,4 +2,7 @@ var VERSION='0.0.9' var mod = module("haco_version") mod.VERSION=VERSION +mod.METADATA=(global.TAPP_METADATA!=nil?global.TAPP_METADATA:{}).find('haco',{}) +mod.CHANNEL_ID=mod.METADATA.find('channel_id') + return mod \ No newline at end of file From eabc1d96c3e80b0ba8ddc92e4990f2a7980582c5 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 31 Aug 2023 15:20:33 +0100 Subject: [PATCH 021/183] Add restart button to demo config --- haco/configs/demo.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/haco/configs/demo.py b/haco/configs/demo.py index 0e68df9..ebe6e4f 100644 --- a/haco/configs/demo.py +++ b/haco/configs/demo.py @@ -1,3 +1,13 @@ +from haco import Button, Tasmota + +restart = Button('Restart Tasmota', icon='restart') + + +@restart.callback() +def ha(value) -> Tasmota[str, 'tasmota.cmd("restart 1")']: + return value + + from haco import Sensor memory = Sensor('Memory Free', icon='memory', uom=Sensor.UOM.DATA_KILOBYTES, device_class=Sensor.DEVICE_CLASS.DATA_SIZE) From 9f2bc075fa93a85dae45181898d124121f379496 Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Thu, 31 Aug 2023 14:21:20 +0000 Subject: [PATCH 022/183] Increment version number to 0.0.10 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index 7990fd1..2dfa26e 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.9' +var VERSION='0.0.10' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 914620b..b7868dc 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.9 +version: 0.0.10 diff --git a/haco/version b/haco/version index 429d94a..b0a1227 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.9 \ No newline at end of file +0.0.10 \ No newline at end of file From a719aab68f0394d7be4f29f919b6328505209df0 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 31 Aug 2023 16:45:45 +0100 Subject: [PATCH 023/183] Allow hostnames as identifiers --- berry/haco.be | 8 +++++--- haco/device.py | 6 ++++-- haco/load_configs.py | 47 +++++++++++++++++++------------------------- haco/mqtt.py | 18 +++++++++++------ 4 files changed, 41 insertions(+), 38 deletions(-) diff --git a/berry/haco.be b/berry/haco.be index b42671d..40caab3 100644 --- a/berry/haco.be +++ b/berry/haco.be @@ -173,7 +173,7 @@ class Daemon def init() - logger.info(string.format('Starting haco daemon in %s seconds...', self.DELAY_SUBSCRIBE)) + logger.info(string.format('Starting haco daemon (v%s) in %s seconds...',haco_version.VERSION, self.DELAY_SUBSCRIBE)) self.registry_daemon=tools.callbacks.Registry() self.registry_config=tools.callbacks.Registry() @@ -187,7 +187,7 @@ class Daemon def subscribe_daemon() - var rule_announce=tools.callbacks.Rule('mqtt#connected',/->print('announced called by mqtt#connected',self.publish_announce())) + var rule_announce=tools.callbacks.Rule('mqtt#connected',/->self.publish_announce()) self.registry_daemon.add(rule_announce) var rule_config=tools.callbacks.MqttSubscription( @@ -198,7 +198,7 @@ class Daemon if mqtt.connected() self.publish_announce() end - logger.info(string.format('haco daemon has started.', self.DELAY_SUBSCRIBE)) + logger.info(string.format('The haco daemon has started. Hostname: %s, MAC: %s. Listening for configuration...', tasmota.hostname(), tools.network.get_mac())) end @@ -222,9 +222,11 @@ class Daemon def get_data_announce() return { + 'version': haco_version.VERSION, 'hostname': tasmota.hostname(), 'eth': tasmota.eth(), 'wifi': tasmota.wifi(), + 'mac': tools.network.get_mac(), 'timestamp': tasmota.rtc(), 'config_id': self.config_id, 'topic': tools.mqtt.get_topic(), diff --git a/haco/device.py b/haco/device.py index a68ecaf..679284a 100644 --- a/haco/device.py +++ b/haco/device.py @@ -9,12 +9,13 @@ from haco.tools import log_publish, split_into_chunks, log_subscribe class Device: - def __init__(self, mac, config_module, controls: List[Control], run_config_post=None): + def __init__(self, identifier, config_module, controls: List[Control], run_config_post=None): self.name = None self.config_module = config_module self.topic = None self.hostname = None - self.mac = mac + self.mac = None + self.identifier = identifier self.run_config_post = run_config_post self.controls = controls self.config_id = None @@ -109,6 +110,7 @@ class Device: self.name = data_announce['device_name'] self.topic = data_announce['topic'] self.hostname = data_announce['hostname'] + self.mac = data_announce['mac'] await self.do_subscriptions(client) diff --git a/haco/load_configs.py b/haco/load_configs.py index f370bdb..9d93d77 100644 --- a/haco/load_configs.py +++ b/haco/load_configs.py @@ -30,39 +30,32 @@ def load_controls_from_directory(): for data in options['assignments']: name = data['config'] - macs = data['identifier'] + identifier = data['identifier'] - if type(macs) is not list: - macs = [macs] + args = {'identifier': identifier} - macs + py_file = CONFIGS_PATH / Path(name).with_suffix('.py') + module_name = py_file.stem - for mac in macs: + try: + module = importlib.import_module(f'haco.configs.{module_name}') + reload(module) + except ImportError: + spec = importlib.util.spec_from_file_location(module_name, str(py_file)) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) - args = {'mac': mac} + args['config_module'] = module - py_file = CONFIGS_PATH / Path(name).with_suffix('.py') - module_name = py_file.stem + for obj_name in dir(module): + obj = getattr(module, obj_name) + if obj_name == 'DEVICE_CONFIG': + args.update(obj) + if isinstance(obj, Control): + args.setdefault('controls', []) + args['controls'].append(obj) - try: - module = importlib.import_module(f'haco.configs.{module_name}') - reload(module) - except ImportError: - spec = importlib.util.spec_from_file_location(module_name, str(py_file)) - module = importlib.util.module_from_spec(spec) - spec.loader.exec_module(module) - - args['config_module'] = module - - for obj_name in dir(module): - obj = getattr(module, obj_name) - if obj_name == 'DEVICE_CONFIG': - args.update(obj) - if isinstance(obj, Control): - args.setdefault('controls', []) - args['controls'].append(obj) - - controls.append(args) + controls.append(args) return controls diff --git a/haco/mqtt.py b/haco/mqtt.py index 4d0cf4f..851a109 100644 --- a/haco/mqtt.py +++ b/haco/mqtt.py @@ -31,16 +31,22 @@ async def listen(client, devices): continue data_announce = json.loads(message.payload) - mac = data_announce['wifi']['mac'] - if mac not in devices: + + identifiers = {data_announce['wifi'].get('mac'), data_announce['eth'].get('mac'), + data_announce['hostname'], data_announce['mac']} + + for identifier in identifiers: + device: Device = devices.get(identifier) + if device: + break + + if not device: msg = f'Got announce from device with no config: Hostname: {data_announce["hostname"]} MAC:{data_announce["mac"]}. Publishing config data.' tools.logger.info(msg) continue - device: Device = devices[mac] - if device.config_id and data_announce['config_id'] == device.config_id: - msg = f'Device {device.name} successfully configured. Hostname: {device.hostname} MAC:{device.mac}' + msg = f'Device "{device.name}" successfully configured. Hostname: {device.hostname} MAC:{device.mac}' tools.logger.info(msg) continue @@ -56,7 +62,7 @@ async def listen(client, devices): async def start_mqtt(): devices = load_devices() - devices = {device.mac: device for device in devices} + devices = {device.identifier: device for device in devices} async with aiomqtt.Client(hostname=MQTT_HOST, port=MQTT_PORT, username=MQTT_USERNAME, password=MQTT_PASSWORD) as client: From bd9304b4ba540b7d97a56236f1bdaf812e8ef639 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 31 Aug 2023 17:46:12 +0100 Subject: [PATCH 024/183] Add test config --- haco/callback.py | 10 +++--- .../{air_fryer.py => proscenic_t21.py} | 31 +++++++++---------- haco/configs/test.py | 25 +++++++++++++++ haco/number.py | 2 ++ 4 files changed, 47 insertions(+), 21 deletions(-) rename haco/configs/{air_fryer.py => proscenic_t21.py} (89%) create mode 100644 haco/configs/test.py diff --git a/haco/callback.py b/haco/callback.py index b149f16..7f8bb1d 100644 --- a/haco/callback.py +++ b/haco/callback.py @@ -4,7 +4,7 @@ import inspect import typing from typing import _AnnotatedAlias -from haco import berry +from haco import berry, schema from haco.trigger import Trigger, Rule Signature = namedtuple('Signature', ['type', 'expression']) @@ -66,7 +66,7 @@ class Callback: known_args = {'value', 'data'} skip_args = {'control'} - if self.platform == 'tasmota': + if self.platform == schema.Tasmota.PLATFORM: berry_exp = {} for name, (type, exp) in arg_data.items(): @@ -76,7 +76,7 @@ class Callback: continue if name not in known_args: - msg = f'Callback {self.function_name} argument {name} requires a Berry expression annotation.' + msg = f'Callback "{self.function_name}" argument "{name}" requires a Berry expression annotation.' raise ValueError(msg) exp = name @@ -104,6 +104,6 @@ class Callback: self.function_tasmota - if self.platform == 'tasmota': + if self.platform == schema.Tasmota.PLATFORM: if not self.trigger: - raise ValueError(f'Callback {self.function_name} must have a trigger.') + raise ValueError(f'Callback "{self.function_name}" must have a trigger.') diff --git a/haco/configs/air_fryer.py b/haco/configs/proscenic_t21.py similarity index 89% rename from haco/configs/air_fryer.py rename to haco/configs/proscenic_t21.py index 4d5eb8e..8ad974c 100644 --- a/haco/configs/air_fryer.py +++ b/haco/configs/proscenic_t21.py @@ -20,9 +20,9 @@ def tasmota(value: int): time_remaining = Sensor( name='Time Remaining', - uom='minutes', + uom=Sensor.UOM.TIME_MINUTES, icon='timer', - device_class='DURATION' + device_class=Sensor.DEVICE_CLASS.DURATION ) @@ -34,7 +34,7 @@ def tasmota(value: int): cooking_time = Number( name='Cooking Time', number_range=range(1, 60), - uom='minutes', + uom=Number.UOM.TIME_MINUTES, icon='timer' ) @@ -52,7 +52,7 @@ cooking_temp_f = Number( 'Cooking Temperature (F)', number_range=range(170, 399), mode='slider', - uom='°F', + uom=Number.UOM.TEMP_FAHRENHEIT, icon='temperature-fahrenheit' ) @@ -71,7 +71,7 @@ cooking_temp_c = Number( 'Cooking Temperature (C)', number_range=range(77, 204), mode='slider', - uom='°C', + uom=Number.UOM.TEMP_CELSIUS, icon='temperature-celsius' ) @@ -103,7 +103,7 @@ add_tuya_io(power, int, 1, 1) delay_time = Number( name='Delay Time', number_range=range(0, 720), - uom='minutes', + uom=Sensor.UOM.TIME_MINUTES, icon='timer-pause' ) @@ -112,22 +112,21 @@ add_tuya_io(delay_time, int, 2, 6) status = Sensor( name='Status', icon='playlist-play', - device_class='ENUM' + device_class=Sensor.DEVICE_CLASS.ENUM ) -keep_warm_time = Number( - name='Keep Warm Time', - number_range=range(0, 120), - uom='minutes', - icon='timer-sync' -) - -add_tuya_io(keep_warm_time, int, 2, 105) - @status.callback(trigger=tuya.received(4, 5)) def tasmota(value: int): return ['Ready', 'Delayed Cook', 'Cooking', 'Keep Warm', 'Off', 'Cooking Complete'][value] +keep_warm_time = Number( + name='Keep Warm Time', + number_range=range(0, 120), + uom=Sensor.UOM.TIME_MINUTES, + icon='timer-sync' +) + +add_tuya_io(keep_warm_time, int, 2, 105) DEVICE_CONFIG = {'run_config_post': f'def () return tasmota.cmd("TuyaSend0") end'} diff --git a/haco/configs/test.py b/haco/configs/test.py new file mode 100644 index 0000000..ea150a9 --- /dev/null +++ b/haco/configs/test.py @@ -0,0 +1,25 @@ +from haco import Select, Tasmota + +greeter = Select('Greeter', icon='hand-wave', options=['Hi', 'Hello Word', 'Bienvenue']) + +set_greeting = """ +def (value,data) + + import string + var cmd=string.format('var16 %s',value) + tasmota.cmd(cmd) + + print(string.format('haco says: %s!',value)) + +end +""" + + +@greeter.callback() +def ha(value) -> Tasmota[str, set_greeting]: + return value + + +@greeter.callback(trigger='Var16#state') +def tasmota(value: str): + return value diff --git a/haco/number.py b/haco/number.py index c87057b..9da7c87 100644 --- a/haco/number.py +++ b/haco/number.py @@ -1,10 +1,12 @@ from haco.control import Control +from haco.data.uom import Uom from haco.tools import get_range_pair class Number(Control): NAME = 'number' + UOM = Uom # def init(name, number_range, mode, step, uom, entity_id, icon, callbacks) def __init__(self, name, number_range: range, icon=None, mode=None, step=None, uom=None): From 74b7d0c8414d7faa3e3c827a249b73537628e3df Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 Sep 2023 15:39:47 +0100 Subject: [PATCH 025/183] Refine some error messages and argument names --- haco/configs/demo.py | 19 ++++++++++++++++++- haco/configs/proscenic_t21.py | 5 +++-- haco/configs/test.py | 4 ++-- haco/control.py | 2 +- haco/debugging.py | 2 +- haco/sensor.py | 6 +++--- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/haco/configs/demo.py b/haco/configs/demo.py index ebe6e4f..74b85a0 100644 --- a/haco/configs/demo.py +++ b/haco/configs/demo.py @@ -10,7 +10,7 @@ def ha(value) -> Tasmota[str, 'tasmota.cmd("restart 1")']: from haco import Sensor -memory = Sensor('Memory Free', icon='memory', uom=Sensor.UOM.DATA_KILOBYTES, device_class=Sensor.DEVICE_CLASS.DATA_SIZE) +memory = Sensor('Memory Free', icon='memory', uom=Sensor.UOM.DATA_KILOBYTES, uom_type=Sensor.UOM_TYPE.DATA_SIZE) @memory.callback(trigger='Tele#Heap') @@ -26,3 +26,20 @@ restart = Button('Restart Tasmota', icon='restart') @restart.callback() def ha(value) -> Tasmota[str, 'tasmota.cmd("restart 1")']: return value + + +from haco import Select, Tasmota + +LOG_LEVELS = ["None", "Error", "Info", "Debug", "Debug More"] + +weblog = Select('WebLog Level', icon='console', options=LOG_LEVELS) + + +@weblog.callback() +def ha(value) -> Tasmota[str, 'tasmota.cmd("WebLog "+value)']: + return LOG_LEVELS.index(value) + + +@weblog.callback(trigger='WebLog') +def tasmota(value: int): + return LOG_LEVELS[value] diff --git a/haco/configs/proscenic_t21.py b/haco/configs/proscenic_t21.py index 8ad974c..14bab99 100644 --- a/haco/configs/proscenic_t21.py +++ b/haco/configs/proscenic_t21.py @@ -21,8 +21,9 @@ def tasmota(value: int): time_remaining = Sensor( name='Time Remaining', uom=Sensor.UOM.TIME_MINUTES, + uom_type=Sensor.UOM_TYPE.DURATION, icon='timer', - device_class=Sensor.DEVICE_CLASS.DURATION + ) @@ -112,7 +113,7 @@ add_tuya_io(delay_time, int, 2, 6) status = Sensor( name='Status', icon='playlist-play', - device_class=Sensor.DEVICE_CLASS.ENUM + uom_type=Sensor.UOM_TYPE.ENUM ) diff --git a/haco/configs/test.py b/haco/configs/test.py index ea150a9..a1eccc7 100644 --- a/haco/configs/test.py +++ b/haco/configs/test.py @@ -20,6 +20,6 @@ def ha(value) -> Tasmota[str, set_greeting]: return value -@greeter.callback(trigger='Var16#state') -def tasmota(value: str): +@greeter.callback(trigger='WebLog') +def tasmota(value: int): return value diff --git a/haco/control.py b/haco/control.py index d0638bf..c971a82 100644 --- a/haco/control.py +++ b/haco/control.py @@ -54,7 +54,7 @@ class Control: callback_names = self.schema.get_callback_function_names() if function_name not in callback_names: - msg = f'Callback function "{function_name}" name is not valid. Must be one of: {sorted(callback_names)}' + msg = f'Callback function "{function_name}" name is not valid for control "{self.__class__.__name__}". Must be one of: {sorted(callback_names)}' raise ValueError(msg) capability_id, platform_id = function_name.rsplit('_', 1) diff --git a/haco/debugging.py b/haco/debugging.py index 9db48ea..1fc78f4 100644 --- a/haco/debugging.py +++ b/haco/debugging.py @@ -6,7 +6,7 @@ from haco.tasmota import Tasmota def get_memory_sensor(): - memory_sensor = Sensor('Memory Free', uom='kB', device_class='DATA_SIZE', data_type=int) + memory_sensor = Sensor('Memory Free', uom='kB', uom_type='DATA_SIZE', data_type=int) @memory_sensor.callback(trigger.Cron('*/30 * * * * *')) def tasmota(value: Tasmota[Any, 'tasmota.memory()']): diff --git a/haco/sensor.py b/haco/sensor.py index f145b7f..e27aa09 100644 --- a/haco/sensor.py +++ b/haco/sensor.py @@ -8,7 +8,7 @@ from haco.data.uom import Uom class Sensor(Control): NAME = 'sensor' - DEVICE_CLASS = DeviceClassSensor + UOM_TYPE = DeviceClassSensor UOM = Uom @classmethod @@ -23,9 +23,9 @@ class Sensor(Control): ] ) - def __init__(self, name, data_type=None, uom=None, icon=None, device_class=None): + def __init__(self, name, data_type=None, uom=None, icon=None, uom_type=None): self.data_type = data_type - self.device_class = device_class + self.device_class = uom_type self.uom = uom super().__init__(name, icon=icon) From 82b878dd36e2ac42b8bd3476f0e77f147a44141f Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 Sep 2023 15:40:09 +0100 Subject: [PATCH 026/183] Add README --- README.md | 344 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 343 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 535b6c7..1a330e5 100644 --- a/README.md +++ b/README.md @@ -1 +1,343 @@ -# Home Assistant Control Objects \ No newline at end of file +# `haco` Home Assistant Control Objects + +`haco` is a Home Assistant Add-On, and associated Tasmota daemon written in Berry, to greatly simplify the process of +exposing Home +Assistant controls (e.g. Pull-down Lists, Number Sliders, Sensors, etc.) from a Tasmota device - and handling the +communication between both sides. + +Using `haco` to expose, for example, a "Restart Tasmota" button to Home Assistant is as simple as writing the following +Python code: + +```py +from haco import Button, Tasmota + +restart = Button('Restart Tasmota', icon='restart') + + +@restart.callback() +def ha(value) -> Tasmota[str, 'tasmota.cmd("restart 1")']: + return value +``` + +A fully functional restart button will now appear associated with the device in Home Assistant: + +Restart Button + +Or, more practically, a cookbook pull-down menu, for a Tuya air fryer, might look like this: + +```py +OPTIONS = ['Default', 'Fries', 'Shrimp', 'Pizza', 'Chicken', 'Fish', 'Steak', 'Cake', 'Bacon', 'Preheat', 'Custom'] + +cookbook = Select('Cookbook', options=OPTIONS, icon='chef-hat') + + +@cookbook.callback() +def ha(value: str) -> Tasmota[int, tuya.send(4, 3)]: + return OPTIONS.index(value) + + +@cookbook.callback(trigger=tuya.received(4, 3)) +def tasmota(value: int): + return OPTIONS[value] +``` + +Air Fryer Cookbook + +## Do I Need This? Can't I Do this with Native Tasmota? + +You certainly can. + +But in my experience, the process is so fiddly, error-prone and hard to maintain that it's enough to +deter the casual user (as I am) entirely. Plus, sharing your configuration, once you've finally got it working, can mean +complex step-by-step guides, setting up triggers, finding MAC addresses and topics (in Tasmota) - and numerous +Blueprints, Helpers and Templates (on the Home Assistant side). + +You can see how much work creating such guides involves by seeing how it +was [heroically undertaken by Blakadder](https://blakadder.com/proscenic-in-home-assistant/), as +compared with the [full `haco`-based equivalent](/configs/proscenic_t21.py). + +With `haco`, on the other hand, the thorny parts of the initial setup are abstracted away and your final configuration +can often be shared via a single script. Below is a list of some of the tasks that `haco` +handles for you: + +* Announcing the entity via MQTT to Home Assistant +* Generating MQTT/HA-friendly unique IDs +* Associating the entity with its parent device +* Subscribing and publishing to the relevant MQTT topics +* Managing the relevant Tasmota rules +* Appropriate serialization of data +* Translating Home Assistant messages to their to appropriate Berry data types, and vice versa + +## Pre-Release + +:warning: This library is currently in a pre-release state. The configuration format is likely to change, and +only `Sensor`, `Select`, `Button`, `Number`, `BinarySensor`, `Switch`, `Text`, `Update`, `Fan` +and `Climate` entities are currently implemented. + +## Installation + +Installation involves installing two parts: the Tasmota daemon and the Home Assistant Add-On. Both are fairly simple. + +### Tasmota + +I'd advise first using a guinea pig Tasmota device to get `haco` up and running. The device needs to have MQTT +connected and be available to Home Assistant (i.e. showing up in the Devices section). + +Once your test device is ready, with a recent (12.5+) version of Tasmota, simply paste the following into your Tasmota +Berry Script Console: + +```be +{"download":tasmota.urlfetch('https://link.frontmatter.ai/haco/tapp','haco.tapp'), "restart":tasmota.cmd("restart 1")} +``` + +You should see output like `{'restart': {'Restart': 'Restarting'}, 'download': 200}` and the device will restart. + +With older Tasmota versions, download the [`.tapp` file](https://link.frontmatter.ai/haco/tapp) on a desktop computer, +upload it to your device as `haco.tapp` and restart manually. + +Once the device restarts, you should see the following among your Tasmota startup logs (in the regular console, not the +Berry one): + +``` +HACO: The haco daemon has started. Hostname: tasmota-test, MAC: 04:74:77:9B:CB:CC. Listening for configuration... +``` + +### Home Assistant + +You can now install the Home Assistant Add-On: + +[![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://link.frontmatter.ai/haco/add-on) + +Once the Add-On is installed, click into its Configuration tab, you'll see a setting called `assignments`: + +```yaml +- config: null + identifier: null +``` + +#### Assigning a configuration module to a device + +Now we're ready to assign a configuration module to our Tasmota device. For now, we can use a built-in test +module `test`. The `identifer` value should be the hostname (or MAC) of your Tasmota device. So for our example it +should look like this: + +```yaml +- config: test + identifier: tasmota-test # Hostname of Tasmota device +``` + +Saving the Configuration will restart the Add-On. After the restart, you should see the following in the Add-On logs: + +``` +Device "Tasmota Test Device" successfully configured. Hostname: tasmota-test MAC: 04:74:77:9B:CB:CC. +``` + +In Home Assistant, find the device in the Devices section. You should now see a test Select (pulldown) control called " +Greeter". +Selecting the greetings from the pulldown, you should see them appear in your Tasmota Berry console, e.g. + +```console +haco says: Hello World! +``` + +This means `haco` is set up and working properly. Good! You can now use `haco` to assign configuration modules to your +Tasmota devices. + +## Configuration Modules + +Configuration modules are a little like drivers, that tell `haco` how to communicate with a Tasmota device, what +controls to expose to Home Assistant, etc. + +So far we've only used the `test` configuration module, that exposed the Greeter pulldown, but to control +real-world devices, you'll need to assign them to a module written specifically for that device. There are currently two +types of modules, +Built-In and User-Defined. + +Whichever type you use, assigning them to a device is done as we saw above. + +### Built-In Modules + +`haco` ships with a small number of built-in configurations. These can be found in +the [configs directory](tree/release/haco/configs) in this repo. But in the likely event that your device hasn't already +been added, you'll need to define your own. + +:information_source: The aim is to expand the number of built-in configurations over time. So if you define your own ( +see below), please submit it to this repo as a Pull Request, or raise an Issue linking to your code! + +### Creating Your Own Configuration Module + +#### General module structure + +A configuration module is, ultimately, just a typical Python module. In this case, they contain definitions from one or +more `Control` objects. Each control definition involves two things: + +* The control object assigned to a variable, e.g. `temperature_sensor=Sensor(...)` +* Any required callback functions for the control, e.g. `@temperature_sensor.callback(...)` + +#### Location + +User-Defined modules should be added to the `/config/haco` directory in Home Assistant, with a `.py` extension, +e.g. `my_config.py`. + +#### Defining controls + +Here are a couple of simple examples to help get you started defining your own configuration module. + +##### Tasmota-Only Controls + +First, let's define a Tasmota-only sensor to report how much free memory there is on the Tasmota device. This sensor +is "Tasmota-Only" as it only handles values sent _from_ Tasmota (and sends nothing back from Home Assistant). + +```python +from haco import Sensor + +memory = Sensor('Memory Free', icon='memory', uom=Sensor.UOM.DATA_KILOBYTES, uom_type=Sensor.UOM_TYPE.DATA_SIZE) + + +@memory.callback(trigger='Tele#Heap') +def tasmota(value: int): + return value + +``` + +Let's break this control definition down into the control object, the callback decorator, and the callback itself. + +###### The control object + +First we initialise a `Sensor` control object, assign it to a variable called `memory`, give it a relevant icon, unit of +measure and device class. + +###### The callback decorator + +Next, we add a callback object to that control. Here we call the function `tasmota` to tell `haco` that this callback is +for handling values _from_ Tasmota. As for _what_ +values to return from Tasmota, this is specified by the `trigger` argument to the decorator `memory.callback`. The +trigger itself, `Tele#Heap`, fires +whenever telemetry data is returned from Tasmota and, specifically, returns the `Heap` field, which contains the free +memory in +kilobytes. + +:warning: Tasmota callbacks _must_ have such a `trigger` specified in this decorator. + +###### The callback + +Note that the callback function is named `tasmota`. This is important as the name tells `haco` that this callback +handles values _from_ Tasmota. +The response from the trigger we specified in our callback decorator above gets fed into our callback as the `value` +argument. The (optional) type annotation for the `value` argument (the `int`) tells `haco` what data type to expect from +Tasmota, and type conversion gets done automatically. +The return value from the function is what will be returned to Home Assistant as the value for the sensor. + +:information_source: Note that our callback function does not actually _do_ anything with our `value` other than return +it. But if we wanted to (for example) +convert the value from kilobytes to bytes, this is where we'd do it, with `return value*1000`. + +:information_source: You can find the list of available UOMs [here](blob/release/haco/data/uom.py) and +types [here](blob/main/haco/data/type_sensor.py). + +#### Home Assistant-Only Controls + +Moving on to the opposite type of control, that is one that only handles values _from_ Home Assistant. The Button +control does +exactly this, as it is triggered by being pressing in Home Assistant, but Tasmota returns nothing to acknowledge that +press. + +Here is how to define a `Button` control that, when pressed, restarts the Tasmota device. + +```py +from haco import Button, Tasmota + +restart = Button('Restart Tasmota', icon='restart') + + +@restart.callback() +def ha(value) -> Tasmota[str, 'tasmota.cmd("restart 1")']: + return value + +``` + +In the case we define a `Button` control, and again use our decorator to add a callback to handle values _from_ Home +Assistant, which must therefore be named `ha`. + +###### The `Tasmota` Type Annotation + +The most notable difference with a Home Assistant (`ha`) callback is the `Tasmota` return type annotation. This takes +two arguments, `Tasmota[,]`. The +first argument is the type returned by the callback function, as per usual, and which again lets `haco` convert the +return value accordingly. + +But the second argument is an expression that defines how to _apply_ the change on the Tasmota side. In this case, this +is just a Berry expression to restart Tasmota. + +:warning: Note that Home Assistant callbacks _must_ have such a `Tasmota` type annotation for their return type. + +:information_source: In the example above, the `value` argument received and returned by our callback is not actually +used on the Berry +side. Home Assistant just sends a constant string (`PRESS`) when the button is pressed, so the actual content of +the `value` argument is not important. + +#### Two-Way Controls + +Two-Way controls need to handle values from _both_ Home Assistant and from Tasmota, and hence need both the callbacks +types - `ha` and `tasmota` we've seen above. + +Here is an example two-way `Select` (pulldown menu) object. It allows setting the Tasmota `WebLog` console debugging +level from Home Assistant, and also reflects any changes to that setting made on the Tasmota side. + +```python +from haco import Select, Tasmota + +LOG_LEVELS = ["None", "Error", "Info", "Debug", "Debug More"] + +weblog = Select('WebLog Level', icon='console', options=LOG_LEVELS) + + +@weblog.callback() +def ha(value) -> Tasmota[str, 'tasmota.cmd("WebLog "+value)']: + return LOG_LEVELS.index(value) + + +@weblog.callback(trigger='WebLog') +def tasmota(value: int): + return LOG_LEVELS[value] +``` + +The above is very similar to what we have already seen. + +The `ha` callback takes friendly names (e.g. `Error`, `Info`) selected by the user in Home Assistant, and returns them +as their corresponding number values (`WebLog 1`, `WebLog2`) used by Tasmota. + +The `tasmota` callback, naturally enough, does the exact opposite, returning the string names to Home Assistant whenever +the `WebLog` command is used on the Tasmota side. + +WebLog Select + +#### Debugging Your Configuration + +When you first assign a new configuration to a device, keep an eye on the Add-On logs for any errors. You'll see a +typical Python stack trace if anything goes wrong. + +:information_source: Each time you edit your configuration module (`.py` file), you'll need to restart the Add-On. Hot +is reloading not yet supported. + +#### Additional Capabilities + +More complex device controls (e.g. `Climate`, `Fan`) have additional capabilities beyond a single value sent to/from +Home Assistant. Adding callbacks for these extended capabilities is done similarly to the above, only the callbacks need +to include the name of the capability. So if you want to add callbacks around setting the `target_humidity` of +a `Climate` control, you'd need to call your callbacks `target_humidity_tasmota` and `target_humidity_ha`, etc. + +A full schema of these names will appear in subsequent documentation. But you can find example implementations for most +controls in the [built-in `development` config](blob/release/haco/configs/development.py). + +Anway, if you get the names wrong, you'll see an error like this in your Add-On logs: + +``` +ValueError: Callback function "set_mode_ha" name is not valid for control "Climate". Must be one of: ['action_tasmota', 'current_humidity_tasmota', 'current_temperature_tasmota', 'mode_ha', 'mode_tasmota', 'preset_mode_ha', 'preset_mode_tasmota', 'swing_mode_ha', 'swing_mode_tasmota', 'target_humidity_ha', 'target_humidity_tasmota', 'target_temperature_ha', 'target_temperature_tasmota', 'temperature_high_ha', 'temperature_high_tasmota', 'temperature_low_ha', 'temperature_low_tasmota'] +``` + +#### Additional Resources + +Beyond these examples, when creating your own configuration, you'll probably find +the [built-in configurations](tree/release/haco/configs) ( +especially the [`development` config](blob/release/haco/configs/development.py)) useful. From 636436763cecb2078b108dd8c682bb2cd437632b Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 Sep 2023 15:51:37 +0100 Subject: [PATCH 027/183] Add environment variable log level --- haco/tools.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/haco/tools.py b/haco/tools.py index f42987a..c24d237 100644 --- a/haco/tools.py +++ b/haco/tools.py @@ -1,10 +1,13 @@ import hashlib import logging +import os from haco import constants, tuya from haco.tasmota import Tasmota -logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(message)s', datefmt='%Y-%m-%d %H:%M:%S') +LOG_LEVEL = os.environ.get('HACO_LOG_LEVEL', 'INFO') + +logging.basicConfig(level=LOG_LEVEL, format='%(asctime)s %(levelname)-8s %(message)s', datefmt='%Y-%m-%d %H:%M:%S') logger = logging.getLogger(__name__) From 0244699ec3929d593779edca68da1047ef4695f6 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 Sep 2023 16:20:37 +0100 Subject: [PATCH 028/183] Refine README --- README.md | 76 ++++++++++++++++++++++---------------- assets/greeter_select.png | Bin 0 -> 5237 bytes assets/memory_sensor.png | Bin 0 -> 40990 bytes assets/weblog_select.png | Bin 0 -> 5237 bytes haco/control.py | 2 +- 5 files changed, 45 insertions(+), 33 deletions(-) create mode 100644 assets/greeter_select.png create mode 100644 assets/memory_sensor.png create mode 100644 assets/weblog_select.png diff --git a/README.md b/README.md index 1a330e5..c3f0b1d 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,8 @@ Installation involves installing two parts: the Tasmota daemon and the Home Assi ### Tasmota I'd advise first using a guinea pig Tasmota device to get `haco` up and running. The device needs to have MQTT -connected and be available to Home Assistant (i.e. showing up in the Devices section). +connected and be available to Home Assistant (i.e. showing up +in [the Devices section](https://my.home-assistant.io/redirect/devices/)). Once your test device is ready, with a recent (12.5+) version of Tasmota, simply paste the following into your Tasmota Berry Script Console: @@ -92,9 +93,6 @@ Berry Script Console: You should see output like `{'restart': {'Restart': 'Restarting'}, 'download': 200}` and the device will restart. -With older Tasmota versions, download the [`.tapp` file](https://link.frontmatter.ai/haco/tapp) on a desktop computer, -upload it to your device as `haco.tapp` and restart manually. - Once the device restarts, you should see the following among your Tasmota startup logs (in the regular console, not the Berry one): @@ -102,13 +100,19 @@ Berry one): HACO: The haco daemon has started. Hostname: tasmota-test, MAC: 04:74:77:9B:CB:CC. Listening for configuration... ``` +#### Older Tasmota Versions + +With older Tasmota versions, download the [`haco.tapp` file](https://link.frontmatter.ai/haco/tapp) on a desktop +computer, +upload it to your device and restart manually. + ### Home Assistant You can now install the Home Assistant Add-On: [![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://link.frontmatter.ai/haco/add-on) -Once the Add-On is installed, click into its Configuration tab, you'll see a setting called `assignments`: +Once the Add-On is installed, click into its Configuration tab and you'll see a setting called `assignments`: ```yaml - config: null @@ -132,8 +136,11 @@ Saving the Configuration will restart the Add-On. After the restart, you should Device "Tasmota Test Device" successfully configured. Hostname: tasmota-test MAC: 04:74:77:9B:CB:CC. ``` -In Home Assistant, find the device in the Devices section. You should now see a test Select (pulldown) control called " -Greeter". +In Home Assistant, find the device in [the Devices section](https://my.home-assistant.io/redirect/devices/). You should +now see a test Select (pulldown) control called "Greeter". + +WebLog Select + Selecting the greetings from the pulldown, you should see them appear in your Tasmota Berry console, e.g. ```console @@ -177,7 +184,7 @@ more `Control` objects. Each control definition involves two things: #### Location User-Defined modules should be added to the `/config/haco` directory in Home Assistant, with a `.py` extension, -e.g. `my_config.py`. +e.g. `/config/haco/my_config.py`. #### Defining controls @@ -205,35 +212,38 @@ Let's break this control definition down into the control object, the callback d ###### The control object First we initialise a `Sensor` control object, assign it to a variable called `memory`, give it a relevant icon, unit of -measure and device class. +measure and type. ###### The callback decorator -Next, we add a callback object to that control. Here we call the function `tasmota` to tell `haco` that this callback is -for handling values _from_ Tasmota. As for _what_ -values to return from Tasmota, this is specified by the `trigger` argument to the decorator `memory.callback`. The -trigger itself, `Tele#Heap`, fires -whenever telemetry data is returned from Tasmota and, specifically, returns the `Heap` field, which contains the free -memory in -kilobytes. +The callback decorator `@memory.callback(trigger='Tele#Heap')` specifies a Tasmota trigger, the values from which will +be sent to the callback function. +This specific trigger, `Tele#Heap`, fires whenever telemetry data is returned from Tasmota and, specifically, returns +the `Heap` field, which contains the free +memory in kilobytes. :warning: Tasmota callbacks _must_ have such a `trigger` specified in this decorator. +Memory Sensor + + ###### The callback -Note that the callback function is named `tasmota`. This is important as the name tells `haco` that this callback +Note that the callback function is named `tasmota`. This name is important as it tells `haco` that this callback handles values _from_ Tasmota. + The response from the trigger we specified in our callback decorator above gets fed into our callback as the `value` argument. The (optional) type annotation for the `value` argument (the `int`) tells `haco` what data type to expect from Tasmota, and type conversion gets done automatically. + The return value from the function is what will be returned to Home Assistant as the value for the sensor. :information_source: Note that our callback function does not actually _do_ anything with our `value` other than return -it. But if we wanted to (for example) -convert the value from kilobytes to bytes, this is where we'd do it, with `return value*1000`. +it. But if we wanted to (for example) convert the value from kilobytes to bytes, this is where we'd do it, +with `return value*1000`. -:information_source: You can find the list of available UOMs [here](blob/release/haco/data/uom.py) and -types [here](blob/main/haco/data/type_sensor.py). +:information_source: You can find the list of available units of measure [here](../../blob/release/haco/data/uom.py) and +types [here](../../blob/main/haco/data/type_sensor.py). #### Home Assistant-Only Controls @@ -266,19 +276,20 @@ two arguments, `Tasmota[,]`. The first argument is the type returned by the callback function, as per usual, and which again lets `haco` convert the return value accordingly. -But the second argument is an expression that defines how to _apply_ the change on the Tasmota side. In this case, this +The second argument is an expression that defines _what to do_ on the Tasmota side when the button is pressed. In this +case, this is just a Berry expression to restart Tasmota. :warning: Note that Home Assistant callbacks _must_ have such a `Tasmota` type annotation for their return type. :information_source: In the example above, the `value` argument received and returned by our callback is not actually -used on the Berry -side. Home Assistant just sends a constant string (`PRESS`) when the button is pressed, so the actual content of +used by the Berry expression side. Home Assistant just sends a constant string (`PRESS`) when the button is pressed, so +the actual content of the `value` argument is not important. #### Two-Way Controls -Two-Way controls need to handle values from _both_ Home Assistant and from Tasmota, and hence need both the callbacks +Two-way controls need to handle values from _both_ Home Assistant and from Tasmota, and hence need both the callbacks types - `ha` and `tasmota` we've seen above. Here is an example two-way `Select` (pulldown menu) object. It allows setting the Tasmota `WebLog` console debugging @@ -317,27 +328,28 @@ the `WebLog` command is used on the Tasmota side. When you first assign a new configuration to a device, keep an eye on the Add-On logs for any errors. You'll see a typical Python stack trace if anything goes wrong. -:information_source: Each time you edit your configuration module (`.py` file), you'll need to restart the Add-On. Hot +:warning: Each time you edit your configuration module (`.py` file), you'll need to restart the Add-On. Hot is reloading not yet supported. #### Additional Capabilities -More complex device controls (e.g. `Climate`, `Fan`) have additional capabilities beyond a single value sent to/from -Home Assistant. Adding callbacks for these extended capabilities is done similarly to the above, only the callbacks need +More complex device controls (e.g. `Climate`, `Fan`) have additional capabilities beyond a single value requiting +Tasmota/Home Assistant +callbacks. Adding callbacks for these extended capabilities is done similarly to the above, only the callbacks need to include the name of the capability. So if you want to add callbacks around setting the `target_humidity` of a `Climate` control, you'd need to call your callbacks `target_humidity_tasmota` and `target_humidity_ha`, etc. A full schema of these names will appear in subsequent documentation. But you can find example implementations for most -controls in the [built-in `development` config](blob/release/haco/configs/development.py). +controls in the [built-in `development` config](../../blob/release/haco/configs/development.py). Anway, if you get the names wrong, you'll see an error like this in your Add-On logs: ``` -ValueError: Callback function "set_mode_ha" name is not valid for control "Climate". Must be one of: ['action_tasmota', 'current_humidity_tasmota', 'current_temperature_tasmota', 'mode_ha', 'mode_tasmota', 'preset_mode_ha', 'preset_mode_tasmota', 'swing_mode_ha', 'swing_mode_tasmota', 'target_humidity_ha', 'target_humidity_tasmota', 'target_temperature_ha', 'target_temperature_tasmota', 'temperature_high_ha', 'temperature_high_tasmota', 'temperature_low_ha', 'temperature_low_tasmota'] +ValueError: Callback function name "set_mode_ha" is not valid for control "Climate". Must be one of: ['action_tasmota', 'current_humidity_tasmota', 'current_temperature_tasmota', 'mode_ha', 'mode_tasmota', 'preset_mode_ha', 'preset_mode_tasmota', 'swing_mode_ha', 'swing_mode_tasmota', 'target_humidity_ha', 'target_humidity_tasmota', 'target_temperature_ha', 'target_temperature_tasmota', 'temperature_high_ha', 'temperature_high_tasmota', 'temperature_low_ha', 'temperature_low_tasmota'] ``` #### Additional Resources Beyond these examples, when creating your own configuration, you'll probably find -the [built-in configurations](tree/release/haco/configs) ( -especially the [`development` config](blob/release/haco/configs/development.py)) useful. +the [built-in configurations](../../tree/release/haco/configs) (especially +the [`development` config](../../blob/release/haco/configs/development.py)) useful. diff --git a/assets/greeter_select.png b/assets/greeter_select.png new file mode 100644 index 0000000000000000000000000000000000000000..ff3546fe785251d64d50f78f1dfbbf69cc98e185 GIT binary patch literal 5237 zcmc(jS5y;Sw8xXs0s$c!5CkEjAP54A0-+_*fS}Su=`C~%5I_NGN$4O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+-}UBPA_Fm(E&4nCb285AUm5nYnMa-o)G{PIEqk6A_Rx2kBO3FHu;* zLj#H#Hj5>r*2~L{a5ZfUqC*yBOydq>g;CK+h4ALtZ@MQFSGl@1@08ofl*gjARSPwd z{qZvw#vT#7`xp2a2Ce7RX(rNW$bo{4ESFyzg%iqN^v3EyP1nJ%NnJ3QVNzV)d|Nso zrww0934AZStvVhIXgC)GUO)?Ek4oKuHUMlx7eI4U<-p<+2vm&wU&mGd=_Kgi24LnV z`%TlHm0f`FcolI2YI?*a{nyocoF+H` literal 0 HcmV?d00001 diff --git a/haco/control.py b/haco/control.py index c971a82..20bb0b8 100644 --- a/haco/control.py +++ b/haco/control.py @@ -54,7 +54,7 @@ class Control: callback_names = self.schema.get_callback_function_names() if function_name not in callback_names: - msg = f'Callback function "{function_name}" name is not valid for control "{self.__class__.__name__}". Must be one of: {sorted(callback_names)}' + msg = f'Callback function name "{function_name}" is not valid for control "{self.__class__.__name__}". Must be one of: {sorted(callback_names)}' raise ValueError(msg) capability_id, platform_id = function_name.rsplit('_', 1) From c1001fd6f1f135afc330e278d2767161e7c26def Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 Sep 2023 16:35:45 +0100 Subject: [PATCH 029/183] Refine README --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c3f0b1d..bef14e6 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,8 @@ def tasmota(value: int): ``` +Memory Sensor + Let's break this control definition down into the control object, the callback decorator, and the callback itself. ###### The control object @@ -224,9 +226,6 @@ memory in kilobytes. :warning: Tasmota callbacks _must_ have such a `trigger` specified in this decorator. -Memory Sensor - - ###### The callback Note that the callback function is named `tasmota`. This name is important as it tells `haco` that this callback From 872ecbad27860987072d8a1700a9ef8704343f53 Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Fri, 1 Sep 2023 15:53:30 +0000 Subject: [PATCH 030/183] Increment version number to 0.0.11 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index 2dfa26e..b20e02d 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.10' +var VERSION='0.0.11' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index b7868dc..c4675fa 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.10 +version: 0.0.11 diff --git a/haco/version b/haco/version index b0a1227..58682af 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.10 \ No newline at end of file +0.0.11 \ No newline at end of file From 54a090c6e8ebc8f2834936cf5c42d42ac43a44a3 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 Sep 2023 17:24:16 +0100 Subject: [PATCH 031/183] Make links absolute --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index bef14e6..4fed767 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ def ha(value) -> Tasmota[str, 'tasmota.cmd("restart 1")']: A fully functional restart button will now appear associated with the device in Home Assistant: -Restart Button +Restart Button Or, more practically, a cookbook pull-down menu, for a Tuya air fryer, might look like this: @@ -41,7 +41,7 @@ def tasmota(value: int): return OPTIONS[value] ``` -Air Fryer Cookbook +Air Fryer Cookbook ## Do I Need This? Can't I Do this with Native Tasmota? @@ -139,7 +139,7 @@ Device "Tasmota Test Device" successfully configured. Hostname: tasmota-test MAC In Home Assistant, find the device in [the Devices section](https://my.home-assistant.io/redirect/devices/). You should now see a test Select (pulldown) control called "Greeter". -WebLog Select +WebLog Select Selecting the greetings from the pulldown, you should see them appear in your Tasmota Berry console, e.g. @@ -207,7 +207,7 @@ def tasmota(value: int): ``` -Memory Sensor +Memory Sensor Let's break this control definition down into the control object, the callback decorator, and the callback itself. @@ -320,7 +320,7 @@ as their corresponding number values (`WebLog 1`, `WebLog2`) used by Tasmota. The `tasmota` callback, naturally enough, does the exact opposite, returning the string names to Home Assistant whenever the `WebLog` command is used on the Tasmota side. -WebLog Select +WebLog Select #### Debugging Your Configuration @@ -339,7 +339,7 @@ to include the name of the capability. So if you want to add callbacks around se a `Climate` control, you'd need to call your callbacks `target_humidity_tasmota` and `target_humidity_ha`, etc. A full schema of these names will appear in subsequent documentation. But you can find example implementations for most -controls in the [built-in `development` config](../../blob/release/haco/configs/development.py). +controls in the [built-in `development` config](https://github.com/fmtr/haco/tree/release/haco/configs/development.py). Anway, if you get the names wrong, you'll see an error like this in your Add-On logs: @@ -350,5 +350,5 @@ ValueError: Callback function name "set_mode_ha" is not valid for control "Clima #### Additional Resources Beyond these examples, when creating your own configuration, you'll probably find -the [built-in configurations](../../tree/release/haco/configs) (especially -the [`development` config](../../blob/release/haco/configs/development.py)) useful. +the [built-in configurations](https://github.com/fmtr/haco/tree/release/haco/configs) (especially +the [`development` config](https://github.com/fmtr/haco/tree/release/haco/configs/development.py)) useful. From ca4b9a39548c6eae90d753452bfaa918022bfcee Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 Sep 2023 17:32:27 +0100 Subject: [PATCH 032/183] Make links absolute --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4fed767..32f5a89 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ def ha(value) -> Tasmota[str, 'tasmota.cmd("restart 1")']: A fully functional restart button will now appear associated with the device in Home Assistant: -Restart Button +Restart Button Or, more practically, a cookbook pull-down menu, for a Tuya air fryer, might look like this: @@ -41,7 +41,7 @@ def tasmota(value: int): return OPTIONS[value] ``` -Air Fryer Cookbook +Air Fryer Cookbook ## Do I Need This? Can't I Do this with Native Tasmota? @@ -139,7 +139,7 @@ Device "Tasmota Test Device" successfully configured. Hostname: tasmota-test MAC In Home Assistant, find the device in [the Devices section](https://my.home-assistant.io/redirect/devices/). You should now see a test Select (pulldown) control called "Greeter". -WebLog Select +WebLog Select Selecting the greetings from the pulldown, you should see them appear in your Tasmota Berry console, e.g. @@ -207,7 +207,7 @@ def tasmota(value: int): ``` -Memory Sensor +Memory Sensor Let's break this control definition down into the control object, the callback decorator, and the callback itself. @@ -320,7 +320,7 @@ as their corresponding number values (`WebLog 1`, `WebLog2`) used by Tasmota. The `tasmota` callback, naturally enough, does the exact opposite, returning the string names to Home Assistant whenever the `WebLog` command is used on the Tasmota side. -WebLog Select +WebLog Select #### Debugging Your Configuration From c6cb067ddc95f33fe3529c2b4aafb4d6479b5973 Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Fri, 1 Sep 2023 16:33:22 +0000 Subject: [PATCH 033/183] Increment version number to 0.0.12 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index b20e02d..9ba0f8d 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.11' +var VERSION='0.0.12' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index c4675fa..3aaf3fe 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.11 +version: 0.0.12 diff --git a/haco/version b/haco/version index 58682af..9bbaee4 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.11 \ No newline at end of file +0.0.12 \ No newline at end of file From 84bc8ca87879f6e5f22c1d280493bdc600af9b43 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 1 Sep 2023 20:21:22 +0100 Subject: [PATCH 034/183] Refactor environment variables into constants module --- haco/constants.py | 14 ++++++++++++++ haco/load_configs.py | 5 +---- haco/mqtt.py | 7 +------ haco/tools.py | 6 ++---- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/haco/constants.py b/haco/constants.py index bac17ee..bc588f7 100644 --- a/haco/constants.py +++ b/haco/constants.py @@ -1,5 +1,19 @@ +import os import string +from pathlib import Path CHARS_ALLOWED = string.ascii_lowercase + string.digits SEPS_ALLOWED = '_- ' BRANCH = 'release' + +CONFIGS_PATH = Path(os.environ['HACO_CONFIGS_PATH']) +OPTIONS_PATH = Path(os.environ['HACO_OPTIONS_PATH']) +MQTT_PASSWORD = os.environ['MQTT_PASSWORD'] +MQTT_HOST = os.environ['MQTT_HOST'] +MQTT_PORT = int(os.environ['MQTT_PORT']) +MQTT_USERNAME = os.environ['MQTT_USERNAME'] + +if (CONFIGS_PATH / '.debug').exists(): + LOG_LEVEL = 'DEBUG' +else: + LOG_LEVEL = os.environ.get('HACO_LOG_LEVEL', 'INFO') diff --git a/haco/load_configs.py b/haco/load_configs.py index 9d93d77..c49967b 100644 --- a/haco/load_configs.py +++ b/haco/load_configs.py @@ -2,16 +2,13 @@ from importlib import reload import importlib.util import json -import os from pathlib import Path from haco import tools +from haco.constants import CONFIGS_PATH, OPTIONS_PATH from haco.control import Control from haco.device import Device -CONFIGS_PATH = Path(os.environ['HACO_CONFIGS_PATH']) -OPTIONS_PATH = Path(os.environ['HACO_OPTIONS_PATH']) - def load_json(file_path): with open(file_path, 'r') as json_file: diff --git a/haco/mqtt.py b/haco/mqtt.py index 851a109..8cd230c 100644 --- a/haco/mqtt.py +++ b/haco/mqtt.py @@ -1,19 +1,14 @@ import aiomqtt import asyncio import json -import os from pathlib import Path from haco import constants, tools +from haco.constants import MQTT_PASSWORD, MQTT_HOST, MQTT_PORT, MQTT_USERNAME from haco.device import Device from haco.load_configs import load_devices from haco.tools import log_received -MQTT_PASSWORD = os.environ['MQTT_PASSWORD'] -MQTT_HOST = os.environ['MQTT_HOST'] -MQTT_PORT = int(os.environ['MQTT_PORT']) -MQTT_USERNAME = os.environ['MQTT_USERNAME'] - async def listen(client, devices): TOPIC_ANNOUNCE = f"haco/{constants.BRANCH}/+/announce" diff --git a/haco/tools.py b/haco/tools.py index c24d237..6d9e9fe 100644 --- a/haco/tools.py +++ b/haco/tools.py @@ -1,13 +1,11 @@ import hashlib import logging -import os from haco import constants, tuya from haco.tasmota import Tasmota -LOG_LEVEL = os.environ.get('HACO_LOG_LEVEL', 'INFO') - -logging.basicConfig(level=LOG_LEVEL, format='%(asctime)s %(levelname)-8s %(message)s', datefmt='%Y-%m-%d %H:%M:%S') +logging.basicConfig(level=constants.LOG_LEVEL, format='%(asctime)s %(levelname)-8s %(message)s', + datefmt='%Y-%m-%d %H:%M:%S') logger = logging.getLogger(__name__) From 726cb3fc49c5e1df1698cf8659f7fe1200f899fe Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Fri, 1 Sep 2023 19:22:35 +0000 Subject: [PATCH 035/183] Increment version number to 0.0.13 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index 9ba0f8d..dd79821 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.12' +var VERSION='0.0.13' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 3aaf3fe..0c55c52 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.12 +version: 0.0.13 diff --git a/haco/version b/haco/version index 9bbaee4..2e60e2a 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.12 \ No newline at end of file +0.0.13 \ No newline at end of file From 747fca5ab1f1b2fd15cf6c8cabd24f180be81ee1 Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Sat, 2 Sep 2023 12:09:52 +0000 Subject: [PATCH 036/183] Increment version number to 0.0.14 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index dd79821..a318038 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.13' +var VERSION='0.0.14' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 0c55c52..fd15bc8 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.13 +version: 0.0.14 diff --git a/haco/version b/haco/version index 2e60e2a..1111c9c 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.13 \ No newline at end of file +0.0.14 \ No newline at end of file From 33ea83362d6d260214b7c322312a1d3fba9cc7a0 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sat, 2 Sep 2023 13:20:55 +0100 Subject: [PATCH 037/183] Refine logging, sanitized name separators --- haco/constants.py | 2 +- haco/mqtt.py | 2 +- haco/tools.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/haco/constants.py b/haco/constants.py index bc588f7..474625d 100644 --- a/haco/constants.py +++ b/haco/constants.py @@ -3,7 +3,7 @@ import string from pathlib import Path CHARS_ALLOWED = string.ascii_lowercase + string.digits -SEPS_ALLOWED = '_- ' +SEPS = '_- /' BRANCH = 'release' CONFIGS_PATH = Path(os.environ['HACO_CONFIGS_PATH']) diff --git a/haco/mqtt.py b/haco/mqtt.py index 8cd230c..479d067 100644 --- a/haco/mqtt.py +++ b/haco/mqtt.py @@ -36,7 +36,7 @@ async def listen(client, devices): break if not device: - msg = f'Got announce from device with no config: Hostname: {data_announce["hostname"]} MAC:{data_announce["mac"]}. Publishing config data.' + msg = f"""Found device with no configuration module assigned. Assign one in Add-On Configuration: "{data_announce["device_name"]}" Hostname: {data_announce["hostname"]} {data_announce["hostname"]} MAC:{data_announce["mac"]}.""" tools.logger.info(msg) continue diff --git a/haco/tools.py b/haco/tools.py index 6d9e9fe..48a086a 100644 --- a/haco/tools.py +++ b/haco/tools.py @@ -65,7 +65,7 @@ def sanitize_name(s, sep='-'): chars = [] for c in s.lower(): - if c in constants.SEPS_ALLOWED: + if c in constants.SEPS: chars.append(sep) elif c in constants.CHARS_ALLOWED: chars.append(c) From a405c03c31605acc976e20dfd45f88dc60041ace Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sat, 2 Sep 2023 13:21:04 +0100 Subject: [PATCH 038/183] Fix README links --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 32f5a89..c64968a 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,8 @@ Blueprints, Helpers and Templates (on the Home Assistant side). You can see how much work creating such guides involves by seeing how it was [heroically undertaken by Blakadder](https://blakadder.com/proscenic-in-home-assistant/), as -compared with the [full `haco`-based equivalent](/configs/proscenic_t21.py). +compared with +the [full `haco`-based equivalent](https://github.com/fmtr/haco/blob/release/haco/configs/proscenic_t21.py). With `haco`, on the other hand, the thorny parts of the initial setup are abstracted away and your final configuration can often be shared via a single script. Below is a list of some of the tasks that `haco` @@ -165,7 +166,8 @@ Whichever type you use, assigning them to a device is done as we saw above. ### Built-In Modules `haco` ships with a small number of built-in configurations. These can be found in -the [configs directory](tree/release/haco/configs) in this repo. But in the likely event that your device hasn't already +the [configs directory](https://github.com/fmtr/haco/blob/release/haco/configs) in this repo. But in the likely event +that your device hasn't already been added, you'll need to define your own. :information_source: The aim is to expand the number of built-in configurations over time. So if you define your own ( From 5019f6376a54dcbb2ab3bdc6bc9d9ead4056f0bc Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Sat, 2 Sep 2023 12:22:00 +0000 Subject: [PATCH 039/183] Increment version number to 0.0.15 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index a318038..352cc36 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.14' +var VERSION='0.0.15' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index fd15bc8..4fa8aa4 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.14 +version: 0.0.15 diff --git a/haco/version b/haco/version index 1111c9c..9beca35 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.14 \ No newline at end of file +0.0.15 \ No newline at end of file From 30bc6f94fe79ee2cfaddfdad8eead589c4a8c9a2 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 5 Sep 2023 14:46:43 +0100 Subject: [PATCH 040/183] Implement Update control --- haco/__init__.py | 2 ++ haco/update.py | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 haco/update.py diff --git a/haco/__init__.py b/haco/__init__.py index 825ad5f..2ea5f09 100644 --- a/haco/__init__.py +++ b/haco/__init__.py @@ -5,6 +5,7 @@ from .pulldown import Select from .sensor import Sensor from .switch import Switch from .tasmota import Tasmota +from .update import Update __all__ = [ "Button", @@ -13,5 +14,6 @@ __all__ = [ "Tasmota", "Number", "Switch", + "Update", "tuya" ] diff --git a/haco/update.py b/haco/update.py new file mode 100644 index 0000000..79800b5 --- /dev/null +++ b/haco/update.py @@ -0,0 +1,41 @@ +from haco.control import Control +from haco.schema import Schema, Capability, AnnounceTopic, Tasmota, HomeAssistant + + +class Update(Control): + NAME = 'update' + + @classmethod + def get_schema(cls): + schema = Schema( + capabilities=[ + Capability( + name='state', + ha=HomeAssistant(announce_data=AnnounceTopic(key='{io_ha}_topic')), + tamota=Tasmota(announce_data=AnnounceTopic(key='{io_ha}_topic')) + ), + Capability( + name='latest_version', + ha=None, + tamota=Tasmota(announce_data=AnnounceTopic(key='{capability}_topic')) + ) + ] + ) + return schema + + # def init(name, entity_id, icon, temperature_unit, temperature_range, humidity_range, modes, preset_modes, fan_modes, swing_modes, precision, callbacks) + + def __init__(self, name=None, icon=None, release_url=None, entity_picture=None): + self.release_url = release_url + self.entity_picture = entity_picture + + super().__init__(name, icon=icon) + + def get_config_ha_ex(self): + data = { + 'entity_picture': self.entity_picture, + 'payload_install': 'INSTALL', + 'release_url': self.release_url + } + + return data From 5ea9c99b1538683b13396cfc683937c4c6d0c881 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 5 Sep 2023 14:47:20 +0100 Subject: [PATCH 041/183] Fix unused argument error message --- haco/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haco/schema.py b/haco/schema.py index 362eb1d..d55d853 100644 --- a/haco/schema.py +++ b/haco/schema.py @@ -240,7 +240,7 @@ class Tasmota(Platform): extra_args = set(data.keys()) - set(sigs.keys()) for arg in extra_args: - msg = f'Callback {self.callback.function_name} got argument ({arg}={extra_args[arg]}) not in callback function. Will be ignored.' + msg = f'Callback {self.callback.function_name} got argument ({arg}={data[arg]}) not in callback function. Will be ignored.' logging.warning(msg) data.pop(arg) From 0ace60baad52a99e925dfdf07e91566e79818593 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 5 Sep 2023 14:49:00 +0100 Subject: [PATCH 042/183] Fix Tasmota crash: auto-defer callbacks --- berry/haco.be | 7 +++---- berry/haco_autoexec.be | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/berry/haco.be b/berry/haco.be index 40caab3..6310045 100644 --- a/berry/haco.be +++ b/berry/haco.be @@ -263,7 +263,7 @@ class Daemon if self.config_id==nil var rule_control=tools.callbacks.MqttSubscription( self.TOPIC_CONTROL, - /value,data->self.handle_control_message(value,data) + /value,data->tasmota.set_timer(0,/->self.handle_control_message(value,data)) ) self.registry_daemon.add(rule_control) end @@ -312,11 +312,10 @@ class Daemon function=tools.compile.evaluate(data['function']) else logger.error(string.format('Using default function for %s',trigger)) - function=/value data->{'value':value,'data':data} + function=/value,data->{'value':value,'data':data} end - - return callback_type(trigger,/value data->self.publish_output(function,value,data,topic)) + return callback_type(trigger,/value,data->tasmota.set_timer(0,/->self.publish_output(function,value,data,topic))) end diff --git a/berry/haco_autoexec.be b/berry/haco_autoexec.be index bdcb1fe..4d0f0ad 100644 --- a/berry/haco_autoexec.be +++ b/berry/haco_autoexec.be @@ -5,6 +5,8 @@ def autoexec(metadata) haco.daemon=haco.Daemon() + #haco.daemon.registry_daemon.remove_all() + end var mod = module("haco_autoexec") From afa30b72b495cb80c0baf5fd0fcbc3fb18b00e97 Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Tue, 5 Sep 2023 14:06:41 +0000 Subject: [PATCH 043/183] Increment version number to 0.0.16 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index 352cc36..565f359 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.15' +var VERSION='0.0.16' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 4fa8aa4..e8590bd 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.15 +version: 0.0.16 diff --git a/haco/version b/haco/version index 9beca35..e484aaf 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.15 \ No newline at end of file +0.0.16 \ No newline at end of file From 08097f816cc807408e7a97272467eec0fa36f8be Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 5 Sep 2023 15:49:45 +0100 Subject: [PATCH 044/183] Implement Response object --- haco/__init__.py | 2 ++ haco/callback.py | 6 ++++++ haco/control.py | 6 ++++++ haco/schema.py | 11 ++++++++--- haco/tools.py | 17 +++++++++++++++++ 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/haco/__init__.py b/haco/__init__.py index 2ea5f09..e2c345f 100644 --- a/haco/__init__.py +++ b/haco/__init__.py @@ -1,5 +1,6 @@ from haco import tuya from .button import Button +from .callback import Response from .number import Number from .pulldown import Select from .sensor import Sensor @@ -15,5 +16,6 @@ __all__ = [ "Number", "Switch", "Update", + "Response", "tuya" ] diff --git a/haco/callback.py b/haco/callback.py index 7f8bb1d..dab8018 100644 --- a/haco/callback.py +++ b/haco/callback.py @@ -107,3 +107,9 @@ class Callback: if self.platform == schema.Tasmota.PLATFORM: if not self.trigger: raise ValueError(f'Callback "{self.function_name}" must have a trigger.') + + +class Response: + def __init__(self, value=None, send=True): + self.value = value + self.send = send diff --git a/haco/control.py b/haco/control.py index 20bb0b8..4aa9551 100644 --- a/haco/control.py +++ b/haco/control.py @@ -101,6 +101,12 @@ class Control: platform = self.schema.get(capability_id).get(platform_id) output = platform.handle(message) + + if output == 'DO_NOT_SEND': + logging.warning( + f'Topic {message.topic.value} callback responded with send=False. Will not publish response.') + return + topic = str(platform.get_topic_publish()) await log_publish(client, topic, output) diff --git a/haco/schema.py b/haco/schema.py index d55d853..e3089d0 100644 --- a/haco/schema.py +++ b/haco/schema.py @@ -4,7 +4,7 @@ import typing from pathlib import Path from typing import List -from haco import tools, constants +from haco import tools, constants, callback DEVICE = 'development-eth' CONTROL = 'DEVELOPMENT-DEHUMIDIFIER' @@ -108,10 +108,15 @@ class Platform: payload_str = message.payload.decode('utf-8') payload = self.deserialize(payload_str) - output_raw = self.get_callback_output(payload) + response = self.get_callback_output(payload) - output = self.serialize(self.convert_out(output_raw)) + if type(response) is not callback.Response: + response = callback.Response(value=response) + if not response.send: + return 'DO_NOT_SEND' + + output = self.serialize(self.convert_out(response.value)) return output def get_callback_output(self, data): diff --git a/haco/tools.py b/haco/tools.py index 48a086a..a2b3c73 100644 --- a/haco/tools.py +++ b/haco/tools.py @@ -99,3 +99,20 @@ def hash_string(input_string, size=16): hash_result = hash_object.hexdigest()[:size] return hash_result + + +def get_latest(org, repo): + import requests + url = f"https://api.github.com/repos/{org}/{repo}/releases/latest" + + headers = { + 'Accept': 'application/vnd.github+json', + 'X-GitHub-Api-Version': '2022-11-28' + } + + response = requests.request("GET", url, headers=headers) + response_json = response.json() + + tag = response_json.get('tag_name') + + return tag From 988a3f9f4f14aed3e6f35d8bbaa505dd7a748da0 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 6 Sep 2023 14:15:44 +0100 Subject: [PATCH 045/183] Add Tasmota updater prefab, send callback IDs to Tasmota --- berry/haco.be | 7 +++++- haco/__init__.py | 5 ++++ haco/configs/development.py | 13 ++++++----- haco/configs/proscenic_t21.py | 3 +++ haco/debugging.py | 43 ++++++++++++++++++++++++++++++++++- haco/schema.py | 15 ++++++++++-- setup.py | 3 ++- 7 files changed, 78 insertions(+), 11 deletions(-) diff --git a/berry/haco.be b/berry/haco.be index 6310045..3f79d22 100644 --- a/berry/haco.be +++ b/berry/haco.be @@ -304,6 +304,7 @@ class Daemon var callback_type=CALLBACK_MAP[data.find('type', classname(tools.callbacks.Rule))] var topic=data['topic'] var trigger=data['trigger'] + var id=data['id'] var function @@ -315,7 +316,11 @@ class Daemon function=/value,data->{'value':value,'data':data} end - return callback_type(trigger,/value,data->tasmota.set_timer(0,/->self.publish_output(function,value,data,topic))) + return callback_type( + trigger, + /value,data->tasmota.set_timer(0,/->self.publish_output(function,value,data,topic)), + id + ) end diff --git a/haco/__init__.py b/haco/__init__.py index e2c345f..615f096 100644 --- a/haco/__init__.py +++ b/haco/__init__.py @@ -1,11 +1,13 @@ from haco import tuya from .button import Button from .callback import Response +from .climate import Climate from .number import Number from .pulldown import Select from .sensor import Sensor from .switch import Switch from .tasmota import Tasmota +from .text import Text, Password from .update import Update __all__ = [ @@ -15,7 +17,10 @@ __all__ = [ "Tasmota", "Number", "Switch", + "Text", + "Password", "Update", + "Climate", "Response", "tuya" ] diff --git a/haco/configs/development.py b/haco/configs/development.py index 4fd0197..2293e3f 100644 --- a/haco/configs/development.py +++ b/haco/configs/development.py @@ -1,9 +1,5 @@ -from haco.climate import Climate -from haco.number import Number -from haco.pulldown import Select -from haco.sensor import Sensor -from haco.tasmota import Tasmota -from haco.text import Text, Password +from haco import Number, Tasmota, Select, Sensor, Text, Password, Climate + number = Number( 'Dev Number Test Control', @@ -169,3 +165,8 @@ def ha(value: str) -> Tasmota[str, 'tasmota.cmd("var14 "+str(value))']: @password.callback('var14#state') def tasmota(value: str): return value + + +from haco.debugging import get_tasmota_updater + +update = get_tasmota_updater() diff --git a/haco/configs/proscenic_t21.py b/haco/configs/proscenic_t21.py index 14bab99..4d22ca5 100644 --- a/haco/configs/proscenic_t21.py +++ b/haco/configs/proscenic_t21.py @@ -1,6 +1,7 @@ import math from haco import Tasmota, Number, Sensor, Select, Switch, tuya +from haco.debugging import get_tasmota_updater from haco.tools import add_tuya_io OPTIONS = ['Default', 'Fries', 'Shrimp', 'Pizza', 'Chicken', 'Fish', 'Steak', 'Cake', 'Bacon', 'Preheat', 'Custom'] @@ -130,4 +131,6 @@ keep_warm_time = Number( add_tuya_io(keep_warm_time, int, 2, 105) +update = get_tasmota_updater() + DEVICE_CONFIG = {'run_config_post': f'def () return tasmota.cmd("TuyaSend0") end'} diff --git a/haco/debugging.py b/haco/debugging.py index 1fc78f4..8ebd201 100644 --- a/haco/debugging.py +++ b/haco/debugging.py @@ -1,8 +1,10 @@ +import random from typing import Any -from haco import trigger +from haco import trigger, Update, Response from haco.sensor import Sensor from haco.tasmota import Tasmota +from haco.tools import get_latest def get_memory_sensor(): @@ -13,3 +15,42 @@ def get_memory_sensor(): return value.get('heap_free', 'unknown') return memory_sensor + + +def get_tasmota_updater(): + DEFAULT_OTA_URL = 'https://ota.tasmota.com/tasmota32/release/tasmota32.bin' + + once_daily = trigger.Cron(f"0 {random.randint(0, 59)} {random.randint(0, 23)} * * *") + + update = Update('Update Tasmota') + + @update.callback() + def ha(value) -> Tasmota[str, 'tasmota.cmd("upgrade 1")']: + return value + + @update.callback(trigger=once_daily) + def latest_version_tasmota(value): + tag = get_latest('arendst', 'Tasmota') + + if not tag: + return Response(send=False) + + tag = tag.lstrip('v') + + return tag + + @update.callback(trigger=once_daily) + def tasmota(value: Tasmota[Any, 'tasmota.cmd("status 2")'], otaurl: Tasmota[Any, 'tasmota.cmd("OtaUrl")']): + + if otaurl['OtaUrl'] != DEFAULT_OTA_URL: + return Response(send=False) + + version = value.get('StatusFWR', {}).get('Version') or '' + version = version.removesuffix('(tasmota32)') + + if not version: + return Response(send=False) + + return version + + return update diff --git a/haco/schema.py b/haco/schema.py index e3089d0..04002a9 100644 --- a/haco/schema.py +++ b/haco/schema.py @@ -79,6 +79,15 @@ class Platform: self.callback = None + @property + def callback_id(self): + return ( + Path() / + self.capability.schema.control.NAME / + self.capability.schema.control.name_sanitized / + self.capability.name + ) + @property def callback_function_name(self): return f'{self.capability.alias}_{self.PLATFORM}' @@ -220,7 +229,8 @@ class HomeAssistant(Platform): 'topic': None, 'trigger': str(trigger), 'function': self.callback.function_tasmota, - 'type': 'MqttSubscription' + 'type': 'MqttSubscription', + 'id': str(self.callback_id) } return config @@ -290,7 +300,8 @@ class Tasmota(Platform): 'topic': str(self.get_topic_subscription()), 'trigger': self.callback.trigger, 'function': self.callback.function_tasmota, - 'type': self.callback.type_id + 'type': self.callback.type_id, + 'id': str(self.callback_id) } return config diff --git a/setup.py b/setup.py index 3a8167d..abed16a 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,8 @@ setup( }, install_requires=[ 'aiomqtt', - 'pyyaml' + 'pyyaml', + 'requests' ], extras_require={ 'tasmota': [ From 85638bc339a357e3b1b251c5df8b5d918dcb8ca3 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 6 Sep 2023 20:05:25 +0100 Subject: [PATCH 046/183] Rename default capability name from state to default --- haco/button.py | 4 ++-- haco/constants.py | 2 ++ haco/control.py | 6 +++--- haco/sensor.py | 4 ++-- haco/update.py | 3 ++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/haco/button.py b/haco/button.py index 0c288a7..9572d78 100644 --- a/haco/button.py +++ b/haco/button.py @@ -1,4 +1,4 @@ -from haco import schema +from haco import schema, constants from haco.control import Control @@ -10,7 +10,7 @@ class Button(Control): return schema.Schema( capabilities=[ schema.Capability( - name='state', + name=constants.DEFAULT, ha=schema.HomeAssistant(announce_data=schema.AnnounceTopic(key='{io_ha}_topic')), tamota=None ) diff --git a/haco/constants.py b/haco/constants.py index 474625d..38cbfcc 100644 --- a/haco/constants.py +++ b/haco/constants.py @@ -6,6 +6,8 @@ CHARS_ALLOWED = string.ascii_lowercase + string.digits SEPS = '_- /' BRANCH = 'release' +DEFAULT = 'default' + CONFIGS_PATH = Path(os.environ['HACO_CONFIGS_PATH']) OPTIONS_PATH = Path(os.environ['HACO_OPTIONS_PATH']) MQTT_PASSWORD = os.environ['MQTT_PASSWORD'] diff --git a/haco/control.py b/haco/control.py index 4aa9551..a7f5a2f 100644 --- a/haco/control.py +++ b/haco/control.py @@ -1,7 +1,7 @@ import logging from functools import partial -from haco import schema, tools +from haco import schema, tools, constants from haco.callback import Callback from haco.schema import Schema, Platform, Tasmota, HomeAssistant, AnnounceTopic, Capability from haco.tools import log_publish @@ -17,7 +17,7 @@ class Control: schema = Schema( capabilities=[ Capability( - name='state', + name=constants.DEFAULT, ha=HomeAssistant(announce_data=AnnounceTopic(key='{io_ha}_topic')), tamota=Tasmota(announce_data=AnnounceTopic(key='{io_ha}_topic')) ) @@ -49,7 +49,7 @@ class Control: def add_callback(self, trigger, function): if (function_name := function.__name__) in {Tasmota.PLATFORM, HomeAssistant.PLATFORM}: - function_name = f'state_{function_name}' + function_name = f'{constants.DEFAULT}_{function_name}' callback_names = self.schema.get_callback_function_names() diff --git a/haco/sensor.py b/haco/sensor.py index e27aa09..4d7fbfa 100644 --- a/haco/sensor.py +++ b/haco/sensor.py @@ -1,4 +1,4 @@ -from haco import schema +from haco import schema, constants from haco.control import Control from haco.data.type_sensor import DeviceClassSensor @@ -16,7 +16,7 @@ class Sensor(Control): return schema.Schema( capabilities=[ schema.Capability( - name='state', + name=constants.DEFAULT, ha=None, tamota=schema.Tasmota(announce_data=schema.AnnounceTopic(key='{io_ha}_topic')) ) diff --git a/haco/update.py b/haco/update.py index 79800b5..7617a98 100644 --- a/haco/update.py +++ b/haco/update.py @@ -1,3 +1,4 @@ +from haco import constants from haco.control import Control from haco.schema import Schema, Capability, AnnounceTopic, Tasmota, HomeAssistant @@ -10,7 +11,7 @@ class Update(Control): schema = Schema( capabilities=[ Capability( - name='state', + name=constants.DEFAULT, ha=HomeAssistant(announce_data=AnnounceTopic(key='{io_ha}_topic')), tamota=Tasmota(announce_data=AnnounceTopic(key='{io_ha}_topic')) ), From 470734c6a352a36aa8ed5fdfe1f2a7d53b134a12 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 6 Sep 2023 20:37:04 +0100 Subject: [PATCH 047/183] Set default capability name and fix typing --- haco/button.py | 5 ++--- haco/climate.py | 6 +++--- haco/constants.py | 2 +- haco/control.py | 5 ++--- haco/schema.py | 11 +++++++++-- haco/sensor.py | 5 ++--- haco/update.py | 6 ++---- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/haco/button.py b/haco/button.py index 9572d78..d1b1fbb 100644 --- a/haco/button.py +++ b/haco/button.py @@ -1,4 +1,4 @@ -from haco import schema, constants +from haco import schema from haco.control import Control @@ -10,9 +10,8 @@ class Button(Control): return schema.Schema( capabilities=[ schema.Capability( - name=constants.DEFAULT, ha=schema.HomeAssistant(announce_data=schema.AnnounceTopic(key='{io_ha}_topic')), - tamota=None + tasmota=None ) ] ) diff --git a/haco/climate.py b/haco/climate.py index 0387355..e02bf4f 100644 --- a/haco/climate.py +++ b/haco/climate.py @@ -41,18 +41,18 @@ class Climate(Control): Capability( name='current_humidity', ha=None, - tamota=Tasmota(announce_data=AnnounceTopic(key='{capability}_topic')) + tasmota=Tasmota(announce_data=AnnounceTopic(key='{capability}_topic')) ), Capability( name='current_temperature', ha=None, - tamota=Tasmota(announce_data=AnnounceTopic(key='{capability}_topic')) + tasmota=Tasmota(announce_data=AnnounceTopic(key='{capability}_topic')) ), Capability( name='action', type=str, ha=None, - tamota=Tasmota(announce_data=AnnounceTopic(key='{capability}_topic')) + tasmota=Tasmota(announce_data=AnnounceTopic(key='{capability}_topic')) ) ] ) diff --git a/haco/constants.py b/haco/constants.py index 38cbfcc..0c4b0ed 100644 --- a/haco/constants.py +++ b/haco/constants.py @@ -6,7 +6,7 @@ CHARS_ALLOWED = string.ascii_lowercase + string.digits SEPS = '_- /' BRANCH = 'release' -DEFAULT = 'default' +CAPABILITY_DEFAULT = 'default' CONFIGS_PATH = Path(os.environ['HACO_CONFIGS_PATH']) OPTIONS_PATH = Path(os.environ['HACO_OPTIONS_PATH']) diff --git a/haco/control.py b/haco/control.py index a7f5a2f..1a1c49d 100644 --- a/haco/control.py +++ b/haco/control.py @@ -17,9 +17,8 @@ class Control: schema = Schema( capabilities=[ Capability( - name=constants.DEFAULT, ha=HomeAssistant(announce_data=AnnounceTopic(key='{io_ha}_topic')), - tamota=Tasmota(announce_data=AnnounceTopic(key='{io_ha}_topic')) + tasmota=Tasmota(announce_data=AnnounceTopic(key='{io_ha}_topic')) ) ] ) @@ -49,7 +48,7 @@ class Control: def add_callback(self, trigger, function): if (function_name := function.__name__) in {Tasmota.PLATFORM, HomeAssistant.PLATFORM}: - function_name = f'{constants.DEFAULT}_{function_name}' + function_name = f'{constants.CAPABILITY_DEFAULT}_{function_name}' callback_names = self.schema.get_callback_function_names() diff --git a/haco/schema.py b/haco/schema.py index 04002a9..9f8744e 100644 --- a/haco/schema.py +++ b/haco/schema.py @@ -313,13 +313,20 @@ class Default: class Capability: - def __init__(self, name, type=ControlType, tamota: Tasmota = Default, ha: HomeAssistant = Default, alias=None): + def __init__( + self, + name: str = constants.CAPABILITY_DEFAULT, + type=ControlType, + tasmota: typing.Optional[Tasmota] = Default, + ha: typing.Optional[HomeAssistant] = Default, + alias: typing.Optional[str] = None + ): self.name = name self.alias = alias or name self.type = type self.schema = None - self.tasmota = tamota if tamota is not Default else Tasmota() + self.tasmota = tasmota if tasmota is not Default else Tasmota() self.ha = ha if ha is not Default else HomeAssistant() self.platforms = [io for io in {self.tasmota, self.ha} if io] diff --git a/haco/sensor.py b/haco/sensor.py index 4d7fbfa..2a1c26e 100644 --- a/haco/sensor.py +++ b/haco/sensor.py @@ -1,4 +1,4 @@ -from haco import schema, constants +from haco import schema from haco.control import Control from haco.data.type_sensor import DeviceClassSensor @@ -16,9 +16,8 @@ class Sensor(Control): return schema.Schema( capabilities=[ schema.Capability( - name=constants.DEFAULT, ha=None, - tamota=schema.Tasmota(announce_data=schema.AnnounceTopic(key='{io_ha}_topic')) + tasmota=schema.Tasmota(announce_data=schema.AnnounceTopic(key='{io_ha}_topic')) ) ] ) diff --git a/haco/update.py b/haco/update.py index 7617a98..e5c6dae 100644 --- a/haco/update.py +++ b/haco/update.py @@ -1,4 +1,3 @@ -from haco import constants from haco.control import Control from haco.schema import Schema, Capability, AnnounceTopic, Tasmota, HomeAssistant @@ -11,14 +10,13 @@ class Update(Control): schema = Schema( capabilities=[ Capability( - name=constants.DEFAULT, ha=HomeAssistant(announce_data=AnnounceTopic(key='{io_ha}_topic')), - tamota=Tasmota(announce_data=AnnounceTopic(key='{io_ha}_topic')) + tasmota=Tasmota(announce_data=AnnounceTopic(key='{io_ha}_topic')) ), Capability( name='latest_version', ha=None, - tamota=Tasmota(announce_data=AnnounceTopic(key='{capability}_topic')) + tasmota=Tasmota(announce_data=AnnounceTopic(key='{capability}_topic')) ) ] ) From 257b68d8d53919e79e2f753d5adac0958638e9e9 Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Thu, 7 Sep 2023 14:23:07 +0000 Subject: [PATCH 048/183] Increment version number to 0.0.17 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index 565f359..e69324e 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.16' +var VERSION='0.0.17' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index e8590bd..35041f3 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.16 +version: 0.0.17 diff --git a/haco/version b/haco/version index e484aaf..927734f 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.16 \ No newline at end of file +0.0.17 \ No newline at end of file From 613006bf91ebf924bb3ec6388178fd507ab5c0d1 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 8 Sep 2023 13:22:09 +0100 Subject: [PATCH 049/183] Implement Fan object --- haco/__init__.py | 2 ++ haco/fan.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 haco/fan.py diff --git a/haco/__init__.py b/haco/__init__.py index 615f096..8787f1e 100644 --- a/haco/__init__.py +++ b/haco/__init__.py @@ -2,6 +2,7 @@ from haco import tuya from .button import Button from .callback import Response from .climate import Climate +from .fan import Fan from .number import Number from .pulldown import Select from .sensor import Sensor @@ -21,6 +22,7 @@ __all__ = [ "Password", "Update", "Climate", + "Fan", "Response", "tuya" ] diff --git a/haco/fan.py b/haco/fan.py new file mode 100644 index 0000000..11ecc22 --- /dev/null +++ b/haco/fan.py @@ -0,0 +1,56 @@ +from haco import constants +from haco.control import Control +from haco.schema import Schema, Capability, AnnounceTopic, Tasmota, ControlType, HomeAssistant +from haco.tools import get_range_pair, invert_bool + + +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 4744efeb093ca0bd62be0e2c1a23bd3bf06f86a0 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 8 Sep 2023 13:22:38 +0100 Subject: [PATCH 050/183] Refine proscenic_t21 config --- haco/configs/proscenic_t21.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/haco/configs/proscenic_t21.py b/haco/configs/proscenic_t21.py index 4d22ca5..0832489 100644 --- a/haco/configs/proscenic_t21.py +++ b/haco/configs/proscenic_t21.py @@ -37,6 +37,7 @@ cooking_time = Number( name='Cooking Time', number_range=range(1, 60), uom=Number.UOM.TIME_MINUTES, + mode='box', icon='timer' ) @@ -106,6 +107,7 @@ delay_time = Number( name='Delay Time', number_range=range(0, 720), uom=Sensor.UOM.TIME_MINUTES, + mode='box', icon='timer-pause' ) @@ -126,7 +128,8 @@ keep_warm_time = Number( name='Keep Warm Time', number_range=range(0, 120), uom=Sensor.UOM.TIME_MINUTES, - icon='timer-sync' + icon='timer-sync', + mode='box', ) add_tuya_io(keep_warm_time, int, 2, 105) From 4db6b29b2215f71877d5da6829af089944623396 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 8 Sep 2023 13:23:50 +0100 Subject: [PATCH 051/183] Auto-reconnect MQTT --- haco/constants.py | 3 +++ haco/control.py | 7 ++++--- haco/mqtt.py | 15 +++++++++++---- haco/schema.py | 3 --- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/haco/constants.py b/haco/constants.py index 0c4b0ed..4075364 100644 --- a/haco/constants.py +++ b/haco/constants.py @@ -7,6 +7,9 @@ SEPS = '_- /' BRANCH = 'release' CAPABILITY_DEFAULT = 'default' +RECONNECT_DELAY_SEC = 5 +ON = 'ON' +OFF = 'OFF' CONFIGS_PATH = Path(os.environ['HACO_CONFIGS_PATH']) OPTIONS_PATH = Path(os.environ['HACO_OPTIONS_PATH']) diff --git a/haco/control.py b/haco/control.py index 1a1c49d..052d737 100644 --- a/haco/control.py +++ b/haco/control.py @@ -1,7 +1,8 @@ import logging from functools import partial -from haco import schema, tools, constants +import haco.constants +from haco import tools, constants from haco.callback import Callback from haco.schema import Schema, Platform, Tasmota, HomeAssistant, AnnounceTopic, Capability from haco.tools import log_publish @@ -72,9 +73,9 @@ class Control: "unique_id": f"{self.device.name_sanitized}-{self.device.mac_short}-{self.name_sanitized}", "name": self.name, "availability_topic": f"tele/{self.device.topic}/LWT", - "payload_off": schema.OFF, + "payload_off": haco.constants.OFF, "payload_available": "Online", - "payload_on": schema.ON, + "payload_on": haco.constants.ON, "payload_not_available": "Offline", "force_update": True, "icon": self.icon, diff --git a/haco/mqtt.py b/haco/mqtt.py index 479d067..f1e8942 100644 --- a/haco/mqtt.py +++ b/haco/mqtt.py @@ -7,7 +7,7 @@ from haco import constants, tools from haco.constants import MQTT_PASSWORD, MQTT_HOST, MQTT_PORT, MQTT_USERNAME from haco.device import Device from haco.load_configs import load_devices -from haco.tools import log_received +from haco.tools import log_received, logger async def listen(client, devices): @@ -59,6 +59,13 @@ async def start_mqtt(): devices = load_devices() devices = {device.identifier: device for device in devices} - async with aiomqtt.Client(hostname=MQTT_HOST, port=MQTT_PORT, username=MQTT_USERNAME, - password=MQTT_PASSWORD) as client: - await asyncio.gather(listen(client, devices)) + while True: + client = aiomqtt.Client(hostname=MQTT_HOST, port=MQTT_PORT, username=MQTT_USERNAME, + password=MQTT_PASSWORD) + try: + async with client: + await asyncio.gather(listen(client, devices)) + except aiomqtt.MqttError: + msg = f"MQTT: Connection lost; Reconnecting in {constants.RECONNECT_DELAY_SEC} seconds ..." + logger.info(msg) + await asyncio.sleep(constants.RECONNECT_DELAY_SEC) diff --git a/haco/schema.py b/haco/schema.py index 9f8744e..b41e3c9 100644 --- a/haco/schema.py +++ b/haco/schema.py @@ -9,9 +9,6 @@ from haco import tools, constants, callback DEVICE = 'development-eth' CONTROL = 'DEVELOPMENT-DEHUMIDIFIER' -ON = 'ON' -OFF = 'OFF' - class ControlType: ... From d5f49a7729decd7e490a74c0cf0efcc68690dea3 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 17 Sep 2023 14:00:25 +0100 Subject: [PATCH 052/183] Refactor Tasmota announce data into object --- berry/haco.be | 2 ++ berry/manifest.yaml | 4 ++++ haco/control.py | 2 +- haco/device.py | 41 +++++++++++++++++++------------------- haco/device_data.py | 48 +++++++++++++++++++++++++++++++++++++++++++++ haco/mqtt.py | 20 +++++++++++-------- haco/schema.py | 3 ++- 7 files changed, 89 insertions(+), 31 deletions(-) create mode 100644 haco/device_data.py diff --git a/berry/haco.be b/berry/haco.be index 3f79d22..21951b1 100644 --- a/berry/haco.be +++ b/berry/haco.be @@ -230,6 +230,8 @@ class Daemon 'timestamp': tasmota.rtc(), 'config_id': self.config_id, 'topic': tools.mqtt.get_topic(), + 'prefix': tasmota.cmd('Prefix'), + 'fulltopic': tasmota.cmd('FullTopic')['FullTopic'], 'device_name': tools.platform.get_device_name(), } end diff --git a/berry/manifest.yaml b/berry/manifest.yaml index 3187968..ead57de 100644 --- a/berry/manifest.yaml +++ b/berry/manifest.yaml @@ -26,3 +26,7 @@ patches: path: haco_version.be pattern: \bvar\s+VERSION\s*=\s*'{version}' +code_mask: | + import tools + downloader=tools.web.Downloader('{url}',nil,/->print(tasmota.cmd('restart 1'))) + diff --git a/haco/control.py b/haco/control.py index 052d737..b946d99 100644 --- a/haco/control.py +++ b/haco/control.py @@ -72,7 +72,7 @@ class Control: data = { "unique_id": f"{self.device.name_sanitized}-{self.device.mac_short}-{self.name_sanitized}", "name": self.name, - "availability_topic": f"tele/{self.device.topic}/LWT", + "availability_topic": str(self.device.data_announce.topic_lwt_prop), "payload_off": haco.constants.OFF, "payload_available": "Online", "payload_on": haco.constants.ON, diff --git a/haco/device.py b/haco/device.py index 679284a..294bc6c 100644 --- a/haco/device.py +++ b/haco/device.py @@ -4,40 +4,41 @@ from typing import List from haco import tools, constants from haco.control import Control +from haco.device_data import DeviceInfo from haco.tools import log_publish, split_into_chunks, log_subscribe class Device: def __init__(self, identifier, config_module, controls: List[Control], run_config_post=None): - self.name = None + self.config_module = config_module - self.topic = None - self.hostname = None - self.mac = None + self.identifier = identifier self.run_config_post = run_config_post self.controls = controls - self.config_id = None + for control in self.controls: control.device = self self.contols_dict = {control.name_sanitized: control for control in self.controls} self.get = self.contols_dict.get + self.data_announce = None + @property def name_sanitized(self): - return tools.sanitize_name(self.name) + return tools.sanitize_name(self.data_announce.name) @property def mac_short(self): - return self.mac.replace(':', '').lower() + return self.data_announce.mac.replace(':', '').lower() def get_config_ha(self): data_device = { - "connections": [["mac", self.mac]], - "identifiers": self.mac + "connections": [["mac", self.data_announce.mac]], + "identifiers": self.data_announce.mac } data = {} @@ -80,23 +81,23 @@ class Device: } - self.config_id = tools.hash_string(json.dumps(tasmota_config)) + self.data_announce.config_id = tools.hash_string(json.dumps(tasmota_config)) - tasmota_config['id'] = self.config_id + tasmota_config['id'] = self.data_announce.config_id tasmota_config_str = json.dumps(tasmota_config) - tasmota_config_topic = Path(f"haco/{constants.BRANCH}/{self.hostname}/config") + tasmota_config_topic = Path(f"haco/{constants.BRANCH}/{self.data_announce.hostname}/config") parts = split_into_chunks(tasmota_config_str, 750) for i, part in enumerate(parts): - part = json.dumps({"id": self.config_id, "data": part}) + part = json.dumps({"id": self.data_announce.config_id, "data": part}) if len(part) > 1200: raise ValueError(f'Config part too large.') await log_publish(client, str(tasmota_config_topic / str(i)), payload=part, retain=True) - payload_header = json.dumps({"size": len(parts), "id": self.config_id, 'force_update': True}) + payload_header = json.dumps({"size": len(parts), "id": self.data_announce.config_id, 'force_update': True}) await log_publish(client, str(tasmota_config_topic), payload=payload_header, retain=True) - payload_full = json.dumps({"size": len(parts), "id": self.config_id, "data": tasmota_config}) + payload_full = json.dumps({"size": len(parts), "id": self.data_announce.config_id, "data": tasmota_config}) await log_publish(client, str(tasmota_config_topic / 'full'), payload=payload_full, retain=True) async def do_subscriptions(self, client): @@ -104,13 +105,11 @@ class Device: for topic in data.keys(): await log_subscribe(client, str(topic)) - async def bind(self, client, data_announce): - msg = f'Found device with matching config {self.config_module.__name__}: Hostname: {data_announce["hostname"]} MAC:{self.mac}' + async def bind(self, client, data_announce: DeviceInfo): + msg = f'Found device with matching config {self.config_module.__name__}: Hostname: {data_announce.hostname} MAC:{data_announce.mac}' tools.logger.info(msg) - self.name = data_announce['device_name'] - self.topic = data_announce['topic'] - self.hostname = data_announce['hostname'] - self.mac = data_announce['mac'] + + self.data_announce = data_announce await self.do_subscriptions(client) diff --git a/haco/device_data.py b/haco/device_data.py new file mode 100644 index 0000000..6da1c75 --- /dev/null +++ b/haco/device_data.py @@ -0,0 +1,48 @@ +from dataclasses import dataclass, field +from pathlib import Path +from typing import Dict + + +@dataclass +class DeviceInfo: + wifi: Dict[str, any] + device_name: str + fulltopic: str + hostname: str + mac: str + version: str + topic: str + config_id: str + eth: Dict[str, any] + timestamp: Dict[str, int] + prefix: Dict[str, str] + prefix_cmnd: str = field(init=False) + prefix_stat: str = field(init=False) + prefix_tele: str = field(init=False) + + name: str = field(init=False) + + def __post_init__(self): + # Unpack the 'prefix' argument into individual fields + self.prefix_cmnd = self.prefix['Prefix1'] + self.prefix_stat = self.prefix['Prefix2'] + self.prefix_tele = self.prefix['Prefix3'] + + # Replace placeholders in the fulltopic with actual values + self.fulltopic = self.fulltopic.replace('%topic%', self.topic) + + self.name = self.device_name + + @property + def identifiers(self): + return {self.wifi.get('mac'), self.eth.get('mac'), self.hostname, self.mac} + + @property + def topic_tele(self): + topic = Path(self.fulltopic.replace('%prefix%', self.prefix_tele)) + return topic + + @property + def topic_lwt_prop(self): + topic = self.topic_tele / 'LWT' + return topic diff --git a/haco/mqtt.py b/haco/mqtt.py index f1e8942..3aa406e 100644 --- a/haco/mqtt.py +++ b/haco/mqtt.py @@ -6,13 +6,14 @@ from pathlib import Path from haco import constants, tools from haco.constants import MQTT_PASSWORD, MQTT_HOST, MQTT_PORT, MQTT_USERNAME from haco.device import Device +from haco.device_data import DeviceInfo from haco.load_configs import load_devices from haco.tools import log_received, logger async def listen(client, devices): TOPIC_ANNOUNCE = f"haco/{constants.BRANCH}/+/announce" - await client.subscribe(TOPIC_ANNOUNCE) + await tools.log_subscribe(client, TOPIC_ANNOUNCE) async with client.messages() as messages: @@ -26,11 +27,9 @@ async def listen(client, devices): continue data_announce = json.loads(message.payload) + data_announce = DeviceInfo(**data_announce) - identifiers = {data_announce['wifi'].get('mac'), data_announce['eth'].get('mac'), - data_announce['hostname'], data_announce['mac']} - - for identifier in identifiers: + for identifier in data_announce.identifiers: device: Device = devices.get(identifier) if device: break @@ -40,16 +39,21 @@ async def listen(client, devices): tools.logger.info(msg) continue - if device.config_id and data_announce['config_id'] == device.config_id: - msg = f'Device "{device.name}" successfully configured. Hostname: {device.hostname} MAC:{device.mac}' + if device.data_announce and data_announce.config_id == device.data_announce.config_id: + msg = f'Device "{device.data_announce.name}" successfully configured. Hostname: {device.data_announce.hostname} MAC:{device.data_announce.mac}' tools.logger.info(msg) continue await device.bind(client, data_announce) - devices[device.hostname] = device + devices[device.data_announce.hostname] = device else: + + if message.topic.matches('haco/release/+/config/#'): + logger.error(f'Control code got config message. Do not know why.') + continue + _, _, device_name, _, control, capability_id, platform, io = Path(message.topic.value).parts device = devices[device_name] await device.get(control).process_message(client, capability_id, platform, message) diff --git a/haco/schema.py b/haco/schema.py index b41e3c9..e6679f2 100644 --- a/haco/schema.py +++ b/haco/schema.py @@ -378,7 +378,8 @@ class Schema: return names def get_path(self): - return Path(f"haco") / constants.BRANCH / self.control.device.hostname / 'control' / self.control.name_sanitized + return Path( + f"haco") / constants.BRANCH / self.control.device.data_announce.hostname / 'control' / self.control.name_sanitized def get_config_ha(self): data = {} From 82a264db358aab06331af3a5df1dd5c201034990 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 17 Sep 2023 14:02:12 +0100 Subject: [PATCH 053/183] Rename object to DeviceData --- haco/device.py | 4 ++-- haco/device_data.py | 2 +- haco/mqtt.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/haco/device.py b/haco/device.py index 294bc6c..08f18dc 100644 --- a/haco/device.py +++ b/haco/device.py @@ -4,7 +4,7 @@ from typing import List from haco import tools, constants from haco.control import Control -from haco.device_data import DeviceInfo +from haco.device_data import DeviceData from haco.tools import log_publish, split_into_chunks, log_subscribe @@ -105,7 +105,7 @@ class Device: for topic in data.keys(): await log_subscribe(client, str(topic)) - async def bind(self, client, data_announce: DeviceInfo): + async def bind(self, client, data_announce: DeviceData): msg = f'Found device with matching config {self.config_module.__name__}: Hostname: {data_announce.hostname} MAC:{data_announce.mac}' tools.logger.info(msg) diff --git a/haco/device_data.py b/haco/device_data.py index 6da1c75..58d0c31 100644 --- a/haco/device_data.py +++ b/haco/device_data.py @@ -4,7 +4,7 @@ from typing import Dict @dataclass -class DeviceInfo: +class DeviceData: wifi: Dict[str, any] device_name: str fulltopic: str diff --git a/haco/mqtt.py b/haco/mqtt.py index 3aa406e..46e1ca5 100644 --- a/haco/mqtt.py +++ b/haco/mqtt.py @@ -6,7 +6,7 @@ from pathlib import Path from haco import constants, tools from haco.constants import MQTT_PASSWORD, MQTT_HOST, MQTT_PORT, MQTT_USERNAME from haco.device import Device -from haco.device_data import DeviceInfo +from haco.device_data import DeviceData from haco.load_configs import load_devices from haco.tools import log_received, logger @@ -27,7 +27,7 @@ async def listen(client, devices): continue data_announce = json.loads(message.payload) - data_announce = DeviceInfo(**data_announce) + data_announce = DeviceData(**data_announce) for identifier in data_announce.identifiers: device: Device = devices.get(identifier) From 4c26b00c62c15e6e098d73857d8bf5061f86b8e2 Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Sun, 17 Sep 2023 13:04:17 +0000 Subject: [PATCH 054/183] Increment version number to 0.0.18 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index e69324e..2488fbd 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.17' +var VERSION='0.0.18' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 35041f3..bbbac21 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.17 +version: 0.0.18 diff --git a/haco/version b/haco/version index 927734f..a618622 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.17 \ No newline at end of file +0.0.18 \ No newline at end of file From adf8816a4e9ec4f97e79ab0acb2bb0474e33ae50 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 17 Sep 2023 14:22:47 +0100 Subject: [PATCH 055/183] Fix no configuration message --- haco/mqtt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haco/mqtt.py b/haco/mqtt.py index 46e1ca5..4363bd4 100644 --- a/haco/mqtt.py +++ b/haco/mqtt.py @@ -35,7 +35,7 @@ async def listen(client, devices): break if not device: - msg = f"""Found device with no configuration module assigned. Assign one in Add-On Configuration: "{data_announce["device_name"]}" Hostname: {data_announce["hostname"]} {data_announce["hostname"]} MAC:{data_announce["mac"]}.""" + msg = f"""Found device with no configuration module assigned. Assign one in Add-On Configuration: "{data_announce.name}" Hostname: {data_announce.hostname} MAC:{data_announce.mac}.""" tools.logger.info(msg) continue From cdacf80fc7ec282ce3079c802b18a8ca47478d77 Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Sun, 17 Sep 2023 13:23:36 +0000 Subject: [PATCH 056/183] Increment version number to 0.0.19 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index 2488fbd..1b2794a 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.18' +var VERSION='0.0.19' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index bbbac21..90a8ad5 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.18 +version: 0.0.19 diff --git a/haco/version b/haco/version index a618622..c5d4220 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.18 \ No newline at end of file +0.0.19 \ No newline at end of file From 7bee5d3da5a96773e3bb1f8430231460f5b80fea Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 1 Nov 2023 11:11:44 +0000 Subject: [PATCH 057/183] Add support for running as (non-Add-on) Docker and pre-built image --- .github/workflows/main.yml | 15 +++++++++++++++ Dockerfile | 2 +- haco/constants.py | 12 ++++++------ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6556dfc..2610b00 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,6 +30,13 @@ jobs: run: | pip install twine tappack + - name: Docker Login + env: + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} + run: | + echo $DOCKER_TOKEN | docker login --username $DOCKER_USER --password-stdin + - name: Increment Version run: | @@ -74,3 +81,11 @@ jobs: DATA="{\"destination\": \"${URL}\"}" curl --request POST --url https://api.rebrandly.com/v1/links/${LINK_ID} --header 'accept: application/json' --header "apikey: ${REBRANDLY_API_KEY}" --header 'content-type: application/json' --data "$DATA" &> /dev/null + - name: Build Docker + run: | + docker build . --build-arg TYPE=release --build-arg VERSION=${VERSION} --tag fmtr/${NAME}:v${VERSION} + docker tag fmtr/${NAME}:v${VERSION} fmtr/${NAME}:latest + + - name: Push Docker + run: | + docker push --all-tags fmtr/${NAME} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ad53ec5..54a891b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,6 @@ RUN if [ -z "$VERSION" ] ; then pip3 install haco ; else pip3 install haco==${VE FROM ${TYPE} as image -CMD haco +CMD haco-daemon diff --git a/haco/constants.py b/haco/constants.py index 4075364..3d659b2 100644 --- a/haco/constants.py +++ b/haco/constants.py @@ -11,12 +11,12 @@ RECONNECT_DELAY_SEC = 5 ON = 'ON' OFF = 'OFF' -CONFIGS_PATH = Path(os.environ['HACO_CONFIGS_PATH']) -OPTIONS_PATH = Path(os.environ['HACO_OPTIONS_PATH']) -MQTT_PASSWORD = os.environ['MQTT_PASSWORD'] -MQTT_HOST = os.environ['MQTT_HOST'] -MQTT_PORT = int(os.environ['MQTT_PORT']) -MQTT_USERNAME = os.environ['MQTT_USERNAME'] +CONFIGS_PATH = Path(os.environ.get('HACO_CONFIGS_PATH','/haco/config')) +OPTIONS_PATH = Path(os.environ.get('HACO_OPTIONS_PATH','/haco/data/options.json')) +MQTT_HOST = os.environ.get('MQTT_HOST','localhost') +MQTT_PORT = int(os.environ.get('MQTT_PORT',1883)) +MQTT_USERNAME = os.environ.get('MQTT_USERNAME') +MQTT_PASSWORD = os.environ.get('MQTT_PASSWORD',None) if (CONFIGS_PATH / '.debug').exists(): LOG_LEVEL = 'DEBUG' From 5c1f6f6cb138621dde7513f5a0a0f9079873102a Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Wed, 1 Nov 2023 13:17:28 +0000 Subject: [PATCH 058/183] Increment version number to 0.0.20 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index 1b2794a..742dfc8 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.19' +var VERSION='0.0.20' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 90a8ad5..5e38384 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://link.frontmatter.ai/haco -version: 0.0.19 +version: 0.0.20 diff --git a/haco/version b/haco/version index c5d4220..eb1591a 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.19 \ No newline at end of file +0.0.20 \ No newline at end of file From c5b8413001570de8e3aa14428f21067d54cef303 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 7 Mar 2024 16:04:15 +0000 Subject: [PATCH 059/183] Add development compose --- docker-compose.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100755 index 0000000..45e6945 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3.4' +services: + haco-dev: + build: + context: . + dockerfile: Dockerfile + target: development + image: haco:dev + container_name: haco + env_file: + - ${ENV_PATH} + volumes: + - /fm/haco/artifacts:/haco \ No newline at end of file From be9395a5b76899acabefb67cb5652dc213f33822 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 7 Mar 2024 16:05:08 +0000 Subject: [PATCH 060/183] Migrate links to fmtr.link --- README.md | 6 +++--- ha/addon/CHANGELOG.md | 2 +- ha/addon/DOCS.md | 2 +- ha/addon/config.yaml | 2 +- setup.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c64968a..4b1e75a 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ Once your test device is ready, with a recent (12.5+) version of Tasmota, simply Berry Script Console: ```be -{"download":tasmota.urlfetch('https://link.frontmatter.ai/haco/tapp','haco.tapp'), "restart":tasmota.cmd("restart 1")} +{"download":tasmota.urlfetch('https://fmtr.link/haco/tapp','haco.tapp'), "restart":tasmota.cmd("restart 1")} ``` You should see output like `{'restart': {'Restart': 'Restarting'}, 'download': 200}` and the device will restart. @@ -103,7 +103,7 @@ HACO: The haco daemon has started. Hostname: tasmota-test, MAC: 04:74:77:9B:CB:C #### Older Tasmota Versions -With older Tasmota versions, download the [`haco.tapp` file](https://link.frontmatter.ai/haco/tapp) on a desktop +With older Tasmota versions, download the [`haco.tapp` file](https://fmtr.link/haco/tapp) on a desktop computer, upload it to your device and restart manually. @@ -111,7 +111,7 @@ upload it to your device and restart manually. You can now install the Home Assistant Add-On: -[![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://link.frontmatter.ai/haco/add-on) +[![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://fmtr.link/haco/add-on) Once the Add-On is installed, click into its Configuration tab and you'll see a setting called `assignments`: diff --git a/ha/addon/CHANGELOG.md b/ha/addon/CHANGELOG.md index 5bf094e..47f41bd 100644 --- a/ha/addon/CHANGELOG.md +++ b/ha/addon/CHANGELOG.md @@ -1 +1 @@ -For the latest changes, see **[the project releases page](https://link.frontmatter.ai/haco/changes)**. \ No newline at end of file +For the latest changes, see **[the project releases page](https://fmtr.link/haco/changes)**. \ No newline at end of file diff --git a/ha/addon/DOCS.md b/ha/addon/DOCS.md index 67c5929..bfffc09 100644 --- a/ha/addon/DOCS.md +++ b/ha/addon/DOCS.md @@ -1 +1 @@ -For general documentation, see **[the project wiki](https://link.frontmatter.ai/haco/doc)**. \ No newline at end of file +For general documentation, see **[the project wiki](https://fmtr.link/haco/doc)**. \ No newline at end of file diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 5e38384..9a11097 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -21,5 +21,5 @@ schema: services: - mqtt:need slug: haco -url: https://link.frontmatter.ai/haco +url: https://fmtr.link/haco version: 0.0.20 diff --git a/setup.py b/setup.py index abed16a..ec18b29 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup( long_description_content_type='text/markdown', name=name, version=__version__, - url=f'https://link.frontmatter.ai/{name}', + url=f'https://fmtr.link/{name}', license='Copyright © 2023 Frontmatter. All rights reserved.', author='Frontmatter', description='Home Assistant Control Objects', From 46d4c56889295e85f54f51779bd3b912156a6b96 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 7 Mar 2024 16:48:50 +0000 Subject: [PATCH 061/183] Modify Actions to use fmtr.link API --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2610b00..20d78e8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: NAME_SHORT: ${{ github.event.repository.name }} ORG: ${{ github.repository_owner }} REBRANDLY_API_KEY: ${{ secrets.REBRANDLY_API_KEY }} - LINK_ID: ca4942821f5740fbaa46d1066b5cd7e4 + LINK_ID: haco/tapp steps: - uses: actions/checkout@v3 @@ -78,8 +78,8 @@ jobs: - name: Update Link run: | URL=https://github.com/${ORG}/${NAME}/releases/download/v${VERSION}/${NAME_SHORT}.tapp - DATA="{\"destination\": \"${URL}\"}" - curl --request POST --url https://api.rebrandly.com/v1/links/${LINK_ID} --header 'accept: application/json' --header "apikey: ${REBRANDLY_API_KEY}" --header 'content-type: application/json' --data "$DATA" &> /dev/null + DATA="{\"longUrl\": \"${URL}\"}" + curl --request PATCH --url https://fmtr.link/rest/v3/short-urls/${LINK_ID} --header "Content-Type: application/json" --header "X-Api-Key: ${SHLINK_API_KEY}" --data "$DATA" &> /dev/null - name: Build Docker run: | From 64babe44d9ca588f61fea8c799c24223d865f5eb Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Thu, 7 Mar 2024 16:51:43 +0000 Subject: [PATCH 062/183] Increment version number to 0.0.21 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index 742dfc8..b044272 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.20' +var VERSION='0.0.21' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 9a11097..daa915c 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://fmtr.link/haco -version: 0.0.20 +version: 0.0.21 diff --git a/haco/version b/haco/version index eb1591a..186fbd6 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.20 \ No newline at end of file +0.0.21 \ No newline at end of file From c819c44fbd452dbda7d5fe26ef73cbf00e368807 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 7 Mar 2024 16:54:59 +0000 Subject: [PATCH 063/183] Modify Actions to use fmtr.link API --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 20d78e8..4f6affb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: NAME: ${{ github.event.repository.name }} NAME_SHORT: ${{ github.event.repository.name }} ORG: ${{ github.repository_owner }} - REBRANDLY_API_KEY: ${{ secrets.REBRANDLY_API_KEY }} + SHLINK_API_KEY: ${{ secrets.SHLINK_API_KEY }} LINK_ID: haco/tapp steps: From 3bc11ca0f84371598f76c33c8e333bba49689685 Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Thu, 7 Mar 2024 16:55:47 +0000 Subject: [PATCH 064/183] Increment version number to 0.0.22 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index b044272..a503627 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.21' +var VERSION='0.0.22' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index daa915c..5145b58 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://fmtr.link/haco -version: 0.0.21 +version: 0.0.22 diff --git a/haco/version b/haco/version index 186fbd6..fe059cc 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.21 \ No newline at end of file +0.0.22 \ No newline at end of file From c2c9c7bb03d6e605ceb15143dd58c14a625549d7 Mon Sep 17 00:00:00 2001 From: David Roe Date: Sat, 9 Mar 2024 02:31:33 -0800 Subject: [PATCH 065/183] Resolve dependency upgrade issues (#3) * Use pipx * Lock aiomqtt version --- ha/addon/Dockerfile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ha/addon/Dockerfile b/ha/addon/Dockerfile index 72ed76c..a67f7f5 100644 --- a/ha/addon/Dockerfile +++ b/ha/addon/Dockerfile @@ -2,10 +2,15 @@ ARG BUILD_FROM FROM $BUILD_FROM ARG BUILD_VERSION -RUN apk add --no-cache py3-pip -RUN pip install haco==${BUILD_VERSION} +RUN apk add --no-cache pipx +ENV PATH="${PATH}:/root/.local/bin" + +RUN pipx install haco==${BUILD_VERSION} + +# Remove one haco is either updated to support aiomqtt 2.0.0 or specifies needed version in setup.py +RUN pipx inject haco aiomqtt==1.2.1 COPY run.sh / RUN chmod a+x /run.sh -CMD [ "/run.sh" ] \ No newline at end of file +CMD [ "/run.sh" ] From ca9d910666213fe6ab8cc83fc7d72f7653692442 Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Sat, 9 Mar 2024 10:32:54 +0000 Subject: [PATCH 066/183] Increment version number to 0.0.23 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index a503627..cee1ba3 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.22' +var VERSION='0.0.23' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 5145b58..8934fee 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://fmtr.link/haco -version: 0.0.22 +version: 0.0.23 diff --git a/haco/version b/haco/version index fe059cc..95dfee2 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.22 \ No newline at end of file +0.0.23 \ No newline at end of file From 443d9e4bc3cd028eed9356fa46f736a024963d48 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 12 Mar 2024 09:42:27 +0000 Subject: [PATCH 067/183] Update Docker base Python image #2 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 54a891b..37602f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ARG VERSION ARG TYPE=development -FROM edwardbrown/python as base +FROM fmtr/python as base ENV DEBIAN_FRONTEND=noninteractive RUN apt -qq update -y From 375f9f0ecf93fc6202f9afa560b0d1fe2691b0fd Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 12 Mar 2024 09:43:21 +0000 Subject: [PATCH 068/183] Force pip install without venv #2 --- ha/addon/Dockerfile | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/ha/addon/Dockerfile b/ha/addon/Dockerfile index a67f7f5..61e4d62 100644 --- a/ha/addon/Dockerfile +++ b/ha/addon/Dockerfile @@ -2,15 +2,10 @@ ARG BUILD_FROM FROM $BUILD_FROM ARG BUILD_VERSION -RUN apk add --no-cache pipx -ENV PATH="${PATH}:/root/.local/bin" - -RUN pipx install haco==${BUILD_VERSION} - -# Remove one haco is either updated to support aiomqtt 2.0.0 or specifies needed version in setup.py -RUN pipx inject haco aiomqtt==1.2.1 +RUN apk add --no-cache py3-pip +RUN pip install haco==${BUILD_VERSION} --break-system-packages COPY run.sh / RUN chmod a+x /run.sh -CMD [ "/run.sh" ] +CMD [ "/run.sh" ] \ No newline at end of file From 119e29751556aa667da7f91c9d723614696ec1f5 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 12 Mar 2024 09:52:05 +0000 Subject: [PATCH 069/183] Pin aiomqtt<2 #2 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ec18b29..9a7171b 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ setup( name: [f'version'], }, install_requires=[ - 'aiomqtt', + 'aiomqtt<2', 'pyyaml', 'requests' ], From 86dbfd984a5e0858c52a431f1dbdc5766d9a36ab Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Tue, 12 Mar 2024 09:53:52 +0000 Subject: [PATCH 070/183] Increment version number to 0.0.24 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index cee1ba3..4e4a623 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.23' +var VERSION='0.0.24' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index 8934fee..f60add8 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://fmtr.link/haco -version: 0.0.23 +version: 0.0.24 diff --git a/haco/version b/haco/version index 95dfee2..9c2a097 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.23 \ No newline at end of file +0.0.24 \ No newline at end of file From 7c2be490c71e5c0eb6dfeba51fbd027018d2a277 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 27 Mar 2024 14:24:53 +0000 Subject: [PATCH 071/183] Move actions email to secrets --- .github/workflows/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4f6affb..c85e74f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,10 +38,11 @@ jobs: echo $DOCKER_TOKEN | docker login --username $DOCKER_USER --password-stdin - name: Increment Version + env: + GIT_EMAIL: ${{ secrets.GIT_EMAIL }} run: | - git config --global user.name 'Frontmatter Actions' - git config --global user.email 'actions@frontmatter.ai' + git config --global user.email "$GIT_EMAIL" echo -n ${VERSION} > ${NAME}/version python3 update_version.py ${VERSION} tappack --module-path berry/ --output ./${NAME_SHORT}.tapp From 49fb5b91a43fe667dc5d34063909b65fc29a8d85 Mon Sep 17 00:00:00 2001 From: Frontmatter Actions Date: Wed, 27 Mar 2024 14:25:48 +0000 Subject: [PATCH 072/183] Increment version number to 0.0.25 for release --- berry/haco_version.be | 2 +- ha/addon/config.yaml | 2 +- haco/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/berry/haco_version.be b/berry/haco_version.be index 4e4a623..1701bfd 100644 --- a/berry/haco_version.be +++ b/berry/haco_version.be @@ -1,4 +1,4 @@ -var VERSION='0.0.24' +var VERSION='0.0.25' var mod = module("haco_version") mod.VERSION=VERSION diff --git a/ha/addon/config.yaml b/ha/addon/config.yaml index f60add8..0083fa5 100644 --- a/ha/addon/config.yaml +++ b/ha/addon/config.yaml @@ -22,4 +22,4 @@ services: - mqtt:need slug: haco url: https://fmtr.link/haco -version: 0.0.24 +version: 0.0.25 diff --git a/haco/version b/haco/version index 9c2a097..d34586a 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.24 \ No newline at end of file +0.0.25 \ No newline at end of file From d772b5a9b74bda647ca1e13e108b2d945a578ec4 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 23 Oct 2024 08:20:14 +0100 Subject: [PATCH 073/183] Add Docker build instructions (fixes #1) --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index 4b1e75a..4965c35 100644 --- a/README.md +++ b/README.md @@ -354,3 +354,36 @@ ValueError: Callback function name "set_mode_ha" is not valid for control "Clima Beyond these examples, when creating your own configuration, you'll probably find the [built-in configurations](https://github.com/fmtr/haco/tree/release/haco/configs) (especially the [`development` config](https://github.com/fmtr/haco/tree/release/haco/configs/development.py)) useful. + +## How to Run Using Docker + +If you're not using Home Assistant OS (Supervised) you might want to run as a stand-alone Docker Container. There's no pre-built image currently, so you'll need to build and run manually: + +## Build + +```bash +git clone https://github.com/fmtr/haco.git +cd haco +docker build -t fmtr/haco:latest . +``` + +## Run + +Example Docker Compose: + +```yaml +version: '3' +services: + main: + image: fmtr/haco:latest + container_name: haco + restart: unless-stopped + + environment: + - MQTT_HOST=mqtt.service + - HACO_LOG_LEVEL=DEBUG + volumes: + - :/haco +``` + + From 666f625ed0b1ec50faf81db928cc8277a6fdc472 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 23 Oct 2024 08:25:41 +0100 Subject: [PATCH 074/183] Add other environment variables to Docker build instructions --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 4965c35..4ad8ec9 100644 --- a/README.md +++ b/README.md @@ -386,4 +386,11 @@ services: - :/haco ``` +Other environment variables: + +- `MQTT_HOST` +- `MQTT_PORT` +- `MQTT_USERNAME` +- `MQTT_PASSWORD` + From 77214fa26b68ab193372a6d66f48199cf8945162 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 11 Nov 2025 09:03:09 +0000 Subject: [PATCH 075/183] Refactor setup.py to use fmtr.tools.Setup --- build.env | 9 +++++++++ pyproject.toml | 3 +++ setup.py | 46 ++++++++++------------------------------------ 3 files changed, 22 insertions(+), 36 deletions(-) create mode 100644 build.env create mode 100644 pyproject.toml diff --git a/build.env b/build.env new file mode 100644 index 0000000..8d30f31 --- /dev/null +++ b/build.env @@ -0,0 +1,9 @@ +CHANNEL="prod" +#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/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c2d6e8d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["fmtr.tools[setup,debug]"] +build-backend = "setuptools.build_meta" # \ No newline at end of file diff --git a/setup.py b/setup.py index 9a7171b..0d7ce36 100644 --- a/setup.py +++ b/setup.py @@ -1,40 +1,14 @@ -from pathlib import Path +from fmtr.tools import Setup -from setuptools import find_packages, setup - -packages = find_packages() -name = next(iter(packages)) -path_base = Path(__file__).absolute().parent -path = path_base / name / 'version' -__version__ = path.read_text().strip() - -setup( - long_description=(path_base / 'README.md').read_text(), - long_description_content_type='text/markdown', - name=name, - version=__version__, - url=f'https://fmtr.link/{name}', - license='Copyright © 2023 Frontmatter. All rights reserved.', - author='Frontmatter', +setup = Setup( + org=None, + dependencies=dict( + install=[ + 'fmtr.tools[version.dev,logging,sets,yaml,debug,caching,api]', + 'aiomqtt<2' + ] + ), description='Home Assistant Control Objects', keywords='homeassistant controls python tasmota', - packages=packages, - package_data={ - name: [f'version'], - }, - install_requires=[ - 'aiomqtt<2', - 'pyyaml', - 'requests' - ], - extras_require={ - 'tasmota': [ - - ] - }, - entry_points={ - 'console_scripts': [ - f'{name}-daemon = {name}.start:main', - ], - } + # url=f'https://fmtr.link/{name}', ) From e6ea78ab49f183d951368bc52c55702f36b0a2e1 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 14 Nov 2025 12:08:21 +0000 Subject: [PATCH 076/183] Add unpicking comments --- haco/climate.py | 2 +- haco/mqtt.py | 3 ++- haco/schema.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/haco/climate.py b/haco/climate.py index e02bf4f..da441eb 100644 --- a/haco/climate.py +++ b/haco/climate.py @@ -22,7 +22,7 @@ class Climate(Control): ), Capability( name='temperature', - alias='target_temperature' + alias='target_temperature' # only used for callbacks, i guess to unify/simplify them for the user. ), Capability( name='temperature_high' diff --git a/haco/mqtt.py b/haco/mqtt.py index 4363bd4..8fb7e40 100644 --- a/haco/mqtt.py +++ b/haco/mqtt.py @@ -1,8 +1,9 @@ -import aiomqtt import asyncio import json from pathlib import Path +import aiomqtt + from haco import constants, tools from haco.constants import MQTT_PASSWORD, MQTT_HOST, MQTT_PORT, MQTT_USERNAME from haco.device import Device diff --git a/haco/schema.py b/haco/schema.py index e6679f2..0412a9b 100644 --- a/haco/schema.py +++ b/haco/schema.py @@ -133,7 +133,7 @@ class Platform: if not self.callback: return {} - return {self.get_topic_subscription(): self.get_handler_name()} + return {self.get_topic_subscription(): self.get_handler_name()} # I think this is as such because it needs to invert the subscription. so one platform gets the other's messages? def get_config_ha(self): From 995cb81253ce35430fe18880bd1e1ecb882bf467 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 14 Nov 2025 12:10:48 +0000 Subject: [PATCH 077/183] Restructure v0 in v0 sub package --- {.github => haco/v0/.github}/workflows/main.yml | 0 Dockerfile => haco/v0/Dockerfile | 0 README.md => haco/v0/README.md | 0 {assets => haco/v0/assets}/air_fryer_cookbook.png | Bin {assets => haco/v0/assets}/greeter_select.png | Bin {assets => haco/v0/assets}/memory_sensor.png | Bin {assets => haco/v0/assets}/restart_button.png | Bin {assets => haco/v0/assets}/weblog_select.png | Bin {berry => haco/v0/berry}/haco.be | 0 {berry => haco/v0/berry}/haco_autoexec.be | 0 {berry => haco/v0/berry}/haco_version.be | 0 {berry => haco/v0/berry}/manifest.yaml | 0 docker-compose.yml => haco/v0/docker-compose.yml | 0 {ha => haco/v0/ha}/addon/CHANGELOG.md | 0 {ha => haco/v0/ha}/addon/DOCS.md | 0 {ha => haco/v0/ha}/addon/Dockerfile | 0 {ha => haco/v0/ha}/addon/README.md | 0 {ha => haco/v0/ha}/addon/config.yaml | 0 {ha => haco/v0/ha}/addon/icon.png | Bin {ha => haco/v0/ha}/addon/logo.png | Bin {ha => haco/v0/ha}/addon/run.sh | 0 haco/{ => v0/haco}/__init__.py | 0 haco/{ => v0/haco}/berry.py | 0 haco/{ => v0/haco}/binary_sensor.py | 0 haco/{ => v0/haco}/button.py | 3 ++- haco/{ => v0/haco}/callback.py | 6 +++--- haco/{ => v0/haco}/climate.py | 0 haco/{ => v0/haco}/constants.py | 0 haco/{ => v0/haco}/control.py | 3 ++- haco/{ => v0/haco}/debugging.py | 3 ++- haco/{ => v0/haco}/device.py | 3 ++- haco/{ => v0/haco}/device_data.py | 0 haco/{ => v0/haco}/fan.py | 3 ++- haco/{ => v0/haco}/load_configs.py | 6 +++--- haco/{ => v0/haco}/mqtt.py | 4 ++-- haco/{ => v0/haco}/number.py | 4 ++-- haco/{ => v0/haco}/pulldown.py | 0 haco/{ => v0/haco}/schema.py | 0 haco/{ => v0/haco}/sensor.py | 4 ++-- haco/{ => v0/haco}/start.py | 0 haco/{ => v0/haco}/switch.py | 0 haco/{ => v0/haco}/tasmota.py | 0 haco/{ => v0/haco}/text.py | 0 haco/{ => v0/haco}/tools.py | 3 ++- haco/{ => v0/haco}/trigger.py | 0 haco/{ => v0/haco}/tuya.py | 0 haco/{ => v0/haco}/update.py | 0 update_version.py => haco/v0/update_version.py | 3 +-- 48 files changed, 25 insertions(+), 20 deletions(-) rename {.github => haco/v0/.github}/workflows/main.yml (100%) rename Dockerfile => haco/v0/Dockerfile (100%) rename README.md => haco/v0/README.md (100%) rename {assets => haco/v0/assets}/air_fryer_cookbook.png (100%) rename {assets => haco/v0/assets}/greeter_select.png (100%) rename {assets => haco/v0/assets}/memory_sensor.png (100%) rename {assets => haco/v0/assets}/restart_button.png (100%) rename {assets => haco/v0/assets}/weblog_select.png (100%) rename {berry => haco/v0/berry}/haco.be (100%) rename {berry => haco/v0/berry}/haco_autoexec.be (100%) rename {berry => haco/v0/berry}/haco_version.be (100%) rename {berry => haco/v0/berry}/manifest.yaml (100%) rename docker-compose.yml => haco/v0/docker-compose.yml (100%) rename {ha => haco/v0/ha}/addon/CHANGELOG.md (100%) rename {ha => haco/v0/ha}/addon/DOCS.md (100%) rename {ha => haco/v0/ha}/addon/Dockerfile (100%) rename {ha => haco/v0/ha}/addon/README.md (100%) rename {ha => haco/v0/ha}/addon/config.yaml (100%) rename {ha => haco/v0/ha}/addon/icon.png (100%) rename {ha => haco/v0/ha}/addon/logo.png (100%) rename {ha => haco/v0/ha}/addon/run.sh (100%) rename haco/{ => v0/haco}/__init__.py (100%) rename haco/{ => v0/haco}/berry.py (100%) rename haco/{ => v0/haco}/binary_sensor.py (100%) rename haco/{ => v0/haco}/button.py (99%) rename haco/{ => v0/haco}/callback.py (100%) rename haco/{ => v0/haco}/climate.py (100%) rename haco/{ => v0/haco}/constants.py (100%) rename haco/{ => v0/haco}/control.py (99%) rename haco/{ => v0/haco}/debugging.py (99%) rename haco/{ => v0/haco}/device.py (99%) rename haco/{ => v0/haco}/device_data.py (100%) rename haco/{ => v0/haco}/fan.py (99%) rename haco/{ => v0/haco}/load_configs.py (100%) rename haco/{ => v0/haco}/mqtt.py (100%) rename haco/{ => v0/haco}/number.py (100%) rename haco/{ => v0/haco}/pulldown.py (100%) rename haco/{ => v0/haco}/schema.py (100%) rename haco/{ => v0/haco}/sensor.py (100%) rename haco/{ => v0/haco}/start.py (100%) rename haco/{ => v0/haco}/switch.py (100%) rename haco/{ => v0/haco}/tasmota.py (100%) rename haco/{ => v0/haco}/text.py (100%) rename haco/{ => v0/haco}/tools.py (99%) rename haco/{ => v0/haco}/trigger.py (100%) rename haco/{ => v0/haco}/tuya.py (100%) rename haco/{ => v0/haco}/update.py (100%) rename update_version.py => haco/v0/update_version.py (99%) diff --git a/.github/workflows/main.yml b/haco/v0/.github/workflows/main.yml similarity index 100% rename from .github/workflows/main.yml rename to haco/v0/.github/workflows/main.yml diff --git a/Dockerfile b/haco/v0/Dockerfile similarity index 100% rename from Dockerfile rename to haco/v0/Dockerfile diff --git a/README.md b/haco/v0/README.md similarity index 100% rename from README.md rename to haco/v0/README.md diff --git a/assets/air_fryer_cookbook.png b/haco/v0/assets/air_fryer_cookbook.png similarity index 100% rename from assets/air_fryer_cookbook.png rename to haco/v0/assets/air_fryer_cookbook.png diff --git a/assets/greeter_select.png b/haco/v0/assets/greeter_select.png similarity index 100% rename from assets/greeter_select.png rename to haco/v0/assets/greeter_select.png diff --git a/assets/memory_sensor.png b/haco/v0/assets/memory_sensor.png similarity index 100% rename from assets/memory_sensor.png rename to haco/v0/assets/memory_sensor.png diff --git a/assets/restart_button.png b/haco/v0/assets/restart_button.png similarity index 100% rename from assets/restart_button.png rename to haco/v0/assets/restart_button.png diff --git a/assets/weblog_select.png b/haco/v0/assets/weblog_select.png similarity index 100% rename from assets/weblog_select.png rename to haco/v0/assets/weblog_select.png diff --git a/berry/haco.be b/haco/v0/berry/haco.be similarity index 100% rename from berry/haco.be rename to haco/v0/berry/haco.be diff --git a/berry/haco_autoexec.be b/haco/v0/berry/haco_autoexec.be similarity index 100% rename from berry/haco_autoexec.be rename to haco/v0/berry/haco_autoexec.be diff --git a/berry/haco_version.be b/haco/v0/berry/haco_version.be similarity index 100% rename from berry/haco_version.be rename to haco/v0/berry/haco_version.be diff --git a/berry/manifest.yaml b/haco/v0/berry/manifest.yaml similarity index 100% rename from berry/manifest.yaml rename to haco/v0/berry/manifest.yaml diff --git a/docker-compose.yml b/haco/v0/docker-compose.yml similarity index 100% rename from docker-compose.yml rename to haco/v0/docker-compose.yml diff --git a/ha/addon/CHANGELOG.md b/haco/v0/ha/addon/CHANGELOG.md similarity index 100% rename from ha/addon/CHANGELOG.md rename to haco/v0/ha/addon/CHANGELOG.md diff --git a/ha/addon/DOCS.md b/haco/v0/ha/addon/DOCS.md similarity index 100% rename from ha/addon/DOCS.md rename to haco/v0/ha/addon/DOCS.md diff --git a/ha/addon/Dockerfile b/haco/v0/ha/addon/Dockerfile similarity index 100% rename from ha/addon/Dockerfile rename to haco/v0/ha/addon/Dockerfile diff --git a/ha/addon/README.md b/haco/v0/ha/addon/README.md similarity index 100% rename from ha/addon/README.md rename to haco/v0/ha/addon/README.md diff --git a/ha/addon/config.yaml b/haco/v0/ha/addon/config.yaml similarity index 100% rename from ha/addon/config.yaml rename to haco/v0/ha/addon/config.yaml diff --git a/ha/addon/icon.png b/haco/v0/ha/addon/icon.png similarity index 100% rename from ha/addon/icon.png rename to haco/v0/ha/addon/icon.png diff --git a/ha/addon/logo.png b/haco/v0/ha/addon/logo.png similarity index 100% rename from ha/addon/logo.png rename to haco/v0/ha/addon/logo.png diff --git a/ha/addon/run.sh b/haco/v0/ha/addon/run.sh similarity index 100% rename from ha/addon/run.sh rename to haco/v0/ha/addon/run.sh diff --git a/haco/__init__.py b/haco/v0/haco/__init__.py similarity index 100% rename from haco/__init__.py rename to haco/v0/haco/__init__.py diff --git a/haco/berry.py b/haco/v0/haco/berry.py similarity index 100% rename from haco/berry.py rename to haco/v0/haco/berry.py diff --git a/haco/binary_sensor.py b/haco/v0/haco/binary_sensor.py similarity index 100% rename from haco/binary_sensor.py rename to haco/v0/haco/binary_sensor.py diff --git a/haco/button.py b/haco/v0/haco/button.py similarity index 99% rename from haco/button.py rename to haco/v0/haco/button.py index d1b1fbb..4004dd8 100644 --- a/haco/button.py +++ b/haco/v0/haco/button.py @@ -1,6 +1,7 @@ -from haco import schema from haco.control import Control +from haco import schema + class Button(Control): NAME = 'button' diff --git a/haco/callback.py b/haco/v0/haco/callback.py similarity index 100% rename from haco/callback.py rename to haco/v0/haco/callback.py index dab8018..6728c83 100644 --- a/haco/callback.py +++ b/haco/v0/haco/callback.py @@ -1,12 +1,12 @@ -from collections import namedtuple - import inspect import typing +from collections import namedtuple from typing import _AnnotatedAlias -from haco import berry, schema from haco.trigger import Trigger, Rule +from haco import berry, schema + Signature = namedtuple('Signature', ['type', 'expression']) diff --git a/haco/climate.py b/haco/v0/haco/climate.py similarity index 100% rename from haco/climate.py rename to haco/v0/haco/climate.py diff --git a/haco/constants.py b/haco/v0/haco/constants.py similarity index 100% rename from haco/constants.py rename to haco/v0/haco/constants.py diff --git a/haco/control.py b/haco/v0/haco/control.py similarity index 99% rename from haco/control.py rename to haco/v0/haco/control.py index b946d99..16ce18c 100644 --- a/haco/control.py +++ b/haco/v0/haco/control.py @@ -2,11 +2,12 @@ import logging from functools import partial import haco.constants -from haco import tools, constants from haco.callback import Callback from haco.schema import Schema, Platform, Tasmota, HomeAssistant, AnnounceTopic, Capability from haco.tools import log_publish +from haco import tools, constants + class Control: NAME = None diff --git a/haco/debugging.py b/haco/v0/haco/debugging.py similarity index 99% rename from haco/debugging.py rename to haco/v0/haco/debugging.py index 8ebd201..2a7a8e2 100644 --- a/haco/debugging.py +++ b/haco/v0/haco/debugging.py @@ -1,11 +1,12 @@ import random from typing import Any -from haco import trigger, Update, Response from haco.sensor import Sensor from haco.tasmota import Tasmota from haco.tools import get_latest +from haco import trigger, Update, Response + def get_memory_sensor(): memory_sensor = Sensor('Memory Free', uom='kB', uom_type='DATA_SIZE', data_type=int) diff --git a/haco/device.py b/haco/v0/haco/device.py similarity index 99% rename from haco/device.py rename to haco/v0/haco/device.py index 08f18dc..3583e32 100644 --- a/haco/device.py +++ b/haco/v0/haco/device.py @@ -2,11 +2,12 @@ import json from pathlib import Path from typing import List -from haco import tools, constants from haco.control import Control from haco.device_data import DeviceData from haco.tools import log_publish, split_into_chunks, log_subscribe +from haco import tools, constants + class Device: diff --git a/haco/device_data.py b/haco/v0/haco/device_data.py similarity index 100% rename from haco/device_data.py rename to haco/v0/haco/device_data.py diff --git a/haco/fan.py b/haco/v0/haco/fan.py similarity index 99% rename from haco/fan.py rename to haco/v0/haco/fan.py index 11ecc22..c6472d7 100644 --- a/haco/fan.py +++ b/haco/v0/haco/fan.py @@ -1,8 +1,9 @@ -from haco import constants 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' diff --git a/haco/load_configs.py b/haco/v0/haco/load_configs.py similarity index 100% rename from haco/load_configs.py rename to haco/v0/haco/load_configs.py index c49967b..ff1128d 100644 --- a/haco/load_configs.py +++ b/haco/v0/haco/load_configs.py @@ -1,14 +1,14 @@ -from importlib import reload - import importlib.util import json +from importlib import reload from pathlib import Path -from haco import tools from haco.constants import CONFIGS_PATH, OPTIONS_PATH from haco.control import Control from haco.device import Device +from haco import tools + def load_json(file_path): with open(file_path, 'r') as json_file: diff --git a/haco/mqtt.py b/haco/v0/haco/mqtt.py similarity index 100% rename from haco/mqtt.py rename to haco/v0/haco/mqtt.py index 8fb7e40..f1f3c1c 100644 --- a/haco/mqtt.py +++ b/haco/v0/haco/mqtt.py @@ -3,14 +3,14 @@ import json from pathlib import Path import aiomqtt - -from haco import constants, tools from haco.constants import MQTT_PASSWORD, MQTT_HOST, MQTT_PORT, MQTT_USERNAME from haco.device import Device from haco.device_data import DeviceData from haco.load_configs import load_devices from haco.tools import log_received, logger +from haco import constants, tools + async def listen(client, devices): TOPIC_ANNOUNCE = f"haco/{constants.BRANCH}/+/announce" diff --git a/haco/number.py b/haco/v0/haco/number.py similarity index 100% rename from haco/number.py rename to haco/v0/haco/number.py index 9da7c87..53524d5 100644 --- a/haco/number.py +++ b/haco/v0/haco/number.py @@ -1,8 +1,8 @@ from haco.control import Control -from haco.data.uom import Uom - from haco.tools import get_range_pair +from haco.data.uom import Uom + class Number(Control): NAME = 'number' diff --git a/haco/pulldown.py b/haco/v0/haco/pulldown.py similarity index 100% rename from haco/pulldown.py rename to haco/v0/haco/pulldown.py diff --git a/haco/schema.py b/haco/v0/haco/schema.py similarity index 100% rename from haco/schema.py rename to haco/v0/haco/schema.py diff --git a/haco/sensor.py b/haco/v0/haco/sensor.py similarity index 100% rename from haco/sensor.py rename to haco/v0/haco/sensor.py index 2a1c26e..425ee0f 100644 --- a/haco/sensor.py +++ b/haco/v0/haco/sensor.py @@ -1,7 +1,7 @@ -from haco import schema from haco.control import Control -from haco.data.type_sensor import DeviceClassSensor +from haco import schema +from haco.data.type_sensor import DeviceClassSensor from haco.data.uom import Uom diff --git a/haco/start.py b/haco/v0/haco/start.py similarity index 100% rename from haco/start.py rename to haco/v0/haco/start.py diff --git a/haco/switch.py b/haco/v0/haco/switch.py similarity index 100% rename from haco/switch.py rename to haco/v0/haco/switch.py diff --git a/haco/tasmota.py b/haco/v0/haco/tasmota.py similarity index 100% rename from haco/tasmota.py rename to haco/v0/haco/tasmota.py diff --git a/haco/text.py b/haco/v0/haco/text.py similarity index 100% rename from haco/text.py rename to haco/v0/haco/text.py diff --git a/haco/tools.py b/haco/v0/haco/tools.py similarity index 99% rename from haco/tools.py rename to haco/v0/haco/tools.py index a2b3c73..674c8b4 100644 --- a/haco/tools.py +++ b/haco/v0/haco/tools.py @@ -1,9 +1,10 @@ import hashlib import logging -from haco import constants, tuya from haco.tasmota import Tasmota +from haco import constants, tuya + logging.basicConfig(level=constants.LOG_LEVEL, format='%(asctime)s %(levelname)-8s %(message)s', datefmt='%Y-%m-%d %H:%M:%S') logger = logging.getLogger(__name__) diff --git a/haco/trigger.py b/haco/v0/haco/trigger.py similarity index 100% rename from haco/trigger.py rename to haco/v0/haco/trigger.py diff --git a/haco/tuya.py b/haco/v0/haco/tuya.py similarity index 100% rename from haco/tuya.py rename to haco/v0/haco/tuya.py diff --git a/haco/update.py b/haco/v0/haco/update.py similarity index 100% rename from haco/update.py rename to haco/v0/haco/update.py diff --git a/update_version.py b/haco/v0/update_version.py similarity index 99% rename from update_version.py rename to haco/v0/update_version.py index 167cbe2..91c2eb1 100644 --- a/update_version.py +++ b/haco/v0/update_version.py @@ -1,6 +1,5 @@ -import sys - import re +import sys from pathlib import Path PATH_ROOT = Path(__file__).parent.absolute() From 9b268aae0365057b020d2461698f0a592d730bd1 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 14 Nov 2025 12:11:27 +0000 Subject: [PATCH 078/183] Restructure v0 in v0 sub package --- haco/{ => v0}/configs/__init__.py | 0 haco/{ => v0}/configs/demo.py | 0 haco/{ => v0}/configs/development.py | 0 haco/{ => v0}/configs/proscenic_t21.py | 4 ++-- haco/{ => v0}/configs/test.py | 0 haco/{ => v0}/data/__init__.py | 0 haco/{ => v0}/data/type_binary_sensor.py | 0 haco/{ => v0}/data/type_sensor.py | 0 haco/{ => v0}/data/uom.py | 0 9 files changed, 2 insertions(+), 2 deletions(-) rename haco/{ => v0}/configs/__init__.py (100%) rename haco/{ => v0}/configs/demo.py (100%) rename haco/{ => v0}/configs/development.py (100%) rename haco/{ => v0}/configs/proscenic_t21.py (100%) rename haco/{ => v0}/configs/test.py (100%) rename haco/{ => v0}/data/__init__.py (100%) rename haco/{ => v0}/data/type_binary_sensor.py (100%) rename haco/{ => v0}/data/type_sensor.py (100%) rename haco/{ => v0}/data/uom.py (100%) diff --git a/haco/configs/__init__.py b/haco/v0/configs/__init__.py similarity index 100% rename from haco/configs/__init__.py rename to haco/v0/configs/__init__.py diff --git a/haco/configs/demo.py b/haco/v0/configs/demo.py similarity index 100% rename from haco/configs/demo.py rename to haco/v0/configs/demo.py diff --git a/haco/configs/development.py b/haco/v0/configs/development.py similarity index 100% rename from haco/configs/development.py rename to haco/v0/configs/development.py diff --git a/haco/configs/proscenic_t21.py b/haco/v0/configs/proscenic_t21.py similarity index 100% rename from haco/configs/proscenic_t21.py rename to haco/v0/configs/proscenic_t21.py index 0832489..ba192bf 100644 --- a/haco/configs/proscenic_t21.py +++ b/haco/v0/configs/proscenic_t21.py @@ -1,9 +1,9 @@ import math - -from haco import Tasmota, Number, Sensor, Select, Switch, tuya from haco.debugging import get_tasmota_updater from haco.tools import add_tuya_io +from haco import Tasmota, Number, Sensor, Select, Switch, tuya + OPTIONS = ['Default', 'Fries', 'Shrimp', 'Pizza', 'Chicken', 'Fish', 'Steak', 'Cake', 'Bacon', 'Preheat', 'Custom'] cookbook = Select('Cookbook', options=OPTIONS, icon='chef-hat') diff --git a/haco/configs/test.py b/haco/v0/configs/test.py similarity index 100% rename from haco/configs/test.py rename to haco/v0/configs/test.py diff --git a/haco/data/__init__.py b/haco/v0/data/__init__.py similarity index 100% rename from haco/data/__init__.py rename to haco/v0/data/__init__.py diff --git a/haco/data/type_binary_sensor.py b/haco/v0/data/type_binary_sensor.py similarity index 100% rename from haco/data/type_binary_sensor.py rename to haco/v0/data/type_binary_sensor.py diff --git a/haco/data/type_sensor.py b/haco/v0/data/type_sensor.py similarity index 100% rename from haco/data/type_sensor.py rename to haco/v0/data/type_sensor.py diff --git a/haco/data/uom.py b/haco/v0/data/uom.py similarity index 100% rename from haco/data/uom.py rename to haco/v0/data/uom.py From 069772e5b1caa5c9448bff326534b6607ecbf5f9 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sat, 15 Nov 2025 10:34:48 +0000 Subject: [PATCH 079/183] Add prototype rewrite data structure, imports, typing etc --- haco/__init__.py | 0 haco/capabilities.py | 39 +++++++++++++++++++++ haco/climate.py | 32 +++++++++++++++++ haco/control.py | 82 ++++++++++++++++++++++++++++++++++++++++++++ haco/device.py | 54 +++++++++++++++++++++++++++++ haco/topics.py | 75 ++++++++++++++++++++++++++++++++++++++++ haco/utils.py | 27 +++++++++++++++ 7 files changed, 309 insertions(+) create mode 100644 haco/__init__.py create mode 100644 haco/capabilities.py create mode 100644 haco/climate.py create mode 100644 haco/control.py create mode 100644 haco/device.py create mode 100644 haco/topics.py create mode 100644 haco/utils.py diff --git a/haco/__init__.py b/haco/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/haco/capabilities.py b/haco/capabilities.py new file mode 100644 index 0000000..b5911da --- /dev/null +++ b/haco/capabilities.py @@ -0,0 +1,39 @@ +from typing import Optional + +from pydantic import Field, model_validator + +from fmtr.tools import dm +from fmtr.tools.iterator_tools import strip_none +from haco.control import Control +from haco.topics import AnnounceTopicState, AnnounceTopicCommand + + +class Capability(dm.Base): + name: str + alias: str = None + + state: AnnounceTopicState | None = Field(default_factory=AnnounceTopicState) + command: AnnounceTopicCommand | None = Field(default_factory=AnnounceTopicCommand) + + control: Optional[Control] = Field(None, exclude=True, repr=False) + + @property + def announce(self) -> dict: + data = {} + for topic in strip_none(self.state, self.command): + data |= topic.announce + return data + + @property + def subscriptions(self): + + if not self.command: + return {} + + return self.command.subscriptions + + @model_validator(mode="after") + def attach_parent(self): + for topic in strip_none(self.state, self.command): + topic.capability = self + return self diff --git a/haco/climate.py b/haco/climate.py new file mode 100644 index 0000000..28c0b97 --- /dev/null +++ b/haco/climate.py @@ -0,0 +1,32 @@ +from typing import Literal, Optional, List + +from haco.capabilities import Capability +from haco.control import Control + + +class Climate(Control): + platform: Literal["climate"] = "climate" + temperature_unit: Literal["C", "F"] = "C" + temperature_min: float = 0 + temperature_max: float = 40 + humidity_min: float = 0 + humidity_max: float = 100 + precision: int = 1 + modes: Optional[List[str]] = None + preset_modes: Optional[List[str]] = None + fan_modes: Optional[List[str]] = None + swing_modes: Optional[List[str]] = None + + def temperature_command(self, value): + return value + + @classmethod + def get_capabilities(self): + return [ + Capability(name="current_temperature", command=None), + Capability(name="temperature"), + Capability(name="current_humidity"), + Capability(name="target_humidity"), + Capability(name="mode"), + Capability(name="fan_mode"), + ] diff --git a/haco/control.py b/haco/control.py new file mode 100644 index 0000000..d4dd59f --- /dev/null +++ b/haco/control.py @@ -0,0 +1,82 @@ +from __future__ import annotations + +from functools import cached_property +from typing import Optional, TYPE_CHECKING + +from pydantic import computed_field, model_validator, PrivateAttr + +from fmtr.tools import dm + +if TYPE_CHECKING: + from haco.capabilities import Capability + from haco.device import Device + +from haco.utils import sanitize_name + + +class Control(dm.Base): + name: str + platform: str + + icon: Optional[str] = None + + _device: Device = PrivateAttr(default=None) + + @computed_field + @property + def device(self) -> Device: # todo. quite ugly. perhaps just use @dataclass for topics? + return self._device + + @device.setter + def device(self, value: Device): + self._device = value + + @computed_field + @property + def unique_id(self) -> str: + name_san = sanitize_name(self.name) + return f"{self.device.name_san}-{name_san}" + + @property + def announce_topic(self): + return f"homeassistant/{self.platform}/{self.unique_id}/config" + + @computed_field + @property + def availability_topic(self) -> str: + return self.device.availability_topic + + @property + def announce(self) -> dict: + + data = self.model_dump(mode="json", exclude_none=True) + for capability in self.capabilities: + data |= capability.announce + + data = {self.announce_topic: data} + return data + + @property + def subscriptions(self) -> dict: + + data = {} + + for capability in self.capabilities: + data |= capability.subscriptions + + return data + + @model_validator(mode="after") + def attach_parent(self): + self.capabilities = self.get_capabilities() + for capability in self.capabilities: + capability.control = self + return self + + @classmethod + def get_capabilities(cls): + raise NotImplementedError() + + @cached_property + def capabilities(self) -> list[Capability]: + return self.get_capabilities() diff --git a/haco/device.py b/haco/device.py new file mode 100644 index 0000000..8cd3698 --- /dev/null +++ b/haco/device.py @@ -0,0 +1,54 @@ +from __future__ import annotations + +from functools import cached_property +from typing import List + +from pydantic import Field, computed_field, model_validator + +from fmtr.tools import dm +from haco.control import Control +from haco.utils import sanitize_name + + +class Device(dm.Base): + name: str + manufacturer: str = "Demo" + model: str = "Python MQTT Example" + + controls: List[Control] = Field(default_factory=list, exclude=True, repr=False) + + @property + def name_san(self) -> str: + return sanitize_name(self.name) + + @property + def availability_topic(self) -> str: + return f'status/{self.name_san}/availability' + + @computed_field + @property + def identifiers(self) -> list[str]: + return [self.name_san] + + @computed_field + @property + def connections(self) -> list[list[str]]: + return [["mac", "AA:BB:CC:DD:EE:FF"]] + + @model_validator(mode="after") + def attach_parent(self): + for control in self.controls: + control.device = self + return self + + @cached_property + def announces(self) -> list[dict]: + return [control.announce for control in self.controls] + + @cached_property + def subscriptions(self) -> dict: + data = {} + for control in self.controls: + data |= control.subscriptions + + return data diff --git a/haco/topics.py b/haco/topics.py new file mode 100644 index 0000000..2c19a44 --- /dev/null +++ b/haco/topics.py @@ -0,0 +1,75 @@ +from __future__ import annotations + +from functools import cached_property +from typing import ClassVar, TYPE_CHECKING + +from pydantic import PrivateAttr + +from fmtr.tools import dm + +if TYPE_CHECKING: + from haco.capabilities import Capability + + +class AnnounceTopic(dm.Base): + IO: ClassVar[str | None] = None + key: str = '{capability}_{io}_topic' + value: str = '{path}/{capability}/{io}' + + _capability: Capability = PrivateAttr(default=None) + + @property + def capability(self) -> Capability: # todo. quite ugly. perhaps just use @dataclass for topics? + return self._capability + + @capability.setter + def capability(self, value: Capability): + self._capability = value + + def fill(self, mask): + return mask.format(**self.fills) + + @property + def fills(self): + return dict( + path=str(self.capability.control.device.name_san), + capability=self.capability.name, + io=self.IO + ) + + @cached_property + def topic_key(self): + return self.fill(self.key) + + @cached_property + def topic(self): + return self.fill(self.value) + + @property + def announce(self): + data = {self.topic_key: self.topic} + return data + + @property + def callback_name(self): + return f'{self.capability.name}_{self.IO}' + + +class AnnounceTopicState(AnnounceTopic): + IO = 'state' + + @property + def subscriptions(self): + return {} + + +class AnnounceTopicCommand(AnnounceTopic): + IO = 'command' + + @property + def subscriptions(self): + method = getattr(self.capability.control, self.callback_name, None) + if not method: + return {} + + return {self.topic: method} diff --git a/haco/utils.py b/haco/utils.py new file mode 100644 index 0000000..99c0be2 --- /dev/null +++ b/haco/utils.py @@ -0,0 +1,27 @@ +import string + +CHARS_ALLOWED = string.ascii_lowercase + string.digits +SEPS = '_- /' +BRANCH = 'release' + +CAPABILITY_DEFAULT = 'default' +RECONNECT_DELAY_SEC = 5 +ON = 'ON' +OFF = 'OFF' + + +def sanitize_name(s, sep='-'): + chars = [] + + for c in s.lower(): + if c in SEPS: + chars.append(sep) + elif c in CHARS_ALLOWED: + chars.append(c) + + sanitized = ''.join(chars) + + if not sanitized: + raise ValueError("Sanitized string is empty") + + return sanitized From 5a688bc32ce78e3b207f1d01fe3875574ad41b52 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 19 Nov 2025 10:59:50 +0000 Subject: [PATCH 080/183] Add sandbox1 and 2 --- haco/client.py | 0 haco/constants.py | 13 +++++ haco/control.py | 14 +++-- haco/device.py | 16 ++++-- haco/paths.py | 3 ++ haco/sb1.py | 89 ++++++++++++++++++++++++++++++++ haco/sb2.py | 108 +++++++++++++++++++++++++++++++++++++++ haco/topics.py | 7 ++- haco/v0/haco/__init__.py | 28 ---------- haco/v0/haco/button.py | 9 ++-- haco/v0/haco/control.py | 5 +- haco/v0/haco/device.py | 5 +- haco/v0/haco/sensor.py | 12 +++-- haco/v0/haco/tools.py | 14 ----- 14 files changed, 257 insertions(+), 66 deletions(-) create mode 100644 haco/client.py create mode 100644 haco/constants.py create mode 100644 haco/paths.py create mode 100644 haco/sb1.py create mode 100644 haco/sb2.py diff --git a/haco/client.py b/haco/client.py new file mode 100644 index 0000000..e69de29 diff --git a/haco/constants.py b/haco/constants.py new file mode 100644 index 0000000..2a36fb7 --- /dev/null +++ b/haco/constants.py @@ -0,0 +1,13 @@ +from fmtr.tools import env, Path, net +from haco.paths import paths + +STATUS = 'status' +HOSTNAME = net.get_hostname().lower() +F = net.get_fqdn() +MAC = net.MAC() + +CLIENT_ID = f'{HOSTNAME}-{MAC.hex}' + +TOPIC_ROOT = Path(paths.name) / env.CHANNEL +TOPIC_CLIENT = TOPIC_ROOT / CLIENT_ID +TOPIC_AVAIL = TOPIC_CLIENT / STATUS diff --git a/haco/control.py b/haco/control.py index d4dd59f..81c0eb4 100644 --- a/haco/control.py +++ b/haco/control.py @@ -13,7 +13,6 @@ if TYPE_CHECKING: from haco.utils import sanitize_name - class Control(dm.Base): name: str platform: str @@ -34,8 +33,15 @@ class Control(dm.Base): @computed_field @property def unique_id(self) -> str: - name_san = sanitize_name(self.name) - return f"{self.device.name_san}-{name_san}" + return f"{self.device.name_san}-{self.name_san}" + + @property + def name_san(self) -> str: + return sanitize_name(self.name) + + @property + def topic(self): + return self.device.topic / self.name_sanitized @property def announce_topic(self): @@ -44,7 +50,7 @@ class Control(dm.Base): @computed_field @property def availability_topic(self) -> str: - return self.device.availability_topic + return self.device.client.will.topic @property def announce(self) -> dict: diff --git a/haco/device.py b/haco/device.py index 8cd3698..f418855 100644 --- a/haco/device.py +++ b/haco/device.py @@ -6,6 +6,7 @@ from typing import List from pydantic import Field, computed_field, model_validator from fmtr.tools import dm +from haco import constants from haco.control import Control from haco.utils import sanitize_name @@ -17,13 +18,14 @@ class Device(dm.Base): controls: List[Control] = Field(default_factory=list, exclude=True, repr=False) + @cached_property + def topic(self): + return constants.TOPIC_CLIENT / self.name_san + @property def name_san(self) -> str: return sanitize_name(self.name) - @property - def availability_topic(self) -> str: - return f'status/{self.name_san}/availability' @computed_field @property @@ -42,8 +44,12 @@ class Device(dm.Base): return self @cached_property - def announces(self) -> list[dict]: - return [control.announce for control in self.controls] + def announce(self) -> dict: + data = {} + for capability in self.capabilities: + data |= capability.announce + + return data @cached_property def subscriptions(self) -> dict: diff --git a/haco/paths.py b/haco/paths.py new file mode 100644 index 0000000..11c1c70 --- /dev/null +++ b/haco/paths.py @@ -0,0 +1,3 @@ +from fmtr.tools import sets + +paths = sets.PackagePaths() diff --git a/haco/sb1.py b/haco/sb1.py new file mode 100644 index 0000000..aaf898f --- /dev/null +++ b/haco/sb1.py @@ -0,0 +1,89 @@ +import asyncio +import json + +import aiomqtt + +MQTT_HOST = "mqtt.service" +MQTT_PORT = 1883 +MQTT_USERNAME = "user" +MQTT_PASSWORD = None + +DEVICE_ID = "haco_sandbox" +ENTITY_ID = "demo_switch" +DEVICE_NAME = "Haco Sandbox Device" +ENTITY_NAME = "Demo Switch" + +# Topics +CONFIG_TOPIC = f"homeassistant/switch/{ENTITY_ID}/config" +STATE_TOPIC = f"haco/{DEVICE_ID}/switch/state" +COMMAND_TOPIC = f"haco/{DEVICE_ID}/switch/set" +AVAIL_TOPIC = f"haco/{DEVICE_ID}/status" + + +async def publish_discovery(client): + """Announce the entity to Home Assistant (retained).""" + config = { + "name": ENTITY_NAME, + "unique_id": ENTITY_ID, + "state_topic": STATE_TOPIC, + "command_topic": COMMAND_TOPIC, + "availability_topic": AVAIL_TOPIC, + "payload_on": "ON", + "payload_off": "OFF", + "payload_available": "online", + "payload_not_available": "offline", + "device": { + "identifiers": [DEVICE_ID], + "name": DEVICE_NAME, + "manufacturer": "Demo", + "model": "Python MQTT Example" + } + } + + await client.publish(CONFIG_TOPIC, json.dumps(config), retain=True) + print(f"📢 Announced entity via {CONFIG_TOPIC}") + + +async def handle_commands(client): + """Listen for command messages from HA.""" + async with client.messages() as messages: + await client.subscribe(COMMAND_TOPIC) + async for message in messages: + payload = message.payload.decode() + print(f"📥 Received command: {payload}") + + # Echo back as new state + await client.publish(STATE_TOPIC, payload, retain=True) + + +async def main(): + while True: + try: + async with aiomqtt.Client( + hostname=MQTT_HOST, + port=MQTT_PORT, + username=MQTT_USERNAME, + password=MQTT_PASSWORD, + will=aiomqtt.Will( + topic=AVAIL_TOPIC, + payload="offline", + retain=True, + qos=1, + ), + ) as client: + + # Online now + await client.publish(AVAIL_TOPIC, "online", retain=True) + await publish_discovery(client) + await client.publish(STATE_TOPIC, "OFF", retain=True) + + # Wait for commands + await handle_commands(client) + + except aiomqtt.MqttError as e: + print(f"⚠️ MQTT disconnected: {e}; retrying in 5s") + await asyncio.sleep(5) + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/haco/sb2.py b/haco/sb2.py new file mode 100644 index 0000000..6d48106 --- /dev/null +++ b/haco/sb2.py @@ -0,0 +1,108 @@ +import asyncio +import random + +import aiomqtt + +from fmtr.tools import Constants, mqtt +from fmtr.tools.json_tools import to_json +from haco import constants + + +async def handle_commands(client, control): + """Listen for command messages from HA.""" + + subs = control.subscriptions + + async with client.messages() as messages: + + for topic_sub in subs.keys(): + await client.subscribe(topic_sub) + + async for message in messages: + payload = message.payload.decode() + print(f"{message.topic.value}{Constants.ARROW}{payload}") + method = subs[message.topic.value] + echo_val = method(payload) + echo_val + + # Echo back as new state + # await client.publish(STATE_TOPIC, payload, retain=True) + + +async def background_task(client, control): + while True: + await asyncio.sleep(10) + cap = control.capabilities[1] + value = random.randint(18, 24) + print(f'human is setting temperature to {value}') + await client.publish(cap.state.topic, payload=to_json(value), retain=True) + + +class ClientHaco(mqtt.Client): + + def __init__(self, *args, device=None, will=None, client_id=None, **kwargs): + self.will = will or mqtt.Will(topic=str(constants.TOPIC_AVAIL), payload="offline", retain=True, qos=1, ) + client_id = client_id or constants.CLIENT_ID + self.device = device + # self.device.client = self + super().__init__(*args, will=self.will, client_id=client_id, **kwargs) + + +async def main(): + # Define capabilities + + # device = Device( + # name="Development Device", + # controls=[ + # Climate( + # #id="climate_living_room", + # name="Climate Control", + # fan_modes=['a','b','c'], + # ) + # ] + # + # ) + + # announce=device.announce + # subs=device.subscriptions + + MQTT_HOST = "mqtt.service" + MQTT_PORT = 1883 + MQTT_USERNAME = "user" + MQTT_PASSWORD = None + + while True: + try: + async with ClientHaco( + hostname=MQTT_HOST, + port=MQTT_PORT, + username=MQTT_USERNAME, + password=MQTT_PASSWORD, + + client_id=constants.CLIENT_ID, + # device=device, + ) as client: + + # for topic, data in announce.items(): + # data_json = to_json(data) + # print(f'Announcing {topic} with {data_json}') + # await client.publish(topic, payload=data_json, retain=True) + + # Online now + await client.publish(client.will.topic, "online", retain=True) + + # await publish_discovery(client) + # await client.publish(STATE_TOPIC, "OFF", retain=True) + + # Wait for commands + # asyncio.create_task(background_task(client,control=climate)) + # await handle_commands(client,control=climate) + client + + except aiomqtt.MqttError as e: + print(f"⚠️ MQTT disconnected: {e}") + # await asyncio.sleep(5) + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/haco/topics.py b/haco/topics.py index 2c19a44..c469123 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -5,11 +5,14 @@ from typing import ClassVar, TYPE_CHECKING from pydantic import PrivateAttr -from fmtr.tools import dm +from fmtr.tools import dm, env, Path +from haco.paths import paths if TYPE_CHECKING: from haco.capabilities import Capability +TOPIC_ROOT = Path(paths.name) / env.CHANNEL + class AnnounceTopic(dm.Base): IO: ClassVar[str | None] = None @@ -32,7 +35,7 @@ class AnnounceTopic(dm.Base): @property def fills(self): return dict( - path=str(self.capability.control.device.name_san), + path=str(self.capability.control.topic), capability=self.capability.name, io=self.IO ) diff --git a/haco/v0/haco/__init__.py b/haco/v0/haco/__init__.py index 8787f1e..e69de29 100644 --- a/haco/v0/haco/__init__.py +++ b/haco/v0/haco/__init__.py @@ -1,28 +0,0 @@ -from haco import tuya -from .button import Button -from .callback import Response -from .climate import Climate -from .fan import Fan -from .number import Number -from .pulldown import Select -from .sensor import Sensor -from .switch import Switch -from .tasmota import Tasmota -from .text import Text, Password -from .update import Update - -__all__ = [ - "Button", - "Select", - "Sensor", - "Tasmota", - "Number", - "Switch", - "Text", - "Password", - "Update", - "Climate", - "Fan", - "Response", - "tuya" -] diff --git a/haco/v0/haco/button.py b/haco/v0/haco/button.py index 4004dd8..b7b7216 100644 --- a/haco/v0/haco/button.py +++ b/haco/v0/haco/button.py @@ -1,6 +1,7 @@ -from haco.control import Control - +import haco.capabilities +import haco.topics from haco import schema +from haco.control import Control class Button(Control): @@ -10,8 +11,8 @@ class Button(Control): def get_schema(cls): return schema.Schema( capabilities=[ - schema.Capability( - ha=schema.HomeAssistant(announce_data=schema.AnnounceTopic(key='{io_ha}_topic')), + haco.capabilities.Capability( + ha=schema.HomeAssistant(announce_data=haco.topics.AnnounceTopic(key='{io_ha}_topic')), tasmota=None ) ] diff --git a/haco/v0/haco/control.py b/haco/v0/haco/control.py index 16ce18c..af6cfbe 100644 --- a/haco/v0/haco/control.py +++ b/haco/v0/haco/control.py @@ -1,11 +1,12 @@ import logging from functools import partial -import haco.constants from haco.callback import Callback from haco.schema import Schema, Platform, Tasmota, HomeAssistant, AnnounceTopic, Capability from haco.tools import log_publish +import haco.constants +import haco.utils from haco import tools, constants @@ -42,7 +43,7 @@ class Control: @property def name_sanitized(self): - return tools.sanitize_name(self.name) + return haco.utils.sanitize_name(self.name) def callback(self, trigger=None): return partial(self.add_callback, trigger) diff --git a/haco/v0/haco/device.py b/haco/v0/haco/device.py index 3583e32..21a3cf5 100644 --- a/haco/v0/haco/device.py +++ b/haco/v0/haco/device.py @@ -2,11 +2,12 @@ import json from pathlib import Path from typing import List -from haco.control import Control from haco.device_data import DeviceData from haco.tools import log_publish, split_into_chunks, log_subscribe +import haco.utils from haco import tools, constants +from haco.control import Control class Device: @@ -29,7 +30,7 @@ class Device: @property def name_sanitized(self): - return tools.sanitize_name(self.data_announce.name) + return haco.utils.sanitize_name(self.data_announce.name) @property def mac_short(self): diff --git a/haco/v0/haco/sensor.py b/haco/v0/haco/sensor.py index 425ee0f..191d2b3 100644 --- a/haco/v0/haco/sensor.py +++ b/haco/v0/haco/sensor.py @@ -1,9 +1,11 @@ -from haco.control import Control - -from haco import schema from haco.data.type_sensor import DeviceClassSensor from haco.data.uom import Uom +import haco.capabilities +import haco.topics +from haco import schema +from haco.control import Control + class Sensor(Control): NAME = 'sensor' @@ -15,9 +17,9 @@ class Sensor(Control): def get_schema(cls): return schema.Schema( capabilities=[ - schema.Capability( + haco.capabilities.Capability( ha=None, - tasmota=schema.Tasmota(announce_data=schema.AnnounceTopic(key='{io_ha}_topic')) + tasmota=schema.Tasmota(announce_data=haco.topics.AnnounceTopic(key='{io_ha}_topic')) ) ] ) diff --git a/haco/v0/haco/tools.py b/haco/v0/haco/tools.py index 674c8b4..d7ac9e7 100644 --- a/haco/v0/haco/tools.py +++ b/haco/v0/haco/tools.py @@ -62,21 +62,7 @@ def invert_bool(value): return {True: 'ON', False: 'OFF', 'ON': True, 'OFF': False}[value] -def sanitize_name(s, sep='-'): - chars = [] - for c in s.lower(): - if c in constants.SEPS: - chars.append(sep) - elif c in constants.CHARS_ALLOWED: - chars.append(c) - - sanitized = ''.join(chars) - - if not sanitized: - raise ValueError("Sanitized string is empty") - - return sanitized def add_tuya_io(control, control_type, type_id, dp_id): From a3e98abde39083f9e856332b8442706dcf072625 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 19 Nov 2025 14:00:44 +0000 Subject: [PATCH 081/183] Simplify implementation using dataclasses etc --- haco/base.py | 25 +++++++++++++ haco/capabilities.py | 47 ++++++++++++------------- haco/client.py | 16 +++++++++ haco/climate.py | 10 +++--- haco/constants.py | 4 +++ haco/control.py | 84 +++++++++++++++++++------------------------- haco/device.py | 42 +++++++++++++--------- haco/sb1.py | 5 +-- haco/sb3.py | 20 +++++++++++ haco/topics.py | 47 ++++++++++++------------- haco/utils.py | 6 ++++ 11 files changed, 185 insertions(+), 121 deletions(-) create mode 100644 haco/base.py create mode 100644 haco/sb3.py diff --git a/haco/base.py b/haco/base.py new file mode 100644 index 0000000..68e5560 --- /dev/null +++ b/haco/base.py @@ -0,0 +1,25 @@ +from __future__ import annotations + +from dataclasses import dataclass, fields +from typing import Any + + +@dataclass(kw_only=True) +class Base: + def model_dump(self) -> dict[str, Any]: + 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 diff --git a/haco/capabilities.py b/haco/capabilities.py index b5911da..3eb75ed 100644 --- a/haco/capabilities.py +++ b/haco/capabilities.py @@ -1,39 +1,36 @@ -from typing import Optional +from __future__ import annotations -from pydantic import Field, model_validator +from dataclasses import dataclass, field +from typing import TYPE_CHECKING -from fmtr.tools import dm -from fmtr.tools.iterator_tools import strip_none -from haco.control import Control +from haco.base import Base from haco.topics import AnnounceTopicState, AnnounceTopicCommand +if TYPE_CHECKING: + from haco.control import Control -class Capability(dm.Base): + +@dataclass(kw_only=True) +class Capability(Base): name: str - alias: str = None - 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 - control: Optional[Control] = Field(None, exclude=True, repr=False) + def set_parent(self, control): + self.parent = control + for topic in (t for t in (self.state, self.command) if t): + topic.set_parent(self) + self.announce = self.get_announce() - @property - def announce(self) -> dict: + def get_announce(self) -> dict: data = {} - for topic in strip_none(self.state, self.command): + for topic in (t for t in (self.state, self.command) if t): data |= topic.announce return data @property - def subscriptions(self): - - if not self.command: - return {} - - return self.command.subscriptions - - @model_validator(mode="after") - def attach_parent(self): - for topic in strip_none(self.state, self.command): - topic.capability = self - return self + def control(self): + return self.parent diff --git a/haco/client.py b/haco/client.py index e69de29..c3b39f5 100644 --- a/haco/client.py +++ b/haco/client.py @@ -0,0 +1,16 @@ +from fmtr.tools import mqtt +from haco import constants + + +class ClientHaco(mqtt.Client): + + def __init__(self, *args, device=None, will=None, client_id=None, **kwargs): + self.will = will or mqtt.Will(topic=str(constants.TOPIC_AVAIL), payload="offline", retain=True, qos=1, ) + client_id = client_id or constants.CLIENT_ID + self.device = device + self.device.set_parent(self) + super().__init__(*args, will=self.will, client_id=client_id, **kwargs) + + @property + def topic(self): + return constants.TOPIC_CLIENT diff --git a/haco/climate.py b/haco/climate.py index 28c0b97..95c6c36 100644 --- a/haco/climate.py +++ b/haco/climate.py @@ -1,9 +1,11 @@ -from typing import Literal, Optional, List +from dataclasses import dataclass +from typing import List, Optional, Literal -from haco.capabilities import Capability -from haco.control import Control +from capabilities import Capability +from control import Control +@dataclass(kw_only=True) class Climate(Control): platform: Literal["climate"] = "climate" temperature_unit: Literal["C", "F"] = "C" @@ -21,7 +23,7 @@ class Climate(Control): return value @classmethod - def get_capabilities(self): + def get_capabilities(cls): return [ Capability(name="current_temperature", command=None), Capability(name="temperature"), diff --git a/haco/constants.py b/haco/constants.py index 2a36fb7..ad1dc52 100644 --- a/haco/constants.py +++ b/haco/constants.py @@ -11,3 +11,7 @@ CLIENT_ID = f'{HOSTNAME}-{MAC.hex}' TOPIC_ROOT = Path(paths.name) / env.CHANNEL TOPIC_CLIENT = TOPIC_ROOT / CLIENT_ID TOPIC_AVAIL = TOPIC_CLIENT / STATUS +MQTT_HOST = "mqtt.service" +MQTT_PORT = 1883 +MQTT_USERNAME = "user" +MQTT_PASSWORD = None diff --git a/haco/control.py b/haco/control.py index 81c0eb4..b5e1b6c 100644 --- a/haco/control.py +++ b/haco/control.py @@ -1,36 +1,52 @@ from __future__ import annotations -from functools import cached_property -from typing import Optional, TYPE_CHECKING - -from pydantic import computed_field, model_validator, PrivateAttr - -from fmtr.tools import dm - -if TYPE_CHECKING: - from haco.capabilities import Capability - from haco.device import Device +from dataclasses import dataclass, field +from typing import TYPE_CHECKING +from haco.base import Base +from haco.capabilities import Capability from haco.utils import sanitize_name -class Control(dm.Base): +if TYPE_CHECKING: + from haco.device import Device + + +@dataclass(kw_only=True) +class Control(Base): name: str platform: str - icon: Optional[str] = None + device: Device = field(default=None) + capabilities: None | list[Capability] = field(default=None, metadata=dict(exclude=True)) + announce: dict | None = field(default=None, metadata=dict(exclude=True)) + + def __post_init__(self): + self.caps = self.get_capabilities() + + def set_parent(self, device): + self.device = device + for cap in self.caps: + cap.set_parent(self) + self.announce = self.get_announce() + - _device: Device = PrivateAttr(default=None) - @computed_field @property - def device(self) -> Device: # todo. quite ugly. perhaps just use @dataclass for topics? - return self._device + def parent(self): + return self.device - @device.setter - def device(self, value: Device): - self._device = value + def get_announce(self): + data = self.model_dump() + for cap in self.caps: + data |= cap.announce + + data = {self.announce_topic: data} + return data + + @classmethod + def get_capabilities(cls): + raise NotImplementedError() - @computed_field @property def unique_id(self) -> str: return f"{self.device.name_san}-{self.name_san}" @@ -41,27 +57,16 @@ class Control(dm.Base): @property def topic(self): - return self.device.topic / self.name_sanitized + return self.device.topic / self.name_san @property def announce_topic(self): return f"homeassistant/{self.platform}/{self.unique_id}/config" - @computed_field @property def availability_topic(self) -> str: return self.device.client.will.topic - @property - def announce(self) -> dict: - - data = self.model_dump(mode="json", exclude_none=True) - for capability in self.capabilities: - data |= capability.announce - - data = {self.announce_topic: data} - return data - @property def subscriptions(self) -> dict: @@ -71,18 +76,3 @@ class Control(dm.Base): data |= capability.subscriptions return data - - @model_validator(mode="after") - def attach_parent(self): - self.capabilities = self.get_capabilities() - for capability in self.capabilities: - capability.control = self - return self - - @classmethod - def get_capabilities(cls): - raise NotImplementedError() - - @cached_property - def capabilities(self) -> list[Capability]: - return self.get_capabilities() diff --git a/haco/device.py b/haco/device.py index f418855..1c387f1 100644 --- a/haco/device.py +++ b/haco/device.py @@ -1,26 +1,38 @@ from __future__ import annotations +from dataclasses import dataclass, field from functools import cached_property -from typing import List +from typing import List, TYPE_CHECKING -from pydantic import Field, computed_field, model_validator +from pydantic import computed_field -from fmtr.tools import dm -from haco import constants +from haco.base import Base from haco.control import Control from haco.utils import sanitize_name +if TYPE_CHECKING: + from haco.client import ClientHaco -class Device(dm.Base): + +@dataclass(kw_only=True) +class Device(Base): name: str manufacturer: str = "Demo" model: str = "Python MQTT Example" - controls: List[Control] = Field(default_factory=list, exclude=True, repr=False) + controls: List[Control] = field(default_factory=list, metadata=dict(exclude=True)) + parent: ClientHaco | None = field(metadata=dict(exclude=True)) + announce: dict | None = field(default=None, metadata=dict(exclude=True)) + + def set_parent(self, client): + self.parent = client + for control in self.controls: + control.set_parent(self) + self.announce = self.get_announce() @cached_property def topic(self): - return constants.TOPIC_CLIENT / self.name_san + return self.client.topic / self.name_san @property def name_san(self) -> str: @@ -37,20 +49,16 @@ class Device(dm.Base): def connections(self) -> list[list[str]]: return [["mac", "AA:BB:CC:DD:EE:FF"]] - @model_validator(mode="after") - def attach_parent(self): - for control in self.controls: - control.device = self - return self - - @cached_property - def announce(self) -> dict: + def get_announce(self): data = {} - for capability in self.capabilities: + for capability in self.controls: data |= capability.announce - return data + @property + def client(self): + return self.parent + @cached_property def subscriptions(self) -> dict: data = {} diff --git a/haco/sb1.py b/haco/sb1.py index aaf898f..acb0af8 100644 --- a/haco/sb1.py +++ b/haco/sb1.py @@ -3,10 +3,7 @@ import json import aiomqtt -MQTT_HOST = "mqtt.service" -MQTT_PORT = 1883 -MQTT_USERNAME = "user" -MQTT_PASSWORD = None +from haco.constants import MQTT_HOST, MQTT_PORT, MQTT_USERNAME, MQTT_PASSWORD DEVICE_ID = "haco_sandbox" ENTITY_ID = "demo_switch" diff --git a/haco/sb3.py b/haco/sb3.py new file mode 100644 index 0000000..5839263 --- /dev/null +++ b/haco/sb3.py @@ -0,0 +1,20 @@ +from haco.client import ClientHaco +from haco.climate import Climate +from haco.constants import MQTT_HOST +from haco.device import Device + +client = ClientHaco( + + hostname=MQTT_HOST, + + device=Device( + parent=None, + name='dev-device', + controls=[ + Climate(name='Dev Climate A', platform='climate'), + Climate(name='Dev Climate B', platform='climate'), + ] + ) +) + +client diff --git a/haco/topics.py b/haco/topics.py index c469123..14b5cbd 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -1,33 +1,25 @@ from __future__ import annotations +from dataclasses import dataclass, field from functools import cached_property from typing import ClassVar, TYPE_CHECKING -from pydantic import PrivateAttr - -from fmtr.tools import dm, env, Path -from haco.paths import paths - if TYPE_CHECKING: - from haco.capabilities import Capability - -TOPIC_ROOT = Path(paths.name) / env.CHANNEL + from capabilities import Capability -class AnnounceTopic(dm.Base): +@dataclass(kw_only=True) +class AnnounceTopic: IO: ClassVar[str | None] = None key: str = '{capability}_{io}_topic' value: str = '{path}/{capability}/{io}' - _capability: Capability = PrivateAttr(default=None) + parent: Capability | None = None + announce: dict | None = field(default=None, metadata=dict(exclude=True)) - @property - def capability(self) -> Capability: # todo. quite ugly. perhaps just use @dataclass for topics? - return self._capability - - @capability.setter - def capability(self, value: Capability): - self._capability = value + def set_parent(self, control): + self.parent = control + self.announce = self.get_announce() def fill(self, mask): return mask.format(**self.fills) @@ -48,31 +40,38 @@ class AnnounceTopic(dm.Base): def topic(self): return self.fill(self.value) - @property - def announce(self): - data = {self.topic_key: self.topic} - return data + def get_announce(self): + return {self.topic_key: self.topic} @property def callback_name(self): return f'{self.capability.name}_{self.IO}' + @property + def subscriptions(self): + return {} + @cached_property + def capability(self): + return self.parent + + +@dataclass(kw_only=True) class AnnounceTopicState(AnnounceTopic): - IO = 'state' + IO: ClassVar[str] = 'state' @property def subscriptions(self): return {} +@dataclass(kw_only=True) class AnnounceTopicCommand(AnnounceTopic): - IO = 'command' + IO: ClassVar[str] = 'command' @property def subscriptions(self): method = getattr(self.capability.control, self.callback_name, None) if not method: return {} - return {self.topic: method} diff --git a/haco/utils.py b/haco/utils.py index 99c0be2..4ce9777 100644 --- a/haco/utils.py +++ b/haco/utils.py @@ -1,4 +1,5 @@ import string +from dataclasses import dataclass CHARS_ALLOWED = string.ascii_lowercase + string.digits SEPS = '_- /' @@ -25,3 +26,8 @@ def sanitize_name(s, sep='-'): raise ValueError("Sanitized string is empty") return sanitized + + +@dataclass +class Metadata: + exclude: bool = False From a568e35d0ba0adb97a15242a748a2d5e59f13521 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 20 Nov 2025 09:32:29 +0000 Subject: [PATCH 082/183] Fix Device computed fields order --- haco/control.py | 16 ++++++++++++---- haco/device.py | 31 ++++++++++++++++++------------- haco/sb3.py | 14 +++++--------- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/haco/control.py b/haco/control.py index b5e1b6c..1ebded7 100644 --- a/haco/control.py +++ b/haco/control.py @@ -21,11 +21,11 @@ class Control(Base): announce: dict | None = field(default=None, metadata=dict(exclude=True)) def __post_init__(self): - self.caps = self.get_capabilities() + self.capabilities = self.get_capabilities() def set_parent(self, device): self.device = device - for cap in self.caps: + for cap in self.capabilities: cap.set_parent(self) self.announce = self.get_announce() @@ -37,7 +37,7 @@ class Control(Base): def get_announce(self): data = self.model_dump() - for cap in self.caps: + for cap in self.capabilities: data |= cap.announce data = {self.announce_topic: data} @@ -45,7 +45,10 @@ class Control(Base): @classmethod def get_capabilities(cls): - raise NotImplementedError() + return [ + Capability(name='default') + ] + @property def unique_id(self) -> str: @@ -76,3 +79,8 @@ class Control(Base): data |= capability.subscriptions return data + + +if __name__ == "__main__": + control = Control(name="test", platform="test") + control diff --git a/haco/device.py b/haco/device.py index 1c387f1..c815ed7 100644 --- a/haco/device.py +++ b/haco/device.py @@ -4,8 +4,6 @@ from dataclasses import dataclass, field from functools import cached_property from typing import List, TYPE_CHECKING -from pydantic import computed_field - from haco.base import Base from haco.control import Control from haco.utils import sanitize_name @@ -20,16 +18,26 @@ class Device(Base): manufacturer: str = "Demo" model: str = "Python MQTT Example" + identifiers: list[str] | None = field(default=None, init=False) + controls: List[Control] = field(default_factory=list, metadata=dict(exclude=True)) parent: ClientHaco | None = field(metadata=dict(exclude=True)) announce: dict | None = field(default=None, metadata=dict(exclude=True)) + # def __post_init__(self): + # self.identifiers=['ident'] + def set_parent(self, client): self.parent = client + + self.identifiers = [self.name_san] + for control in self.controls: control.set_parent(self) self.announce = self.get_announce() + self + @cached_property def topic(self): return self.client.topic / self.name_san @@ -38,18 +46,8 @@ class Device(Base): def name_san(self) -> str: return sanitize_name(self.name) - - @computed_field - @property - def identifiers(self) -> list[str]: - return [self.name_san] - - @computed_field - @property - def connections(self) -> list[list[str]]: - return [["mac", "AA:BB:CC:DD:EE:FF"]] - def get_announce(self): + data = {} for capability in self.controls: data |= capability.announce @@ -66,3 +64,10 @@ class Device(Base): data |= control.subscriptions return data + + +if __name__ == "__main__": + control = Control(name="test", platform="test") + device = Device(name="test", parent=None, controls=[control]) + data = device.model_dump() + print(device.topic) diff --git a/haco/sb3.py b/haco/sb3.py index 5839263..5487d1a 100644 --- a/haco/sb3.py +++ b/haco/sb3.py @@ -1,20 +1,16 @@ from haco.client import ClientHaco -from haco.climate import Climate from haco.constants import MQTT_HOST +from haco.control import Control from haco.device import Device +control = Control(name="test", platform="test") +device = Device(name="test", parent=None, controls=[control]) + client = ClientHaco( hostname=MQTT_HOST, - device=Device( - parent=None, - name='dev-device', - controls=[ - Climate(name='Dev Climate A', platform='climate'), - Climate(name='Dev Climate B', platform='climate'), - ] - ) + device=device ) client From 4d35286ff91e9cd712da707ab2133ebe82429baa Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Thu, 20 Nov 2025 12:34:50 +0000 Subject: [PATCH 083/183] Refine data model/announce and subscriptions and add sandbox command/wrapper/callback/state workflow - and adapt for aiomqtt v2 --- haco/v0/README.md => README.md | 0 build.env | 2 +- haco/capabilities.py | 11 +++++++++ haco/client.py | 33 +++++++++++++++++++++---- haco/climate.py | 16 +++++++++++++ haco/control.py | 24 ++++++++++++------- haco/device.py | 12 +++++----- haco/sb3.py | 44 +++++++++++++++++++++++++++------- haco/topics.py | 30 +++++++++++++++-------- setup.py | 3 +-- 10 files changed, 136 insertions(+), 39 deletions(-) rename haco/v0/README.md => README.md (100%) diff --git a/haco/v0/README.md b/README.md similarity index 100% rename from haco/v0/README.md rename to README.md diff --git a/build.env b/build.env index 8d30f31..40d5026 100644 --- a/build.env +++ b/build.env @@ -1,4 +1,4 @@ -CHANNEL="prod" +CHANNEL="dev" #ORG="fmtr" PACKAGE="haco" PORT="06" diff --git a/haco/capabilities.py b/haco/capabilities.py index 3eb75ed..a03d070 100644 --- a/haco/capabilities.py +++ b/haco/capabilities.py @@ -16,6 +16,8 @@ class Capability(Base): state: AnnounceTopicState | None = field(default_factory=AnnounceTopicState) command: AnnounceTopicCommand | None = field(default_factory=AnnounceTopicCommand) + subscriptions: dict | None = field(default=None, metadata=dict(exclude=True), init=False) + parent: Control | None = None announce = None @@ -23,6 +25,9 @@ class Capability(Base): self.parent = control for topic in (t for t in (self.state, self.command) if t): topic.set_parent(self) + + self.subscriptions = self.get_subscriptions() + self.announce = self.get_announce() def get_announce(self) -> dict: @@ -34,3 +39,9 @@ class Capability(Base): @property def control(self): return self.parent + + def get_subscriptions(self) -> dict: + data = {} + for topic in (t for t in (self.state, self.command) if t): + data |= topic.subscriptions + return data diff --git a/haco/client.py b/haco/client.py index c3b39f5..9da8fd7 100644 --- a/haco/client.py +++ b/haco/client.py @@ -1,16 +1,41 @@ -from fmtr.tools import mqtt +import aiomqtt + +from fmtr.tools import mqtt, Constants from haco import constants +aiomqtt.Client class ClientHaco(mqtt.Client): - def __init__(self, *args, device=None, will=None, client_id=None, **kwargs): + def __init__(self, *args, device=None, will=None, identifier=None, **kwargs): self.will = will or mqtt.Will(topic=str(constants.TOPIC_AVAIL), payload="offline", retain=True, qos=1, ) - client_id = client_id or constants.CLIENT_ID + identifier = identifier or constants.CLIENT_ID self.device = device self.device.set_parent(self) - super().__init__(*args, will=self.will, client_id=client_id, **kwargs) + super().__init__(*args, will=self.will, identifier=identifier, **kwargs) @property def topic(self): return constants.TOPIC_CLIENT + + async def handle(self): + """Listen for command messages from HA.""" + + # subs = control.subscriptions + + for topic_sub in self.device.subscriptions.keys(): + print(f"Subscribing to {topic_sub}") + await self.subscribe(topic_sub) + + async for message in self.messages: + payload = message.payload.decode() + print(f"{message.topic.value}{Constants.ARROW}{payload}") + topic_command = self.device.subscriptions[message.topic.value] + echo_val = topic_command.wrap_back(message) + echo_val + + topic_state = topic_command.state + await topic_state.wrap_back(echo_val) + + # Echo back as new state + # await self.publish(STATE_TOPIC, payload, retain=True) diff --git a/haco/climate.py b/haco/climate.py index 95c6c36..154045c 100644 --- a/haco/climate.py +++ b/haco/climate.py @@ -22,6 +22,21 @@ class Climate(Control): def temperature_command(self, value): return value + def mode_command(self, value): + return value + + def fan_mode_command(self, value): + return value + + def fan_mode_state(self, value): + return value + + def power_command(self, value): + return value + + def power_state(self, value): + return value + @classmethod def get_capabilities(cls): return [ @@ -31,4 +46,5 @@ class Climate(Control): Capability(name="target_humidity"), Capability(name="mode"), Capability(name="fan_mode"), + Capability(name="power"), ] diff --git a/haco/control.py b/haco/control.py index 1ebded7..237eea5 100644 --- a/haco/control.py +++ b/haco/control.py @@ -16,17 +16,29 @@ class Control(Base): name: str platform: str - device: Device = field(default=None) + device: Device = 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) + 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): self.capabilities = self.get_capabilities() def set_parent(self, device): self.device = device + for cap in self.capabilities: cap.set_parent(self) + + self.unique_id = self.get_unique_id() + self.availability_topic = self.get_availability_topic() + self.subscriptions = self.get_subscriptions() + + + self.announce = self.get_announce() @@ -49,9 +61,7 @@ class Control(Base): Capability(name='default') ] - - @property - def unique_id(self) -> str: + def get_unique_id(self) -> str: return f"{self.device.name_san}-{self.name_san}" @property @@ -66,12 +76,10 @@ class Control(Base): def announce_topic(self): return f"homeassistant/{self.platform}/{self.unique_id}/config" - @property - def availability_topic(self) -> str: + def get_availability_topic(self) -> str: return self.device.client.will.topic - @property - def subscriptions(self) -> dict: + def get_subscriptions(self) -> dict: data = {} diff --git a/haco/device.py b/haco/device.py index c815ed7..f28e16b 100644 --- a/haco/device.py +++ b/haco/device.py @@ -21,11 +21,11 @@ class Device(Base): identifiers: list[str] | None = field(default=None, init=False) controls: List[Control] = field(default_factory=list, metadata=dict(exclude=True)) - parent: ClientHaco | None = field(metadata=dict(exclude=True)) - announce: dict | None = field(default=None, metadata=dict(exclude=True)) - # def __post_init__(self): - # self.identifiers=['ident'] + 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) + def set_parent(self, client): self.parent = client @@ -35,6 +35,7 @@ class Device(Base): for control in self.controls: control.set_parent(self) self.announce = self.get_announce() + self.subscriptions = self.get_subscriptions() self @@ -57,8 +58,7 @@ class Device(Base): def client(self): return self.parent - @cached_property - def subscriptions(self) -> dict: + def get_subscriptions(self) -> dict: data = {} for control in self.controls: data |= control.subscriptions diff --git a/haco/sb3.py b/haco/sb3.py index 5487d1a..ee9fdda 100644 --- a/haco/sb3.py +++ b/haco/sb3.py @@ -1,16 +1,44 @@ +import asyncio + +import aiomqtt + +from fmtr.tools.json_tools import to_json from haco.client import ClientHaco +from haco.climate import Climate from haco.constants import MQTT_HOST -from haco.control import Control from haco.device import Device -control = Control(name="test", platform="test") -device = Device(name="test", parent=None, controls=[control]) -client = ClientHaco( +async def main(): + climate_a = Climate(name="Dev Climate A", fan_modes=['a', 'b', 'c']) + climate_b = Climate(name="Dev Climate B", fan_modes=['a', 'b', 'c']) + device = Device(name="Dev Device", controls=[climate_a, climate_b]) - hostname=MQTT_HOST, + client = ClientHaco(hostname=MQTT_HOST, device=device) - device=device -) + client -client + while True: + try: + async with client: + + for topic, data in device.announce.items(): + data_json = to_json(data) + print(f'Announcing {topic} with {data_json}') + await client.publish(topic, payload=data_json, retain=True) + + # Online now + await client.publish(client.will.topic, "online", retain=True) + + await client.publish('haco/development/3012edb1a6d4-1ed9c3469373/dev-device/dev-climate-b/power/command', "OFF", retain=True) + + # Wait for commands + await client.handle() + + except aiomqtt.MqttError as e: + print(f"⚠️ MQTT disconnected: {e}; retrying in 5s") + await asyncio.sleep(5) + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/haco/topics.py b/haco/topics.py index 14b5cbd..ebea120 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -16,10 +16,12 @@ class AnnounceTopic: 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) - def set_parent(self, control): - self.parent = control + def set_parent(self, capability: Capability): + self.parent = capability self.announce = self.get_announce() + self.subscriptions = self.get_subscriptions() def fill(self, mask): return mask.format(**self.fills) @@ -47,8 +49,7 @@ class AnnounceTopic: def callback_name(self): return f'{self.capability.name}_{self.IO}' - @property - def subscriptions(self): + def get_subscriptions(self): return {} @cached_property @@ -60,18 +61,27 @@ class AnnounceTopic: class AnnounceTopicState(AnnounceTopic): IO: ClassVar[str] = 'state' - @property - def subscriptions(self): + def get_subscriptions(self): return {} + async def wrap_back(self, value): + method = getattr(self.capability.control, self.callback_name, None) + value_raw = method(value) + await self.capability.control.device.client.publish(self.topic, value_raw) + return value_raw @dataclass(kw_only=True) class AnnounceTopicCommand(AnnounceTopic): IO: ClassVar[str] = 'command' @property - def subscriptions(self): + def state(self): + return self.capability.state + + def wrap_back(self, message): method = getattr(self.capability.control, self.callback_name, None) - if not method: - return {} - return {self.topic: method} + value = method(message.payload.decode('utf-8')) + return value + + def get_subscriptions(self): + return {self.topic: self} diff --git a/setup.py b/setup.py index 0d7ce36..d966648 100644 --- a/setup.py +++ b/setup.py @@ -4,8 +4,7 @@ setup = Setup( org=None, dependencies=dict( install=[ - 'fmtr.tools[version.dev,logging,sets,yaml,debug,caching,api]', - 'aiomqtt<2' + 'fmtr.tools[version.dev,logging,sets,yaml,debug,caching,api,mqtt]', ] ), description='Home Assistant Control Objects', From 25075debdf7da5b965cc1b0a35e9c149bde96c40 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 21 Nov 2025 09:58:53 +0000 Subject: [PATCH 084/183] Prep y0 code for release --- README.md | 394 +----------------------------------------------- haco/client.py | 37 +++-- haco/climate.py | 13 +- haco/control.py | 8 +- haco/obs.py | 11 ++ haco/sb3.py | 24 +-- haco/topics.py | 18 ++- haco/version | 2 +- haco/version.py | 3 + 9 files changed, 73 insertions(+), 437 deletions(-) create mode 100644 haco/obs.py create mode 100644 haco/version.py diff --git a/README.md b/README.md index 4ad8ec9..f3bb28c 100644 --- a/README.md +++ b/README.md @@ -1,396 +1,8 @@ # `haco` Home Assistant Control Objects -`haco` is a Home Assistant Add-On, and associated Tasmota daemon written in Berry, to greatly simplify the process of +`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 Tasmota device - and handling the +Assistant controls (e.g. Pull-down Lists, Number Sliders, Sensors, etc.) from a device - and handling the communication between both sides. -Using `haco` to expose, for example, a "Restart Tasmota" button to Home Assistant is as simple as writing the following -Python code: - -```py -from haco import Button, Tasmota - -restart = Button('Restart Tasmota', icon='restart') - - -@restart.callback() -def ha(value) -> Tasmota[str, 'tasmota.cmd("restart 1")']: - return value -``` - -A fully functional restart button will now appear associated with the device in Home Assistant: - -Restart Button - -Or, more practically, a cookbook pull-down menu, for a Tuya air fryer, might look like this: - -```py -OPTIONS = ['Default', 'Fries', 'Shrimp', 'Pizza', 'Chicken', 'Fish', 'Steak', 'Cake', 'Bacon', 'Preheat', 'Custom'] - -cookbook = Select('Cookbook', options=OPTIONS, icon='chef-hat') - - -@cookbook.callback() -def ha(value: str) -> Tasmota[int, tuya.send(4, 3)]: - return OPTIONS.index(value) - - -@cookbook.callback(trigger=tuya.received(4, 3)) -def tasmota(value: int): - return OPTIONS[value] -``` - -Air Fryer Cookbook - -## Do I Need This? Can't I Do this with Native Tasmota? - -You certainly can. - -But in my experience, the process is so fiddly, error-prone and hard to maintain that it's enough to -deter the casual user (as I am) entirely. Plus, sharing your configuration, once you've finally got it working, can mean -complex step-by-step guides, setting up triggers, finding MAC addresses and topics (in Tasmota) - and numerous -Blueprints, Helpers and Templates (on the Home Assistant side). - -You can see how much work creating such guides involves by seeing how it -was [heroically undertaken by Blakadder](https://blakadder.com/proscenic-in-home-assistant/), as -compared with -the [full `haco`-based equivalent](https://github.com/fmtr/haco/blob/release/haco/configs/proscenic_t21.py). - -With `haco`, on the other hand, the thorny parts of the initial setup are abstracted away and your final configuration -can often be shared via a single script. Below is a list of some of the tasks that `haco` -handles for you: - -* Announcing the entity via MQTT to Home Assistant -* Generating MQTT/HA-friendly unique IDs -* Associating the entity with its parent device -* Subscribing and publishing to the relevant MQTT topics -* Managing the relevant Tasmota rules -* Appropriate serialization of data -* Translating Home Assistant messages to their to appropriate Berry data types, and vice versa - -## Pre-Release - -:warning: This library is currently in a pre-release state. The configuration format is likely to change, and -only `Sensor`, `Select`, `Button`, `Number`, `BinarySensor`, `Switch`, `Text`, `Update`, `Fan` -and `Climate` entities are currently implemented. - -## Installation - -Installation involves installing two parts: the Tasmota daemon and the Home Assistant Add-On. Both are fairly simple. - -### Tasmota - -I'd advise first using a guinea pig Tasmota device to get `haco` up and running. The device needs to have MQTT -connected and be available to Home Assistant (i.e. showing up -in [the Devices section](https://my.home-assistant.io/redirect/devices/)). - -Once your test device is ready, with a recent (12.5+) version of Tasmota, simply paste the following into your Tasmota -Berry Script Console: - -```be -{"download":tasmota.urlfetch('https://fmtr.link/haco/tapp','haco.tapp'), "restart":tasmota.cmd("restart 1")} -``` - -You should see output like `{'restart': {'Restart': 'Restarting'}, 'download': 200}` and the device will restart. - -Once the device restarts, you should see the following among your Tasmota startup logs (in the regular console, not the -Berry one): - -``` -HACO: The haco daemon has started. Hostname: tasmota-test, MAC: 04:74:77:9B:CB:CC. Listening for configuration... -``` - -#### Older Tasmota Versions - -With older Tasmota versions, download the [`haco.tapp` file](https://fmtr.link/haco/tapp) on a desktop -computer, -upload it to your device and restart manually. - -### Home Assistant - -You can now install the Home Assistant Add-On: - -[![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://fmtr.link/haco/add-on) - -Once the Add-On is installed, click into its Configuration tab and you'll see a setting called `assignments`: - -```yaml -- config: null - identifier: null -``` - -#### Assigning a configuration module to a device - -Now we're ready to assign a configuration module to our Tasmota device. For now, we can use a built-in test -module `test`. The `identifer` value should be the hostname (or MAC) of your Tasmota device. So for our example it -should look like this: - -```yaml -- config: test - identifier: tasmota-test # Hostname of Tasmota device -``` - -Saving the Configuration will restart the Add-On. After the restart, you should see the following in the Add-On logs: - -``` -Device "Tasmota Test Device" successfully configured. Hostname: tasmota-test MAC: 04:74:77:9B:CB:CC. -``` - -In Home Assistant, find the device in [the Devices section](https://my.home-assistant.io/redirect/devices/). You should -now see a test Select (pulldown) control called "Greeter". - -WebLog Select - -Selecting the greetings from the pulldown, you should see them appear in your Tasmota Berry console, e.g. - -```console -haco says: Hello World! -``` - -This means `haco` is set up and working properly. Good! You can now use `haco` to assign configuration modules to your -Tasmota devices. - -## Configuration Modules - -Configuration modules are a little like drivers, that tell `haco` how to communicate with a Tasmota device, what -controls to expose to Home Assistant, etc. - -So far we've only used the `test` configuration module, that exposed the Greeter pulldown, but to control -real-world devices, you'll need to assign them to a module written specifically for that device. There are currently two -types of modules, -Built-In and User-Defined. - -Whichever type you use, assigning them to a device is done as we saw above. - -### Built-In Modules - -`haco` ships with a small number of built-in configurations. These can be found in -the [configs directory](https://github.com/fmtr/haco/blob/release/haco/configs) in this repo. But in the likely event -that your device hasn't already -been added, you'll need to define your own. - -:information_source: The aim is to expand the number of built-in configurations over time. So if you define your own ( -see below), please submit it to this repo as a Pull Request, or raise an Issue linking to your code! - -### Creating Your Own Configuration Module - -#### General module structure - -A configuration module is, ultimately, just a typical Python module. In this case, they contain definitions from one or -more `Control` objects. Each control definition involves two things: - -* The control object assigned to a variable, e.g. `temperature_sensor=Sensor(...)` -* Any required callback functions for the control, e.g. `@temperature_sensor.callback(...)` - -#### Location - -User-Defined modules should be added to the `/config/haco` directory in Home Assistant, with a `.py` extension, -e.g. `/config/haco/my_config.py`. - -#### Defining controls - -Here are a couple of simple examples to help get you started defining your own configuration module. - -##### Tasmota-Only Controls - -First, let's define a Tasmota-only sensor to report how much free memory there is on the Tasmota device. This sensor -is "Tasmota-Only" as it only handles values sent _from_ Tasmota (and sends nothing back from Home Assistant). - -```python -from haco import Sensor - -memory = Sensor('Memory Free', icon='memory', uom=Sensor.UOM.DATA_KILOBYTES, uom_type=Sensor.UOM_TYPE.DATA_SIZE) - - -@memory.callback(trigger='Tele#Heap') -def tasmota(value: int): - return value - -``` - -Memory Sensor - -Let's break this control definition down into the control object, the callback decorator, and the callback itself. - -###### The control object - -First we initialise a `Sensor` control object, assign it to a variable called `memory`, give it a relevant icon, unit of -measure and type. - -###### The callback decorator - -The callback decorator `@memory.callback(trigger='Tele#Heap')` specifies a Tasmota trigger, the values from which will -be sent to the callback function. -This specific trigger, `Tele#Heap`, fires whenever telemetry data is returned from Tasmota and, specifically, returns -the `Heap` field, which contains the free -memory in kilobytes. - -:warning: Tasmota callbacks _must_ have such a `trigger` specified in this decorator. - -###### The callback - -Note that the callback function is named `tasmota`. This name is important as it tells `haco` that this callback -handles values _from_ Tasmota. - -The response from the trigger we specified in our callback decorator above gets fed into our callback as the `value` -argument. The (optional) type annotation for the `value` argument (the `int`) tells `haco` what data type to expect from -Tasmota, and type conversion gets done automatically. - -The return value from the function is what will be returned to Home Assistant as the value for the sensor. - -:information_source: Note that our callback function does not actually _do_ anything with our `value` other than return -it. But if we wanted to (for example) convert the value from kilobytes to bytes, this is where we'd do it, -with `return value*1000`. - -:information_source: You can find the list of available units of measure [here](../../blob/release/haco/data/uom.py) and -types [here](../../blob/main/haco/data/type_sensor.py). - -#### Home Assistant-Only Controls - -Moving on to the opposite type of control, that is one that only handles values _from_ Home Assistant. The Button -control does -exactly this, as it is triggered by being pressing in Home Assistant, but Tasmota returns nothing to acknowledge that -press. - -Here is how to define a `Button` control that, when pressed, restarts the Tasmota device. - -```py -from haco import Button, Tasmota - -restart = Button('Restart Tasmota', icon='restart') - - -@restart.callback() -def ha(value) -> Tasmota[str, 'tasmota.cmd("restart 1")']: - return value - -``` - -In the case we define a `Button` control, and again use our decorator to add a callback to handle values _from_ Home -Assistant, which must therefore be named `ha`. - -###### The `Tasmota` Type Annotation - -The most notable difference with a Home Assistant (`ha`) callback is the `Tasmota` return type annotation. This takes -two arguments, `Tasmota[,]`. The -first argument is the type returned by the callback function, as per usual, and which again lets `haco` convert the -return value accordingly. - -The second argument is an expression that defines _what to do_ on the Tasmota side when the button is pressed. In this -case, this -is just a Berry expression to restart Tasmota. - -:warning: Note that Home Assistant callbacks _must_ have such a `Tasmota` type annotation for their return type. - -:information_source: In the example above, the `value` argument received and returned by our callback is not actually -used by the Berry expression side. Home Assistant just sends a constant string (`PRESS`) when the button is pressed, so -the actual content of -the `value` argument is not important. - -#### Two-Way Controls - -Two-way controls need to handle values from _both_ Home Assistant and from Tasmota, and hence need both the callbacks -types - `ha` and `tasmota` we've seen above. - -Here is an example two-way `Select` (pulldown menu) object. It allows setting the Tasmota `WebLog` console debugging -level from Home Assistant, and also reflects any changes to that setting made on the Tasmota side. - -```python -from haco import Select, Tasmota - -LOG_LEVELS = ["None", "Error", "Info", "Debug", "Debug More"] - -weblog = Select('WebLog Level', icon='console', options=LOG_LEVELS) - - -@weblog.callback() -def ha(value) -> Tasmota[str, 'tasmota.cmd("WebLog "+value)']: - return LOG_LEVELS.index(value) - - -@weblog.callback(trigger='WebLog') -def tasmota(value: int): - return LOG_LEVELS[value] -``` - -The above is very similar to what we have already seen. - -The `ha` callback takes friendly names (e.g. `Error`, `Info`) selected by the user in Home Assistant, and returns them -as their corresponding number values (`WebLog 1`, `WebLog2`) used by Tasmota. - -The `tasmota` callback, naturally enough, does the exact opposite, returning the string names to Home Assistant whenever -the `WebLog` command is used on the Tasmota side. - -WebLog Select - -#### Debugging Your Configuration - -When you first assign a new configuration to a device, keep an eye on the Add-On logs for any errors. You'll see a -typical Python stack trace if anything goes wrong. - -:warning: Each time you edit your configuration module (`.py` file), you'll need to restart the Add-On. Hot -is reloading not yet supported. - -#### Additional Capabilities - -More complex device controls (e.g. `Climate`, `Fan`) have additional capabilities beyond a single value requiting -Tasmota/Home Assistant -callbacks. Adding callbacks for these extended capabilities is done similarly to the above, only the callbacks need -to include the name of the capability. So if you want to add callbacks around setting the `target_humidity` of -a `Climate` control, you'd need to call your callbacks `target_humidity_tasmota` and `target_humidity_ha`, etc. - -A full schema of these names will appear in subsequent documentation. But you can find example implementations for most -controls in the [built-in `development` config](https://github.com/fmtr/haco/tree/release/haco/configs/development.py). - -Anway, if you get the names wrong, you'll see an error like this in your Add-On logs: - -``` -ValueError: Callback function name "set_mode_ha" is not valid for control "Climate". Must be one of: ['action_tasmota', 'current_humidity_tasmota', 'current_temperature_tasmota', 'mode_ha', 'mode_tasmota', 'preset_mode_ha', 'preset_mode_tasmota', 'swing_mode_ha', 'swing_mode_tasmota', 'target_humidity_ha', 'target_humidity_tasmota', 'target_temperature_ha', 'target_temperature_tasmota', 'temperature_high_ha', 'temperature_high_tasmota', 'temperature_low_ha', 'temperature_low_tasmota'] -``` - -#### Additional Resources - -Beyond these examples, when creating your own configuration, you'll probably find -the [built-in configurations](https://github.com/fmtr/haco/tree/release/haco/configs) (especially -the [`development` config](https://github.com/fmtr/haco/tree/release/haco/configs/development.py)) useful. - -## How to Run Using Docker - -If you're not using Home Assistant OS (Supervised) you might want to run as a stand-alone Docker Container. There's no pre-built image currently, so you'll need to build and run manually: - -## Build - -```bash -git clone https://github.com/fmtr/haco.git -cd haco -docker build -t fmtr/haco:latest . -``` - -## Run - -Example Docker Compose: - -```yaml -version: '3' -services: - main: - image: fmtr/haco:latest - container_name: haco - restart: unless-stopped - - environment: - - MQTT_HOST=mqtt.service - - HACO_LOG_LEVEL=DEBUG - volumes: - - :/haco -``` - -Other environment variables: - -- `MQTT_HOST` -- `MQTT_PORT` -- `MQTT_USERNAME` -- `MQTT_PASSWORD` - - +It is in very early release. Documentation is (may) be forthcoming. diff --git a/haco/client.py b/haco/client.py index 9da8fd7..eeb2270 100644 --- a/haco/client.py +++ b/haco/client.py @@ -1,11 +1,15 @@ +import asyncio + import aiomqtt from fmtr.tools import mqtt, Constants +from fmtr.tools.json_tools import to_json from haco import constants +from haco.obs import logger -aiomqtt.Client class ClientHaco(mqtt.Client): + 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="offline", retain=True, qos=1, ) @@ -19,23 +23,38 @@ class ClientHaco(mqtt.Client): return constants.TOPIC_CLIENT async def handle(self): - """Listen for command messages from HA.""" - - # subs = control.subscriptions + """Listen for command messages from HA.""" for topic_sub in self.device.subscriptions.keys(): - print(f"Subscribing to {topic_sub}") + logger.info(f"Subscribing to {topic_sub}") await self.subscribe(topic_sub) async for message in self.messages: payload = message.payload.decode() - print(f"{message.topic.value}{Constants.ARROW}{payload}") + logger.info(f"{message.topic.value}{Constants.ARROW}{payload}") topic_command = self.device.subscriptions[message.topic.value] echo_val = topic_command.wrap_back(message) - echo_val + # Echo back as new state topic_state = topic_command.state await topic_state.wrap_back(echo_val) - # Echo back as new state - # await self.publish(STATE_TOPIC, payload, retain=True) + async def start(self): + while True: + try: + async with self: + + for topic, data in self.device.announce.items(): + data_json = to_json(data) + logger.info(f'Announcing {topic} with {data_json}') + await self.publish(topic, payload=data_json, retain=True) + + await self.publish(self.will.topic, "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") + await asyncio.sleep(5) diff --git a/haco/climate.py b/haco/climate.py index 154045c..2cd4050 100644 --- a/haco/climate.py +++ b/haco/climate.py @@ -19,23 +19,24 @@ class Climate(Control): fan_modes: Optional[List[str]] = None swing_modes: Optional[List[str]] = None + def temperature_command(self, value): - return value + raise NotImplementedError() def mode_command(self, value): - return value + raise NotImplementedError() def fan_mode_command(self, value): - return value + raise NotImplementedError() def fan_mode_state(self, value): - return value + raise NotImplementedError() def power_command(self, value): - return value + raise NotImplementedError() def power_state(self, value): - return value + raise NotImplementedError() @classmethod def get_capabilities(cls): diff --git a/haco/control.py b/haco/control.py index 237eea5..da7eeee 100644 --- a/haco/control.py +++ b/haco/control.py @@ -36,13 +36,8 @@ class Control(Base): 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): return self.device @@ -88,6 +83,9 @@ class Control(Base): return data + async def initialise(self): + ... + if __name__ == "__main__": control = Control(name="test", platform="test") diff --git a/haco/obs.py b/haco/obs.py new file mode 100644 index 0000000..105e55c --- /dev/null +++ b/haco/obs.py @@ -0,0 +1,11 @@ +from fmtr.tools 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__, +) diff --git a/haco/sb3.py b/haco/sb3.py index ee9fdda..cdb85a6 100644 --- a/haco/sb3.py +++ b/haco/sb3.py @@ -1,8 +1,5 @@ import asyncio -import aiomqtt - -from fmtr.tools.json_tools import to_json from haco.client import ClientHaco from haco.climate import Climate from haco.constants import MQTT_HOST @@ -16,28 +13,9 @@ async def main(): client = ClientHaco(hostname=MQTT_HOST, device=device) - client + await client.start() - while True: - try: - async with client: - for topic, data in device.announce.items(): - data_json = to_json(data) - print(f'Announcing {topic} with {data_json}') - await client.publish(topic, payload=data_json, retain=True) - - # Online now - await client.publish(client.will.topic, "online", retain=True) - - await client.publish('haco/development/3012edb1a6d4-1ed9c3469373/dev-device/dev-climate-b/power/command', "OFF", retain=True) - - # Wait for commands - await client.handle() - - except aiomqtt.MqttError as e: - print(f"⚠️ MQTT disconnected: {e}; retrying in 5s") - await asyncio.sleep(5) if __name__ == "__main__": diff --git a/haco/topics.py b/haco/topics.py index ebea120..48c4655 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -4,6 +4,8 @@ from dataclasses import dataclass, field from functools import cached_property from typing import ClassVar, TYPE_CHECKING +from haco.obs import logger + if TYPE_CHECKING: from capabilities import Capability @@ -66,7 +68,13 @@ class AnnounceTopicState(AnnounceTopic): async def wrap_back(self, value): method = getattr(self.capability.control, self.callback_name, None) - value_raw = method(value) + + try: + value_raw = method(value) + except NotImplementedError: + logger.warning(f'No method implemented for {self.topic}') + return + await self.capability.control.device.client.publish(self.topic, value_raw) return value_raw @@ -80,7 +88,13 @@ class AnnounceTopicCommand(AnnounceTopic): def wrap_back(self, message): method = getattr(self.capability.control, self.callback_name, None) - value = method(message.payload.decode('utf-8')) + + try: + value = method(message.payload.decode('utf-8')) + except NotImplementedError: + logger.warning(f'No method implemented for {self.topic}') + return + return value def get_subscriptions(self): diff --git a/haco/version b/haco/version index d34586a..6c6aa7c 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.0.25 \ No newline at end of file +0.1.0 \ No newline at end of file diff --git a/haco/version.py b/haco/version.py new file mode 100644 index 0000000..7fcd766 --- /dev/null +++ b/haco/version.py @@ -0,0 +1,3 @@ +from fmtr.tools import version + +__version__ = version.read() From 424ae0a8cb5c51099d598045868285cc96c29e83 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 21 Nov 2025 10:00:00 +0000 Subject: [PATCH 085/183] Reinstate Actions --- haco/{v0 => }/.github/workflows/main.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename haco/{v0 => }/.github/workflows/main.yml (100%) diff --git a/haco/v0/.github/workflows/main.yml b/haco/.github/workflows/main.yml similarity index 100% rename from haco/v0/.github/workflows/main.yml rename to haco/.github/workflows/main.yml From c75d5aa446b4659c9da31915d93438f962a352ef Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 21 Nov 2025 11:15:37 +0000 Subject: [PATCH 086/183] Update Actions and set pre-release --- haco/.github/workflows/main.yml | 56 +++++++++------------------------ haco/version | 2 +- 2 files changed, 16 insertions(+), 42 deletions(-) diff --git a/haco/.github/workflows/main.yml b/haco/.github/workflows/main.yml index c85e74f..8e75948 100644 --- a/haco/.github/workflows/main.yml +++ b/haco/.github/workflows/main.yml @@ -1,11 +1,10 @@ name: Version and Deploy on: + push: + paths: + - 'haco/versionTEMP' workflow_dispatch: - inputs: - version: - description: 'Version' - required: true jobs: @@ -17,25 +16,24 @@ jobs: NAME: ${{ github.event.repository.name }} NAME_SHORT: ${{ github.event.repository.name }} ORG: ${{ github.repository_owner }} - SHLINK_API_KEY: ${{ secrets.SHLINK_API_KEY }} - LINK_ID: haco/tapp + #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 tappack + pip install twine + pip install -U packaging setuptools twine pip build #https://github.com/pypa/twine/issues/1216 - - name: Docker Login - env: - DOCKER_USER: ${{ secrets.DOCKER_USER }} - DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} - run: | - echo $DOCKER_TOKEN | docker login --username $DOCKER_USER --password-stdin - name: Increment Version env: @@ -43,16 +41,7 @@ jobs: run: | git config --global user.name 'Frontmatter Actions' git config --global user.email "$GIT_EMAIL" - echo -n ${VERSION} > ${NAME}/version - python3 update_version.py ${VERSION} - tappack --module-path berry/ --output ./${NAME_SHORT}.tapp - - git add ${NAME}/version - git add berry/${NAME_SHORT}_version.be - git add ha/addon/config.yaml - - git commit -am "Increment version number to ${VERSION} for release" - git push + VERSION=${{ env.VERSION }} git tag -a v${VERSION} -m "Release version ${VERSION}" git checkout --track origin/release git rebase main @@ -61,13 +50,13 @@ jobs: - name: Release uses: softprops/action-gh-release@v1 with: - files: haco.tapp - tag_name: v${{ github.event.inputs.version }} + tag_name: v${{ env.VERSION }} generate_release_notes: true + prerelease: true - name: Build Wheel run: | - python setup.py sdist bdist_wheel + python -m build - name: Push Wheel env: @@ -75,18 +64,3 @@ jobs: TWINE_USERNAME: __token__ run: | twine upload dist/* - - - name: Update Link - run: | - URL=https://github.com/${ORG}/${NAME}/releases/download/v${VERSION}/${NAME_SHORT}.tapp - DATA="{\"longUrl\": \"${URL}\"}" - curl --request PATCH --url https://fmtr.link/rest/v3/short-urls/${LINK_ID} --header "Content-Type: application/json" --header "X-Api-Key: ${SHLINK_API_KEY}" --data "$DATA" &> /dev/null - - - name: Build Docker - run: | - docker build . --build-arg TYPE=release --build-arg VERSION=${VERSION} --tag fmtr/${NAME}:v${VERSION} - docker tag fmtr/${NAME}:v${VERSION} fmtr/${NAME}:latest - - - name: Push Docker - run: | - docker push --all-tags fmtr/${NAME} \ No newline at end of file diff --git a/haco/version b/haco/version index 6c6aa7c..7b7a560 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.1.0 \ No newline at end of file +0.1.0a1 \ No newline at end of file From cc62959c3774b5a17d52ddef804afe4c07a7884e Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 21 Nov 2025 11:28:56 +0000 Subject: [PATCH 087/183] Reinstate Actions --- {haco/.github => .github}/workflows/main.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {haco/.github => .github}/workflows/main.yml (100%) diff --git a/haco/.github/workflows/main.yml b/.github/workflows/main.yml similarity index 100% rename from haco/.github/workflows/main.yml rename to .github/workflows/main.yml From 83dbc97a95bea69ac581536894dd55c8c200b17c Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 21 Nov 2025 11:33:49 +0000 Subject: [PATCH 088/183] Reinstate Actions trigger --- .github/workflows/main.yml | 2 +- haco/version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8e75948..39088d3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,7 @@ name: Version and Deploy on: push: paths: - - 'haco/versionTEMP' + - 'haco/version' workflow_dispatch: diff --git a/haco/version b/haco/version index 7b7a560..17c3789 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.1.0a1 \ No newline at end of file +0.1.0a2 \ No newline at end of file From 2e8d905fdeaa2b05ec24a0f61c0504d703c00ecd Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 21 Nov 2025 11:38:43 +0000 Subject: [PATCH 089/183] Fix missing PATH_VERSION in Actions --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 39088d3..58568ff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,6 +16,7 @@ jobs: 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 @@ -26,7 +27,7 @@ jobs: - name: Set Version Environment Variable run: | - VERSION=$(cat ${PATH_VERSION}) + VERSION=$(cat ${PATH_VERSION}) echo "VERSION=$VERSION" >> $GITHUB_ENV - name: Install Tools From 9c4d39f46b7f8e3c54d294d3a8992022e9bf4856 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 21 Nov 2025 12:50:56 +0000 Subject: [PATCH 090/183] Implement default state/command capabilities/topics and implement Button --- haco/button.py | 15 +++++++++++++++ haco/capabilities.py | 2 +- haco/control.py | 2 +- haco/sb3.py | 5 ++++- haco/topics.py | 12 ++++++++++-- haco/version | 2 +- 6 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 haco/button.py diff --git a/haco/button.py b/haco/button.py new file mode 100644 index 0000000..e67400b --- /dev/null +++ b/haco/button.py @@ -0,0 +1,15 @@ +from dataclasses import dataclass +from typing import Literal + +from control import Control + + +@dataclass(kw_only=True) +class Button(Control): + platform: Literal["climate"] = "button" + + def command(self, value): + raise NotImplementedError() + + def state(self, value): + raise NotImplementedError() diff --git a/haco/capabilities.py b/haco/capabilities.py index a03d070..3bf81e7 100644 --- a/haco/capabilities.py +++ b/haco/capabilities.py @@ -12,7 +12,7 @@ if TYPE_CHECKING: @dataclass(kw_only=True) class Capability(Base): - name: str + name: str | None = None state: AnnounceTopicState | None = field(default_factory=AnnounceTopicState) command: AnnounceTopicCommand | None = field(default_factory=AnnounceTopicCommand) diff --git a/haco/control.py b/haco/control.py index da7eeee..4094e47 100644 --- a/haco/control.py +++ b/haco/control.py @@ -53,7 +53,7 @@ class Control(Base): @classmethod def get_capabilities(cls): return [ - Capability(name='default') + Capability(name=None) ] def get_unique_id(self) -> str: diff --git a/haco/sb3.py b/haco/sb3.py index cdb85a6..df5bf8c 100644 --- a/haco/sb3.py +++ b/haco/sb3.py @@ -1,5 +1,6 @@ import asyncio +from haco.button import Button from haco.client import ClientHaco from haco.climate import Climate from haco.constants import MQTT_HOST @@ -9,7 +10,9 @@ from haco.device import Device async def main(): climate_a = Climate(name="Dev Climate A", fan_modes=['a', 'b', 'c']) climate_b = Climate(name="Dev Climate B", fan_modes=['a', 'b', 'c']) - device = Device(name="Dev Device", controls=[climate_a, climate_b]) + + b1 = Button(name="Dev Button 1") + device = Device(name="Dev Device", controls=[climate_a, climate_b, b1]) client = ClientHaco(hostname=MQTT_HOST, device=device) diff --git a/haco/topics.py b/haco/topics.py index 48c4655..436fae2 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -13,7 +13,10 @@ if TYPE_CHECKING: @dataclass(kw_only=True) class AnnounceTopic: IO: ClassVar[str | None] = None - key: str = '{capability}_{io}_topic' + + KEY_DEFAULTS: ClassVar[dict] = {True: '{capability}_{io}_topic', False: '{io}_topic'} + + key: str | None = None value: str = '{path}/{capability}/{io}' parent: Capability | None = None @@ -22,6 +25,8 @@ class AnnounceTopic: def set_parent(self, capability: Capability): self.parent = capability + if self.key is None: + self.key = self.KEY_DEFAULTS[bool(self.capability.name)] self.announce = self.get_announce() self.subscriptions = self.get_subscriptions() @@ -32,7 +37,7 @@ class AnnounceTopic: def fills(self): return dict( path=str(self.capability.control.topic), - capability=self.capability.name, + capability=self.capability.name or 'default', io=self.IO ) @@ -49,6 +54,9 @@ class AnnounceTopic: @property def callback_name(self): + if not self.capability.name: + return self.IO + return f'{self.capability.name}_{self.IO}' def get_subscriptions(self): diff --git a/haco/version b/haco/version index 17c3789..8de0802 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.1.0a2 \ No newline at end of file +0.1.0-alpha.3 \ No newline at end of file From 1bcf9fcd82976652cc5d5b00494c0e2172e3b5ee Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Fri, 21 Nov 2025 13:09:21 +0000 Subject: [PATCH 091/183] Add topics property to Capability. --- haco/capabilities.py | 21 +++++++++++++-------- haco/client.py | 7 +++++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/haco/capabilities.py b/haco/capabilities.py index 3bf81e7..df3daa4 100644 --- a/haco/capabilities.py +++ b/haco/capabilities.py @@ -3,6 +3,7 @@ from __future__ import annotations from dataclasses import dataclass, field from typing import TYPE_CHECKING +from fmtr.tools.iterator_tools import strip_none from haco.base import Base from haco.topics import AnnounceTopicState, AnnounceTopicCommand @@ -23,7 +24,7 @@ class Capability(Base): def set_parent(self, control): self.parent = control - for topic in (t for t in (self.state, self.command) if t): + for topic in self.topics: topic.set_parent(self) self.subscriptions = self.get_subscriptions() @@ -32,16 +33,20 @@ class Capability(Base): def get_announce(self) -> dict: data = {} - for topic in (t for t in (self.state, self.command) if t): + for topic in self.topics: data |= topic.announce return data + def get_subscriptions(self) -> dict: + data = {} + for topic in self.topics: + data |= topic.subscriptions + return data + + @property + def topics(self): + return strip_none(self.state, self.command) + @property def control(self): return self.parent - - def get_subscriptions(self) -> dict: - data = {} - for topic in (t for t in (self.state, self.command) if t): - data |= topic.subscriptions - return data diff --git a/haco/client.py b/haco/client.py index eeb2270..209777e 100644 --- a/haco/client.py +++ b/haco/client.py @@ -9,10 +9,13 @@ from haco.obs import logger 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="offline", retain=True, qos=1, ) + self.will = will or mqtt.Will(topic=str(constants.TOPIC_AVAIL), payload=self.OFFLINE, retain=True, qos=1, ) identifier = identifier or constants.CLIENT_ID self.device = device self.device.set_parent(self) @@ -49,7 +52,7 @@ class ClientHaco(mqtt.Client): logger.info(f'Announcing {topic} with {data_json}') await self.publish(topic, payload=data_json, retain=True) - await self.publish(self.will.topic, "online", retain=True) + 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) From 97267b8e29bfa85a421b4751c5c21455576bd731 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 23 Nov 2025 11:30:12 +0000 Subject: [PATCH 092/183] Move switch --- haco/{v0/haco => }/switch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename haco/{v0/haco => }/switch.py (100%) diff --git a/haco/v0/haco/switch.py b/haco/switch.py similarity index 100% rename from haco/v0/haco/switch.py rename to haco/switch.py index 2cb2320..d77d875 100644 --- a/haco/v0/haco/switch.py +++ b/haco/switch.py @@ -1,7 +1,7 @@ -from haco.control import Control - from haco.tools import invert_bool +from haco.control import Control + class Switch(Control): NAME = 'switch' From ea8650f2322da646fb7d3de28839f0954b82819f Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 23 Nov 2025 11:34:49 +0000 Subject: [PATCH 093/183] Implement switch --- haco/sb3.py | 5 ++++- haco/switch.py | 17 +++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/haco/sb3.py b/haco/sb3.py index df5bf8c..aa8c81e 100644 --- a/haco/sb3.py +++ b/haco/sb3.py @@ -5,6 +5,7 @@ from haco.client import ClientHaco from haco.climate import Climate from haco.constants import MQTT_HOST from haco.device import Device +from haco.switch import Switch async def main(): @@ -12,7 +13,9 @@ async def main(): climate_b = Climate(name="Dev Climate B", fan_modes=['a', 'b', 'c']) b1 = Button(name="Dev Button 1") - device = Device(name="Dev Device", controls=[climate_a, climate_b, b1]) + + s1 = Switch(name="Dev Switch 1") + device = Device(name="Dev Device", controls=[climate_a, climate_b, b1, s1]) client = ClientHaco(hostname=MQTT_HOST, device=device) diff --git a/haco/switch.py b/haco/switch.py index d77d875..d35d474 100644 --- a/haco/switch.py +++ b/haco/switch.py @@ -1,14 +1,15 @@ -from haco.tools import invert_bool +from dataclasses import dataclass +from typing import Literal -from haco.control import Control +from control import Control +@dataclass(kw_only=True) class Switch(Control): - NAME = 'switch' + platform: Literal["climate"] = "switch" - def __init__(self, name, icon=None): - super().__init__(name, icon=icon) + def command(self, value): + raise NotImplementedError() - @property - def control_type(self): - return invert_bool + def state(self, value): + raise NotImplementedError() From 9fe9db547ec8d9154f378e2b03ef0ceaa397de35 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 23 Nov 2025 11:35:27 +0000 Subject: [PATCH 094/183] Move pulldown --- haco/{v0/haco => }/pulldown.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename haco/{v0/haco => }/pulldown.py (100%) diff --git a/haco/v0/haco/pulldown.py b/haco/pulldown.py similarity index 100% rename from haco/v0/haco/pulldown.py rename to haco/pulldown.py From 70afdf1857a1f0af65fd07856b754d1e660e9453 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 23 Nov 2025 11:54:24 +0000 Subject: [PATCH 095/183] Add Control.DATA for static announce data --- haco/base.py | 4 +++- haco/button.py | 13 +++++++++---- haco/client.py | 6 +++--- haco/climate.py | 6 +++++- haco/control.py | 4 ++-- haco/pulldown.py | 22 +++++++++++----------- haco/sb3.py | 4 +++- haco/switch.py | 6 ++++-- 8 files changed, 40 insertions(+), 25 deletions(-) diff --git a/haco/base.py b/haco/base.py index 68e5560..2828af6 100644 --- a/haco/base.py +++ b/haco/base.py @@ -6,8 +6,10 @@ from typing import Any @dataclass(kw_only=True) class Base: + DATA = dict() + def model_dump(self) -> dict[str, Any]: - data = {} + data = {} | self.DATA for fld in fields(self): meta = fld.metadata if meta.get('exclude', False): diff --git a/haco/button.py b/haco/button.py index e67400b..93d8a70 100644 --- a/haco/button.py +++ b/haco/button.py @@ -1,15 +1,20 @@ from dataclasses import dataclass -from typing import Literal from control import Control +from haco.capabilities import Capability @dataclass(kw_only=True) class Button(Control): - platform: Literal["climate"] = "button" + DATA = dict( + platform='button' + ) def command(self, value): raise NotImplementedError() - def state(self, value): - raise NotImplementedError() + @classmethod + def get_capabilities(cls): + return [ + Capability(name=None, state=None) + ] diff --git a/haco/client.py b/haco/client.py index 209777e..2147286 100644 --- a/haco/client.py +++ b/haco/client.py @@ -1,6 +1,5 @@ -import asyncio - import aiomqtt +import asyncio from fmtr.tools import mqtt, Constants from fmtr.tools.json_tools import to_json @@ -40,7 +39,8 @@ class ClientHaco(mqtt.Client): # Echo back as new state topic_state = topic_command.state - await topic_state.wrap_back(echo_val) + if topic_state: + await topic_state.wrap_back(echo_val) async def start(self): while True: diff --git a/haco/climate.py b/haco/climate.py index 2cd4050..3a27c38 100644 --- a/haco/climate.py +++ b/haco/climate.py @@ -7,7 +7,11 @@ from control import Control @dataclass(kw_only=True) class Climate(Control): - platform: Literal["climate"] = "climate" + DATA = dict( + platform='climate' + ) + + temperature_unit: Literal["C", "F"] = "C" temperature_min: float = 0 temperature_max: float = 40 diff --git a/haco/control.py b/haco/control.py index 4094e47..0664d52 100644 --- a/haco/control.py +++ b/haco/control.py @@ -14,7 +14,7 @@ if TYPE_CHECKING: @dataclass(kw_only=True) class Control(Base): name: str - platform: str + device: Device = field(default=None, init=False) capabilities: None | list[Capability] = field(default=None, metadata=dict(exclude=True)) @@ -69,7 +69,7 @@ class Control(Base): @property def announce_topic(self): - return f"homeassistant/{self.platform}/{self.unique_id}/config" + return f"homeassistant/{self.DATA['platform']}/{self.unique_id}/config" def get_availability_topic(self) -> str: return self.device.client.will.topic diff --git a/haco/pulldown.py b/haco/pulldown.py index 5c51951..1bd6c8b 100644 --- a/haco/pulldown.py +++ b/haco/pulldown.py @@ -1,18 +1,18 @@ -from typing import List +from dataclasses import dataclass -from haco.control import Control +from control import Control +@dataclass(kw_only=True) class Select(Control): - NAME = 'select' + DATA = dict( + platform='select' + ) - def __init__(self, name, options: List[str], icon=None): - self.options = options - super().__init__(name, icon=icon) + options: list[str] - def get_config_ha_ex(self): - data = { - 'options': self.options, - } + def command(self, value): + raise NotImplementedError() - return data + def state(self, value): + raise NotImplementedError() diff --git a/haco/sb3.py b/haco/sb3.py index aa8c81e..1fa7c5c 100644 --- a/haco/sb3.py +++ b/haco/sb3.py @@ -5,6 +5,7 @@ from haco.client import ClientHaco from haco.climate import Climate from haco.constants import MQTT_HOST from haco.device import Device +from haco.pulldown import Select from haco.switch import Switch @@ -15,7 +16,8 @@ async def main(): b1 = Button(name="Dev Button 1") s1 = Switch(name="Dev Switch 1") - device = Device(name="Dev Device", controls=[climate_a, climate_b, b1, s1]) + 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) diff --git a/haco/switch.py b/haco/switch.py index d35d474..b9cc1a4 100644 --- a/haco/switch.py +++ b/haco/switch.py @@ -1,12 +1,14 @@ from dataclasses import dataclass -from typing import Literal from control import Control @dataclass(kw_only=True) class Switch(Control): - platform: Literal["climate"] = "switch" + DATA = dict( + platform='switch' + ) + def command(self, value): raise NotImplementedError() From 5c08486ef3eeee46f655e2389356743c28a7229a Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 23 Nov 2025 12:09:57 +0000 Subject: [PATCH 096/183] Pass logfire native logging handler to aiomqtt --- haco/climate.py | 10 +++++----- haco/sb3.py | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/haco/climate.py b/haco/climate.py index 3a27c38..7e4a029 100644 --- a/haco/climate.py +++ b/haco/climate.py @@ -1,5 +1,5 @@ from dataclasses import dataclass -from typing import List, Optional, Literal +from typing import Literal from capabilities import Capability from control import Control @@ -18,10 +18,10 @@ class Climate(Control): humidity_min: float = 0 humidity_max: float = 100 precision: int = 1 - modes: Optional[List[str]] = None - preset_modes: Optional[List[str]] = None - fan_modes: Optional[List[str]] = None - swing_modes: Optional[List[str]] = None + modes: list[str] | None = None + preset_modes: list[str] | None = None + fan_modes: list[str] | None = None + swing_modes: list[str] | None = None def temperature_command(self, value): diff --git a/haco/sb3.py b/haco/sb3.py index 1fa7c5c..157fc8f 100644 --- a/haco/sb3.py +++ b/haco/sb3.py @@ -1,13 +1,17 @@ import asyncio +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.pulldown import Select from haco.switch import Switch +handler = logger.LogfireLoggingHandler() +logging.basicConfig(handlers=[handler], level=logging.DEBUG) async def main(): climate_a = Climate(name="Dev Climate A", fan_modes=['a', 'b', 'c']) @@ -19,7 +23,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) + client = ClientHaco(hostname=MQTT_HOST, device=device, logger=logging.getLogger(__name__)) await client.start() From 21100a50960bcc728de271b06a51e322d2919e0a Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Mon, 24 Nov 2025 10:10:41 +0000 Subject: [PATCH 097/183] Fix relative import statements --- haco/button.py | 2 +- haco/climate.py | 4 ++-- haco/control.py | 8 ++++++++ haco/pulldown.py | 2 +- haco/switch.py | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/haco/button.py b/haco/button.py index 93d8a70..9364177 100644 --- a/haco/button.py +++ b/haco/button.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -from control import Control from haco.capabilities import Capability +from haco.control import Control @dataclass(kw_only=True) diff --git a/haco/climate.py b/haco/climate.py index 7e4a029..f18d880 100644 --- a/haco/climate.py +++ b/haco/climate.py @@ -1,8 +1,8 @@ from dataclasses import dataclass from typing import Literal -from capabilities import Capability -from control import Control +from haco.capabilities import Capability +from haco.control import Control @dataclass(kw_only=True) diff --git a/haco/control.py b/haco/control.py index 0664d52..c8665ef 100644 --- a/haco/control.py +++ b/haco/control.py @@ -86,6 +86,14 @@ class Control(Base): async def initialise(self): ... + async def announce2(self): + """ + + Entities must be able to announce themselves to Home Assistant, e.g. when a pulldown changes its options, etc. + + """ + await self.device.client.publish(self.announce_topic, self.announce) + if __name__ == "__main__": control = Control(name="test", platform="test") diff --git a/haco/pulldown.py b/haco/pulldown.py index 1bd6c8b..c49b058 100644 --- a/haco/pulldown.py +++ b/haco/pulldown.py @@ -1,6 +1,6 @@ from dataclasses import dataclass -from control import Control +from haco.control import Control @dataclass(kw_only=True) diff --git a/haco/switch.py b/haco/switch.py index b9cc1a4..6c9ab22 100644 --- a/haco/switch.py +++ b/haco/switch.py @@ -1,6 +1,6 @@ from dataclasses import dataclass -from control import Control +from haco.control import Control @dataclass(kw_only=True) From caa19f016dea57f9cfad26225d1e24961c3bac41 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Mon, 24 Nov 2025 12:04:32 +0000 Subject: [PATCH 098/183] Implement announce as control method and allow async methods --- haco/client.py | 13 +++---------- haco/control.py | 14 +++++++++----- haco/device.py | 12 +++++------- haco/topics.py | 34 +++++++++++++++++++++++++++++----- 4 files changed, 46 insertions(+), 27 deletions(-) diff --git a/haco/client.py b/haco/client.py index 2147286..fa553e6 100644 --- a/haco/client.py +++ b/haco/client.py @@ -2,7 +2,6 @@ import aiomqtt import asyncio from fmtr.tools import mqtt, Constants -from fmtr.tools.json_tools import to_json from haco import constants from haco.obs import logger @@ -35,22 +34,16 @@ 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 = topic_command.wrap_back(message) + echo_val = await topic_command.wrap_back(message) + - # Echo back as new state - topic_state = topic_command.state - if topic_state: - await topic_state.wrap_back(echo_val) async def start(self): while True: try: async with self: - for topic, data in self.device.announce.items(): - data_json = to_json(data) - logger.info(f'Announcing {topic} with {data_json}') - await self.publish(topic, payload=data_json, retain=True) + await self.device.announce() await self.publish(self.will.topic, self.ONLINE, retain=True) diff --git a/haco/control.py b/haco/control.py index c8665ef..9e2895b 100644 --- a/haco/control.py +++ b/haco/control.py @@ -3,8 +3,10 @@ from __future__ import annotations from dataclasses import dataclass, field from typing import TYPE_CHECKING +from fmtr.tools.json_tools import to_json from haco.base import Base from haco.capabilities import Capability +from haco.obs import logger from haco.utils import sanitize_name if TYPE_CHECKING: @@ -21,7 +23,7 @@ class Control(Base): 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)) + # 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): @@ -36,7 +38,7 @@ class Control(Base): self.unique_id = self.get_unique_id() self.availability_topic = self.get_availability_topic() self.subscriptions = self.get_subscriptions() - self.announce = self.get_announce() + #self.announce = self.get_announce() @property def parent(self): @@ -47,7 +49,6 @@ class Control(Base): for cap in self.capabilities: data |= cap.announce - data = {self.announce_topic: data} return data @classmethod @@ -86,13 +87,16 @@ class Control(Base): async def initialise(self): ... - async def announce2(self): + async def announce(self): """ Entities must be able to announce themselves to Home Assistant, e.g. when a pulldown changes its options, etc. """ - await self.device.client.publish(self.announce_topic, self.announce) + topic = self.announce_topic + data_json = to_json(self.get_announce()) + logger.info(f'Announcing {topic} with {data_json}') + await self.device.client.publish(topic, data_json, retain=True) if __name__ == "__main__": diff --git a/haco/device.py b/haco/device.py index f28e16b..0f1fa0a 100644 --- a/haco/device.py +++ b/haco/device.py @@ -23,7 +23,7 @@ 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) + # announce: dict | None = field(default=None, metadata=dict(exclude=True), init=False) subscriptions: dict | None = field(default=None, metadata=dict(exclude=True), init=False) @@ -34,7 +34,7 @@ class Device(Base): for control in self.controls: control.set_parent(self) - self.announce = self.get_announce() + #self.announce = self.get_announce() self.subscriptions = self.get_subscriptions() self @@ -47,12 +47,10 @@ class Device(Base): def name_san(self) -> str: return sanitize_name(self.name) - def get_announce(self): + async def announce(self): + for control in self.controls: + await control.announce() - data = {} - for capability in self.controls: - data |= capability.announce - return data @property def client(self): diff --git a/haco/topics.py b/haco/topics.py index 436fae2..ad491d8 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -4,6 +4,7 @@ from dataclasses import dataclass, field from functools import cached_property from typing import ClassVar, TYPE_CHECKING +from fmtr.tools import aio from haco.obs import logger if TYPE_CHECKING: @@ -76,11 +77,19 @@ class AnnounceTopicState(AnnounceTopic): async def wrap_back(self, value): method = getattr(self.capability.control, self.callback_name, None) + is_async = aio.is_async(method) + + # test try: - value_raw = method(value) + + if is_async: + value_raw = await method(value) + else: + value_raw = method(value) + except NotImplementedError: - logger.warning(f'No method implemented for {self.topic}') + logger.warning(f'No method implemented for {self.__class__.__name__}.{self.callback_name}: {self.topic}') return await self.capability.control.device.client.publish(self.topic, value_raw) @@ -94,16 +103,31 @@ class AnnounceTopicCommand(AnnounceTopic): def state(self): return self.capability.state - def wrap_back(self, message): + async def wrap_back(self, message): method = getattr(self.capability.control, self.callback_name, None) + is_async = aio.is_async(method) + + #test + try: - value = method(message.payload.decode('utf-8')) + + value = message.payload.decode('utf-8') + + if is_async: + value_raw = await method(value) + else: + value_raw = method(value) + except NotImplementedError: logger.warning(f'No method implemented for {self.topic}') return - return value + # Echo back as new state + topic_state = self.state + if topic_state: + await topic_state.wrap_back(value_raw) + def get_subscriptions(self): return {self.topic: self} From 1604e2447e7effdd3a9da01e96144582009d852b Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Mon, 24 Nov 2025 15:19:08 +0000 Subject: [PATCH 099/183] Improve not implemented method warning --- haco/{pulldown.py => select.py} | 0 haco/topics.py | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename haco/{pulldown.py => select.py} (100%) diff --git a/haco/pulldown.py b/haco/select.py similarity index 100% rename from haco/pulldown.py rename to haco/select.py diff --git a/haco/topics.py b/haco/topics.py index ad491d8..aadfe3f 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -89,7 +89,7 @@ class AnnounceTopicState(AnnounceTopic): value_raw = method(value) except NotImplementedError: - logger.warning(f'No method implemented for {self.__class__.__name__}.{self.callback_name}: {self.topic}') + logger.warning(f'No method implemented for {self.capability.control.__class__.__name__}.{self.callback_name}: {self.topic}') return await self.capability.control.device.client.publish(self.topic, value_raw) @@ -120,7 +120,7 @@ class AnnounceTopicCommand(AnnounceTopic): value_raw = method(value) except NotImplementedError: - logger.warning(f'No method implemented for {self.topic}') + logger.warning(f'{self.capability.control.__class__.__name__}.{self.callback_name}: {self.topic}') return # Echo back as new state From 879bc347f8a2cf899c51ff57326a65e4dfd57f15 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 25 Nov 2025 12:30:35 +0000 Subject: [PATCH 100/183] Implement per-control/capability state/command datatype converters --- haco/capabilities.py | 6 +++++- haco/control.py | 13 +++++++------ haco/select.py | 2 ++ haco/topics.py | 11 +++++------ haco/utils.py | 20 ++++++++++++++++++++ 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/haco/capabilities.py b/haco/capabilities.py index df3daa4..73eb7f6 100644 --- a/haco/capabilities.py +++ b/haco/capabilities.py @@ -1,11 +1,12 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Type from fmtr.tools.iterator_tools import strip_none from haco.base import Base from haco.topics import AnnounceTopicState, AnnounceTopicCommand +from haco.utils import Converters if TYPE_CHECKING: from haco.control import Control @@ -15,6 +16,8 @@ if TYPE_CHECKING: class Capability(Base): name: str | None = None + converters: Type[Converters] | None = field(default=None, metadata=dict(exclude=True)) + state: AnnounceTopicState | None = field(default_factory=AnnounceTopicState) command: AnnounceTopicCommand | None = field(default_factory=AnnounceTopicCommand) subscriptions: dict | None = field(default=None, metadata=dict(exclude=True), init=False) @@ -27,6 +30,7 @@ class Capability(Base): for topic in self.topics: topic.set_parent(self) + self.converters = self.converters or self.control.converters self.subscriptions = self.get_subscriptions() self.announce = self.get_announce() diff --git a/haco/control.py b/haco/control.py index 9e2895b..380f968 100644 --- a/haco/control.py +++ b/haco/control.py @@ -1,24 +1,25 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, TypeVar, Generic, Type, ClassVar from fmtr.tools.json_tools import to_json from haco.base import Base from haco.capabilities import Capability from haco.obs import logger -from haco.utils import sanitize_name +from haco.utils import sanitize_name, Converters, ConvertersBool if TYPE_CHECKING: from haco.device import Device +DeviceT = TypeVar("DeviceT", bound="Device") @dataclass(kw_only=True) -class Control(Base): +class Control(Base, Generic[DeviceT]): + converters: ClassVar[Type[Converters]] = ConvertersBool + name: str - - - device: Device = field(default=None, init=False) + 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) diff --git a/haco/select.py b/haco/select.py index c49b058..716bd7c 100644 --- a/haco/select.py +++ b/haco/select.py @@ -1,6 +1,7 @@ from dataclasses import dataclass from haco.control import Control +from haco.utils import ConvertersString @dataclass(kw_only=True) @@ -8,6 +9,7 @@ class Select(Control): DATA = dict( platform='select' ) + converters = ConvertersString options: list[str] diff --git a/haco/topics.py b/haco/topics.py index aadfe3f..6ceb323 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -84,14 +84,15 @@ class AnnounceTopicState(AnnounceTopic): try: if is_async: - value_raw = await method(value) + value = await method(value) else: - value_raw = method(value) + value = method(value) except NotImplementedError: logger.warning(f'No method implemented for {self.capability.control.__class__.__name__}.{self.callback_name}: {self.topic}') return + value_raw = self.capability.converters.state(value) await self.capability.control.device.client.publish(self.topic, value_raw) return value_raw @@ -107,13 +108,11 @@ class AnnounceTopicCommand(AnnounceTopic): method = getattr(self.capability.control, self.callback_name, None) is_async = aio.is_async(method) - - #test + value = message.payload.decode('utf-8') + value = self.capability.converters.command(value) try: - value = message.payload.decode('utf-8') - if is_async: value_raw = await method(value) else: diff --git a/haco/utils.py b/haco/utils.py index 4ce9777..45a1002 100644 --- a/haco/utils.py +++ b/haco/utils.py @@ -1,5 +1,8 @@ import string from dataclasses import dataclass +from typing import Callable + +from fmtr.tools.datatype_tools import to_bool CHARS_ALLOWED = string.ascii_lowercase + string.digits SEPS = '_- /' @@ -10,6 +13,9 @@ RECONNECT_DELAY_SEC = 5 ON = 'ON' OFF = 'OFF' +BOOL_MAP = {True: ON, False: OFF} + +to_bool_ha = BOOL_MAP.get def sanitize_name(s, sep='-'): chars = [] @@ -28,6 +34,20 @@ def sanitize_name(s, sep='-'): return sanitized +class Converters: + command: Callable = None + state: Callable = None + + +class ConvertersBool(Converters): + command: Callable = to_bool + state: Callable = to_bool_ha + + +class ConvertersString(Converters): + command: Callable = str + state: Callable = str + @dataclass class Metadata: exclude: bool = False From 5be372be0395cc36ce07c748a06984cc440d4f77 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Tue, 25 Nov 2025 13:12:03 +0000 Subject: [PATCH 101/183] Replace state/command methods with topic wrapper at runtime --- haco/control.py | 8 ++++++++ haco/topics.py | 6 +++--- haco/utils.py | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/haco/control.py b/haco/control.py index 380f968..4386c7a 100644 --- a/haco/control.py +++ b/haco/control.py @@ -41,6 +41,14 @@ class Control(Base, Generic[DeviceT]): self.subscriptions = self.get_subscriptions() #self.announce = self.get_announce() + for capability in self.capabilities: + for topic in capability.topics: + method_name = topic.callback_name + method = getattr(self, method_name, None) + if not method: continue + setattr(self, f'_{method_name}', method) + setattr(self, f'{method_name}', topic.wrap_back) + @property def parent(self): return self.device diff --git a/haco/topics.py b/haco/topics.py index 6ceb323..f8ea0e7 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -76,7 +76,7 @@ class AnnounceTopicState(AnnounceTopic): return {} async def wrap_back(self, value): - method = getattr(self.capability.control, self.callback_name, None) + method = getattr(self.capability.control, f'_{self.callback_name}', None) is_async = aio.is_async(method) # test @@ -93,7 +93,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) return value_raw @dataclass(kw_only=True) @@ -105,7 +105,7 @@ class AnnounceTopicCommand(AnnounceTopic): return self.capability.state async def wrap_back(self, message): - method = getattr(self.capability.control, self.callback_name, None) + method = getattr(self.capability.control, f'_{self.callback_name}', None) is_async = aio.is_async(method) value = message.payload.decode('utf-8') diff --git a/haco/utils.py b/haco/utils.py index 45a1002..8aac036 100644 --- a/haco/utils.py +++ b/haco/utils.py @@ -15,7 +15,7 @@ OFF = 'OFF' BOOL_MAP = {True: ON, False: OFF} -to_bool_ha = BOOL_MAP.get +from_bool = BOOL_MAP.get def sanitize_name(s, sep='-'): chars = [] @@ -41,7 +41,7 @@ class Converters: class ConvertersBool(Converters): command: Callable = to_bool - state: Callable = to_bool_ha + state: Callable = from_bool class ConvertersString(Converters): From d0808006ab71b340e73a31c8acb989bb2e59a195 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 26 Nov 2025 09:31:53 +0000 Subject: [PATCH 102/183] Move control state/command method wrapping to topic classes --- haco/capabilities.py | 9 +++------ haco/control.py | 12 +++--------- haco/topics.py | 44 ++++++++++++++++++++++++++++++-------------- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/haco/capabilities.py b/haco/capabilities.py index 73eb7f6..fa9e1ca 100644 --- a/haco/capabilities.py +++ b/haco/capabilities.py @@ -20,7 +20,7 @@ class Capability(Base): state: AnnounceTopicState | None = field(default_factory=AnnounceTopicState) command: AnnounceTopicCommand | None = field(default_factory=AnnounceTopicCommand) - subscriptions: dict | None = field(default=None, metadata=dict(exclude=True), init=False) + parent: Control | None = None announce = None @@ -31,20 +31,17 @@ class Capability(Base): topic.set_parent(self) self.converters = self.converters or self.control.converters - self.subscriptions = self.get_subscriptions() - - self.announce = self.get_announce() def get_announce(self) -> dict: data = {} for topic in self.topics: - data |= topic.announce + data |= topic.get_announce() return data def get_subscriptions(self) -> dict: data = {} for topic in self.topics: - data |= topic.subscriptions + data |= topic.get_subscriptions() return data @property diff --git a/haco/control.py b/haco/control.py index 4386c7a..5b27953 100644 --- a/haco/control.py +++ b/haco/control.py @@ -41,13 +41,7 @@ class Control(Base, Generic[DeviceT]): self.subscriptions = self.get_subscriptions() #self.announce = self.get_announce() - for capability in self.capabilities: - for topic in capability.topics: - method_name = topic.callback_name - method = getattr(self, method_name, None) - if not method: continue - setattr(self, f'_{method_name}', method) - setattr(self, f'{method_name}', topic.wrap_back) + @property def parent(self): @@ -56,7 +50,7 @@ class Control(Base, Generic[DeviceT]): def get_announce(self): data = self.model_dump() for cap in self.capabilities: - data |= cap.announce + data |= cap.get_announce() return data @@ -89,7 +83,7 @@ class Control(Base, Generic[DeviceT]): data = {} for capability in self.capabilities: - data |= capability.subscriptions + data |= capability.get_subscriptions() return data diff --git a/haco/topics.py b/haco/topics.py index f8ea0e7..4dee0d2 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -2,7 +2,7 @@ from __future__ import annotations from dataclasses import dataclass, field from functools import cached_property -from typing import ClassVar, TYPE_CHECKING +from typing import ClassVar, TYPE_CHECKING, Callable from fmtr.tools import aio from haco.obs import logger @@ -24,12 +24,17 @@ class AnnounceTopic: announce: dict | None = field(default=None, metadata=dict(exclude=True)) subscriptions: dict | None = field(default=None, metadata=dict(exclude=True), init=False) + control_method: Callable | None = field(default=None, metadata=dict(exclude=True)) + def set_parent(self, capability: Capability): self.parent = capability if self.key is None: self.key = self.KEY_DEFAULTS[bool(self.capability.name)] - self.announce = self.get_announce() - self.subscriptions = self.get_subscriptions() + + method_name = self.callback_name + method = getattr(self.capability.control, method_name, None) + self.control_method = method + setattr(self.capability.control, method_name, self.wrap_back) def fill(self, mask): return mask.format(**self.fills) @@ -60,6 +65,10 @@ class AnnounceTopic: return f'{self.capability.name}_{self.IO}' + @property + def callback_class_method_name(self): + return f'{self.capability.control.__class__.__name__}.{self.callback_name}' + def get_subscriptions(self): return {} @@ -67,6 +76,9 @@ class AnnounceTopic: def capability(self): return self.parent + def wrap_back(self, value): + raise NotImplementedError() + @dataclass(kw_only=True) class AnnounceTopicState(AnnounceTopic): @@ -76,20 +88,21 @@ class AnnounceTopicState(AnnounceTopic): return {} async def wrap_back(self, value): - method = getattr(self.capability.control, f'_{self.callback_name}', None) - is_async = aio.is_async(method) - # test + 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) try: if is_async: - value = await method(value) + value = await self.control_method(value) else: - value = method(value) + value = self.control_method(value) except NotImplementedError: - logger.warning(f'No method implemented for {self.capability.control.__class__.__name__}.{self.callback_name}: {self.topic}') + logger.warning(f'Subclass has not implemented method: {self.callback_class_method_name} {self.topic} {value}') return value_raw = self.capability.converters.state(value) @@ -105,21 +118,24 @@ class AnnounceTopicCommand(AnnounceTopic): return self.capability.state async def wrap_back(self, message): - method = getattr(self.capability.control, f'_{self.callback_name}', None) - is_async = aio.is_async(method) + 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: - value_raw = await method(value) + value_raw = await self.control_method(value) else: - value_raw = method(value) + value_raw = self.control_method(value) except NotImplementedError: - logger.warning(f'{self.capability.control.__class__.__name__}.{self.callback_name}: {self.topic}') + logger.warning(f'Subclass has not implemented method: {self.callback_class_method_name} {self.topic} {value}') return # Echo back as new state From 78e58b3d5dfb6ee59e45c99acb5d1bf9f70c42b1 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 26 Nov 2025 10:32:32 +0000 Subject: [PATCH 103/183] Move number --- haco/{v0/haco => }/number.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename haco/{v0/haco => }/number.py (100%) diff --git a/haco/v0/haco/number.py b/haco/number.py similarity index 100% rename from haco/v0/haco/number.py rename to haco/number.py From f054115dcd56b088de093e7b3ebd940788493cea Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 26 Nov 2025 10:40:08 +0000 Subject: [PATCH 104/183] Move uom --- haco/{v0/data => }/uom.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename haco/{v0/data => }/uom.py (100%) diff --git a/haco/v0/data/uom.py b/haco/uom.py similarity index 100% rename from haco/v0/data/uom.py rename to haco/uom.py From 21d1ac15c33123d0d21392dc8900e21b0587abc8 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 26 Nov 2025 11:36:39 +0000 Subject: [PATCH 105/183] Implement number+uom, rename wrap_back to handler --- haco/client.py | 2 +- haco/number.py | 56 ++++++------- haco/topics.py | 10 +-- haco/uom.py | 218 +++++++++++++++++++++++++------------------------ haco/utils.py | 6 ++ 5 files changed, 148 insertions(+), 144 deletions(-) diff --git a/haco/client.py b/haco/client.py index fa553e6..ce7abcb 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.wrap_back(message) + echo_val = await topic_command.handle(message) diff --git a/haco/number.py b/haco/number.py index 53524d5..e60574a 100644 --- a/haco/number.py +++ b/haco/number.py @@ -1,38 +1,32 @@ +from dataclasses import dataclass +from enum import StrEnum +from typing import ClassVar, Type + from haco.control import Control -from haco.tools import get_range_pair - -from haco.data.uom import Uom +from haco.uom import Uom +from haco.utils import Converters, ConvertersNumeric +class Mode(StrEnum): + BOX = "box" + SLIDER = "slider" + + +@dataclass(kw_only=True) class Number(Control): - NAME = 'number' - UOM = Uom + DATA = dict( + platform='number' + ) + converters: ClassVar[Type[Converters]] = ConvertersNumeric - # def init(name, number_range, mode, step, uom, entity_id, icon, callbacks) - def __init__(self, name, number_range: range, icon=None, mode=None, step=None, uom=None): + min: float = 0. + max: float = 100. + mode: Mode = Mode.SLIDER + step: float = 1. + uom: Uom | None = None - self.min, self.max = get_range_pair(number_range) - self.mode = mode - self.step = step - self.uom = uom + def command(self, value): + raise NotImplementedError() - super().__init__(name, icon=icon) - - @property - def control_type(self): - - if self.step is None or self.step == 1: - return int - else: - return float - - def get_config_ha_ex(self): - data = { - 'min': self.min, - 'max': self.max, - 'mode': self.mode, - 'unit_of_measurement': self.uom, - 'step': self.step - } - - return data + def state(self, value): + raise NotImplementedError() diff --git a/haco/topics.py b/haco/topics.py index 4dee0d2..8923120 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -34,7 +34,7 @@ class AnnounceTopic: method_name = self.callback_name method = getattr(self.capability.control, method_name, None) self.control_method = method - setattr(self.capability.control, method_name, self.wrap_back) + setattr(self.capability.control, method_name, self.handle) def fill(self, mask): return mask.format(**self.fills) @@ -76,7 +76,7 @@ class AnnounceTopic: def capability(self): return self.parent - def wrap_back(self, value): + async def handle(self, value): raise NotImplementedError() @@ -87,7 +87,7 @@ class AnnounceTopicState(AnnounceTopic): def get_subscriptions(self): return {} - async def wrap_back(self, value): + async def handle(self, value=None): if not self.control_method: logger.error(f'Incomplete base class: {self.callback_class_method_name}') @@ -117,7 +117,7 @@ class AnnounceTopicCommand(AnnounceTopic): def state(self): return self.capability.state - async def wrap_back(self, message): + async def handle(self, message): if not self.control_method: logger.error(f'Incomplete base class: {self.callback_class_method_name}') @@ -141,7 +141,7 @@ class AnnounceTopicCommand(AnnounceTopic): # Echo back as new state topic_state = self.state if topic_state: - await topic_state.wrap_back(value_raw) + await topic_state.handle(value_raw) def get_subscriptions(self): diff --git a/haco/uom.py b/haco/uom.py index 2d2c0dc..3986da8 100644 --- a/haco/uom.py +++ b/haco/uom.py @@ -1,138 +1,142 @@ -class Uom: +from enum import StrEnum + + +class Uom(StrEnum): """ - Sourced from: https://github.com/home-assistant/core/blob/03b1c7ad1deb4b9494df01b27ef8e1d7dfe179ba/homeassistant/const.py#L489C1-L489C1 + Sourced from: https://github.com/home-assistant/core/blob/03b1c7ad1deb4b9494df01b27ef8e1d7dfe179ba/homeassistant/const.py#L489 """ - POWER_WATT: str = "W" - POWER_KILO_WATT: str = "kW" + POWER_WATT = "W" + POWER_KILO_WATT = "kW" - VOLT: str = "V" + VOLT = "V" - ENERGY_WATT_HOUR: str = "Wh" - ENERGY_KILO_WATT_HOUR: str = "kWh" + ENERGY_WATT_HOUR = "Wh" + ENERGY_KILO_WATT_HOUR = "kWh" - ELECTRICAL_CURRENT_AMPERE: str = "A" - ELECTRICAL_VOLT_AMPERE: str = "VA" + ELECTRICAL_CURRENT_AMPERE = "A" + ELECTRICAL_VOLT_AMPERE = "VA" - DEGREE: str = "°" + DEGREE = "°" - CURRENCY_EURO: str = "€" - CURRENCY_DOLLAR: str = "$" - CURRENCY_CENT: str = "¢" + CURRENCY_EURO = "€" + CURRENCY_DOLLAR = "$" + CURRENCY_CENT = "¢" - TEMP_CELSIUS: str = "°C" - TEMP_FAHRENHEIT: str = "°F" - TEMP_KELVIN: str = "K" + TEMP_CELSIUS = "°C" + TEMP_FAHRENHEIT = "°F" + TEMP_KELVIN = "K" - TIME_MICROSECONDS: str = "μs" - TIME_MILLISECONDS: str = "ms" - TIME_SECONDS: str = "s" - TIME_MINUTES: str = "min" - TIME_HOURS: str = "h" - TIME_DAYS: str = "d" - TIME_WEEKS: str = "w" - TIME_MONTHS: str = "m" - TIME_YEARS: str = "y" + TIME_MICROSECONDS = "μs" + TIME_MILLISECONDS = "ms" + TIME_SECONDS = "s" + TIME_MINUTES = "min" + TIME_HOURS = "h" + TIME_DAYS = "d" + TIME_WEEKS = "w" + TIME_MONTHS = "m" + TIME_YEARS = "y" - LENGTH_MILLIMETERS: str = "mm" - LENGTH_CENTIMETERS: str = "cm" - LENGTH_METERS: str = "m" - LENGTH_KILOMETERS: str = "km" + LENGTH_MILLIMETERS = "mm" + LENGTH_CENTIMETERS = "cm" + LENGTH_METERS = "m" + LENGTH_KILOMETERS = "km" - LENGTH_INCHES: str = "in" - LENGTH_FEET: str = "ft" - LENGTH_YARD: str = "yd" - LENGTH_MILES: str = "mi" + LENGTH_INCHES = "in" + LENGTH_FEET = "ft" + LENGTH_YARD = "yd" + LENGTH_MILES = "mi" - FREQUENCY_HERTZ: str = "Hz" - FREQUENCY_GIGAHERTZ: str = "GHz" + FREQUENCY_HERTZ = "Hz" + FREQUENCY_GIGAHERTZ = "GHz" - PRESSURE_PA: str = "Pa" - PRESSURE_HPA: str = "hPa" - PRESSURE_BAR: str = "bar" - PRESSURE_MBAR: str = "mbar" - PRESSURE_INHG: str = "inHg" - PRESSURE_PSI: str = "psi" + PRESSURE_PA = "Pa" + PRESSURE_HPA = "hPa" + PRESSURE_BAR = "bar" + PRESSURE_MBAR = "mbar" + PRESSURE_INHG = "inHg" + PRESSURE_PSI = "psi" - VOLUME_LITERS: str = "L" - VOLUME_MILLILITERS: str = "mL" - VOLUME_CUBIC_METERS: str = "m³" - VOLUME_CUBIC_FEET: str = "ft³" + VOLUME_LITERS = "L" + VOLUME_MILLILITERS = "mL" + VOLUME_CUBIC_METERS = "m³" + VOLUME_CUBIC_FEET = "ft³" - VOLUME_GALLONS: str = "gal" - VOLUME_FLUID_OUNCE: str = "fl. oz." + VOLUME_GALLONS = "gal" + VOLUME_FLUID_OUNCE = "fl. oz." - VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR: str = "m³/h" - VOLUME_FLOW_RATE_CUBIC_FEET_PER_MINUTE: str = "ft³/m" + VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR = "m³/h" + VOLUME_FLOW_RATE_CUBIC_FEET_PER_MINUTE = "ft³/m" - AREA_SQUARE_METERS: str = "m²" + AREA_SQUARE_METERS = "m²" - MASS_GRAMS: str = "g" - MASS_KILOGRAMS: str = "kg" - MASS_MILLIGRAMS: str = "mg" - MASS_MICROGRAMS: str = "µg" + MASS_GRAMS = "g" + MASS_KILOGRAMS = "kg" + MASS_MILLIGRAMS = "mg" + MASS_MICROGRAMS = "µg" - MASS_OUNCES: str = "oz" - MASS_POUNDS: str = "lb" + MASS_OUNCES = "oz" + MASS_POUNDS = "lb" - CONDUCTIVITY: str = "µS/cm" + CONDUCTIVITY = "µS/cm" - LIGHT_LUX: str = "lx" + LIGHT_LUX = "lx" - UV_INDEX: str = "UV index" + UV_INDEX = "UV index" - PERCENTAGE: str = "%" + PERCENTAGE = "%" - IRRADIATION_WATTS_PER_SQUARE_METER: str = "W/m²" + IRRADIATION_WATTS_PER_SQUARE_METER = "W/m²" - PRECIPITATION_MILLIMETERS_PER_HOUR: str = "mm/h" + PRECIPITATION_MILLIMETERS_PER_HOUR = "mm/h" - CONCENTRATION_MICROGRAMS_PER_CUBIC_METER: str = "µg/m³" - CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER: str = "mg/m³" - CONCENTRATION_PARTS_PER_CUBIC_METER: str = "p/m³" - CONCENTRATION_PARTS_PER_MILLION: str = "ppm" - CONCENTRATION_PARTS_PER_BILLION: str = "ppb" + CONCENTRATION_MICROGRAMS_PER_CUBIC_METER = "µg/m³" + CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER = "mg/m³" + CONCENTRATION_PARTS_PER_CUBIC_METER = "p/m³" + CONCENTRATION_PARTS_PER_MILLION = "ppm" + CONCENTRATION_PARTS_PER_BILLION = "ppb" - SPEED_MILLIMETERS_PER_DAY: str = "mm/d" - SPEED_INCHES_PER_DAY: str = "in/d" - SPEED_METERS_PER_SECOND: str = "m/s" - SPEED_INCHES_PER_HOUR: str = "in/h" - SPEED_KILOMETERS_PER_HOUR: str = "km/h" - SPEED_MILES_PER_HOUR: str = "mph" + SPEED_MILLIMETERS_PER_DAY = "mm/d" + SPEED_INCHES_PER_DAY = "in/d" + SPEED_METERS_PER_SECOND = "m/s" + SPEED_INCHES_PER_HOUR = "in/h" + SPEED_KILOMETERS_PER_HOUR = "km/h" + SPEED_MILES_PER_HOUR = "mph" - SIGNAL_STRENGTH_DECIBELS: str = "dB" - SIGNAL_STRENGTH_DECIBELS_MILLIWATT: str = "dBm" + SIGNAL_STRENGTH_DECIBELS = "dB" + SIGNAL_STRENGTH_DECIBELS_MILLIWATT = "dBm" - DATA_BITS: str = "bit" - DATA_KILOBITS: str = "kbit" - DATA_MEGABITS: str = "Mbit" - DATA_GIGABITS: str = "Gbit" - DATA_BYTES: str = "B" - DATA_KILOBYTES: str = "kB" - DATA_MEGABYTES: str = "MB" - DATA_GIGABYTES: str = "GB" - DATA_TERABYTES: str = "TB" - DATA_PETABYTES: str = "PB" - DATA_EXABYTES: str = "EB" - DATA_ZETTABYTES: str = "ZB" - DATA_YOTTABYTES: str = "YB" - DATA_KIBIBYTES: str = "KiB" - DATA_MEBIBYTES: str = "MiB" - DATA_GIBIBYTES: str = "GiB" - DATA_TEBIBYTES: str = "TiB" - DATA_PEBIBYTES: str = "PiB" - DATA_EXBIBYTES: str = "EiB" - DATA_ZEBIBYTES: str = "ZiB" - DATA_YOBIBYTES: str = "YiB" - DATA_RATE_BITS_PER_SECOND: str = "bit/s" - DATA_RATE_KILOBITS_PER_SECOND: str = "kbit/s" - DATA_RATE_MEGABITS_PER_SECOND: str = "Mbit/s" - DATA_RATE_GIGABITS_PER_SECOND: str = "Gbit/s" - DATA_RATE_BYTES_PER_SECOND: str = "B/s" - DATA_RATE_KILOBYTES_PER_SECOND: str = "kB/s" - DATA_RATE_MEGABYTES_PER_SECOND: str = "MB/s" - DATA_RATE_GIGABYTES_PER_SECOND: str = "GB/s" - DATA_RATE_KIBIBYTES_PER_SECOND: str = "KiB/s" - DATA_RATE_MEBIBYTES_PER_SECOND: str = "MiB/s" - DATA_RATE_GIBIBYTES_PER_SECOND: str = "GiB/s" + DATA_BITS = "bit" + DATA_KILOBITS = "kbit" + DATA_MEGABITS = "Mbit" + DATA_GIGABITS = "Gbit" + DATA_BYTES = "B" + DATA_KILOBYTES = "kB" + DATA_MEGABYTES = "MB" + DATA_GIGABYTES = "GB" + DATA_TERABYTES = "TB" + DATA_PETABYTES = "PB" + DATA_EXABYTES = "EB" + DATA_ZETTABYTES = "ZB" + DATA_YOTTABYTES = "YB" + DATA_KIBIBYTES = "KiB" + DATA_MEBIBYTES = "MiB" + DATA_GIBIBYTES = "GiB" + DATA_TEBIBYTES = "TiB" + DATA_PEBIBYTES = "PiB" + DATA_EXBIBYTES = "EiB" + DATA_ZEBIBYTES = "ZiB" + DATA_YOBIBYTES = "YiB" + + DATA_RATE_BITS_PER_SECOND = "bit/s" + DATA_RATE_KILOBITS_PER_SECOND = "kbit/s" + DATA_RATE_MEGABITS_PER_SECOND = "Mbit/s" + DATA_RATE_GIGABITS_PER_SECOND = "Gbit/s" + DATA_RATE_BYTES_PER_SECOND = "B/s" + DATA_RATE_KILOBYTES_PER_SECOND = "kB/s" + DATA_RATE_MEGABYTES_PER_SECOND = "MB/s" + DATA_RATE_GIGABYTES_PER_SECOND = "GB/s" + DATA_RATE_KIBIBYTES_PER_SECOND = "KiB/s" + DATA_RATE_MEBIBYTES_PER_SECOND = "MiB/s" + DATA_RATE_GIBIBYTES_PER_SECOND = "GiB/s" diff --git a/haco/utils.py b/haco/utils.py index 8aac036..c223482 100644 --- a/haco/utils.py +++ b/haco/utils.py @@ -2,6 +2,7 @@ import string from dataclasses import dataclass from typing import Callable +from fmtr.tools import json from fmtr.tools.datatype_tools import to_bool CHARS_ALLOWED = string.ascii_lowercase + string.digits @@ -48,6 +49,11 @@ class ConvertersString(Converters): command: Callable = str state: Callable = str + +class ConvertersNumeric(Converters): + command: Callable = json.from_json + state: Callable = json.to_json + @dataclass class Metadata: exclude: bool = False From 28e0142c4f40b5dcf5bd0a4ff9a4607b898b112a Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Wed, 26 Nov 2025 15:37:05 +0000 Subject: [PATCH 106/183] Stop state being retained --- haco/topics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haco/topics.py b/haco/topics.py index 8923120..583fce6 100644 --- a/haco/topics.py +++ b/haco/topics.py @@ -106,7 +106,7 @@ class AnnounceTopicState(AnnounceTopic): return value_raw = self.capability.converters.state(value) - await self.capability.control.device.client.publish(self.topic, value_raw, retain=True) + await self.capability.control.device.client.publish(self.topic, value_raw) return value_raw @dataclass(kw_only=True) From e31eedeb202a6b35c636f2dfc8df902e999d14b7 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sat, 29 Nov 2025 10:48:51 +0000 Subject: [PATCH 107/183] Unify version format --- haco/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haco/version b/haco/version index 8de0802..327101e 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.1.0-alpha.3 \ No newline at end of file +0.1.0-alpha004 \ No newline at end of file From b75b8c60fcf304607e385952df11189300efa2c4 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 30 Nov 2025 09:50:24 +0000 Subject: [PATCH 108/183] Add sw_version field to Device --- haco/constants.py | 5 ----- haco/device.py | 5 +++-- haco/version | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/haco/constants.py b/haco/constants.py index ad1dc52..c171ab3 100644 --- a/haco/constants.py +++ b/haco/constants.py @@ -3,7 +3,6 @@ from haco.paths import paths STATUS = 'status' HOSTNAME = net.get_hostname().lower() -F = net.get_fqdn() MAC = net.MAC() CLIENT_ID = f'{HOSTNAME}-{MAC.hex}' @@ -11,7 +10,3 @@ CLIENT_ID = f'{HOSTNAME}-{MAC.hex}' TOPIC_ROOT = Path(paths.name) / env.CHANNEL TOPIC_CLIENT = TOPIC_ROOT / CLIENT_ID TOPIC_AVAIL = TOPIC_CLIENT / STATUS -MQTT_HOST = "mqtt.service" -MQTT_PORT = 1883 -MQTT_USERNAME = "user" -MQTT_PASSWORD = None diff --git a/haco/device.py b/haco/device.py index 0f1fa0a..cc25594 100644 --- a/haco/device.py +++ b/haco/device.py @@ -15,8 +15,9 @@ if TYPE_CHECKING: @dataclass(kw_only=True) class Device(Base): name: str - manufacturer: str = "Demo" - model: str = "Python MQTT Example" + manufacturer: str | None = None + model: str | None = None + sw_version: str | None = None identifiers: list[str] | None = field(default=None, init=False) diff --git a/haco/version b/haco/version index 327101e..51c467e 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.1.0-alpha004 \ No newline at end of file +0.1.0-alpha005 \ No newline at end of file From b243c74c90525be3a2fa793720bde2e0efc81274 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Sun, 30 Nov 2025 10:21:59 +0000 Subject: [PATCH 109/183] Release version 0.1.0 --- .github/workflows/main.yml | 2 +- haco/sb1.py | 86 ----------------------------- haco/sb2.py | 108 ------------------------------------- haco/sb3.py | 2 +- haco/version | 2 +- 5 files changed, 3 insertions(+), 197 deletions(-) delete mode 100644 haco/sb1.py delete mode 100644 haco/sb2.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 58568ff..fc26a17 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,7 +53,7 @@ jobs: with: tag_name: v${{ env.VERSION }} generate_release_notes: true - prerelease: true + #prerelease: true - name: Build Wheel run: | diff --git a/haco/sb1.py b/haco/sb1.py deleted file mode 100644 index acb0af8..0000000 --- a/haco/sb1.py +++ /dev/null @@ -1,86 +0,0 @@ -import asyncio -import json - -import aiomqtt - -from haco.constants import MQTT_HOST, MQTT_PORT, MQTT_USERNAME, MQTT_PASSWORD - -DEVICE_ID = "haco_sandbox" -ENTITY_ID = "demo_switch" -DEVICE_NAME = "Haco Sandbox Device" -ENTITY_NAME = "Demo Switch" - -# Topics -CONFIG_TOPIC = f"homeassistant/switch/{ENTITY_ID}/config" -STATE_TOPIC = f"haco/{DEVICE_ID}/switch/state" -COMMAND_TOPIC = f"haco/{DEVICE_ID}/switch/set" -AVAIL_TOPIC = f"haco/{DEVICE_ID}/status" - - -async def publish_discovery(client): - """Announce the entity to Home Assistant (retained).""" - config = { - "name": ENTITY_NAME, - "unique_id": ENTITY_ID, - "state_topic": STATE_TOPIC, - "command_topic": COMMAND_TOPIC, - "availability_topic": AVAIL_TOPIC, - "payload_on": "ON", - "payload_off": "OFF", - "payload_available": "online", - "payload_not_available": "offline", - "device": { - "identifiers": [DEVICE_ID], - "name": DEVICE_NAME, - "manufacturer": "Demo", - "model": "Python MQTT Example" - } - } - - await client.publish(CONFIG_TOPIC, json.dumps(config), retain=True) - print(f"📢 Announced entity via {CONFIG_TOPIC}") - - -async def handle_commands(client): - """Listen for command messages from HA.""" - async with client.messages() as messages: - await client.subscribe(COMMAND_TOPIC) - async for message in messages: - payload = message.payload.decode() - print(f"📥 Received command: {payload}") - - # Echo back as new state - await client.publish(STATE_TOPIC, payload, retain=True) - - -async def main(): - while True: - try: - async with aiomqtt.Client( - hostname=MQTT_HOST, - port=MQTT_PORT, - username=MQTT_USERNAME, - password=MQTT_PASSWORD, - will=aiomqtt.Will( - topic=AVAIL_TOPIC, - payload="offline", - retain=True, - qos=1, - ), - ) as client: - - # Online now - await client.publish(AVAIL_TOPIC, "online", retain=True) - await publish_discovery(client) - await client.publish(STATE_TOPIC, "OFF", retain=True) - - # Wait for commands - await handle_commands(client) - - except aiomqtt.MqttError as e: - print(f"⚠️ MQTT disconnected: {e}; retrying in 5s") - await asyncio.sleep(5) - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/haco/sb2.py b/haco/sb2.py deleted file mode 100644 index 6d48106..0000000 --- a/haco/sb2.py +++ /dev/null @@ -1,108 +0,0 @@ -import asyncio -import random - -import aiomqtt - -from fmtr.tools import Constants, mqtt -from fmtr.tools.json_tools import to_json -from haco import constants - - -async def handle_commands(client, control): - """Listen for command messages from HA.""" - - subs = control.subscriptions - - async with client.messages() as messages: - - for topic_sub in subs.keys(): - await client.subscribe(topic_sub) - - async for message in messages: - payload = message.payload.decode() - print(f"{message.topic.value}{Constants.ARROW}{payload}") - method = subs[message.topic.value] - echo_val = method(payload) - echo_val - - # Echo back as new state - # await client.publish(STATE_TOPIC, payload, retain=True) - - -async def background_task(client, control): - while True: - await asyncio.sleep(10) - cap = control.capabilities[1] - value = random.randint(18, 24) - print(f'human is setting temperature to {value}') - await client.publish(cap.state.topic, payload=to_json(value), retain=True) - - -class ClientHaco(mqtt.Client): - - def __init__(self, *args, device=None, will=None, client_id=None, **kwargs): - self.will = will or mqtt.Will(topic=str(constants.TOPIC_AVAIL), payload="offline", retain=True, qos=1, ) - client_id = client_id or constants.CLIENT_ID - self.device = device - # self.device.client = self - super().__init__(*args, will=self.will, client_id=client_id, **kwargs) - - -async def main(): - # Define capabilities - - # device = Device( - # name="Development Device", - # controls=[ - # Climate( - # #id="climate_living_room", - # name="Climate Control", - # fan_modes=['a','b','c'], - # ) - # ] - # - # ) - - # announce=device.announce - # subs=device.subscriptions - - MQTT_HOST = "mqtt.service" - MQTT_PORT = 1883 - MQTT_USERNAME = "user" - MQTT_PASSWORD = None - - while True: - try: - async with ClientHaco( - hostname=MQTT_HOST, - port=MQTT_PORT, - username=MQTT_USERNAME, - password=MQTT_PASSWORD, - - client_id=constants.CLIENT_ID, - # device=device, - ) as client: - - # for topic, data in announce.items(): - # data_json = to_json(data) - # print(f'Announcing {topic} with {data_json}') - # await client.publish(topic, payload=data_json, retain=True) - - # Online now - await client.publish(client.will.topic, "online", retain=True) - - # await publish_discovery(client) - # await client.publish(STATE_TOPIC, "OFF", retain=True) - - # Wait for commands - # asyncio.create_task(background_task(client,control=climate)) - # await handle_commands(client,control=climate) - client - - except aiomqtt.MqttError as e: - print(f"⚠️ MQTT disconnected: {e}") - # await asyncio.sleep(5) - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/haco/sb3.py b/haco/sb3.py index 157fc8f..3a206c2 100644 --- a/haco/sb3.py +++ b/haco/sb3.py @@ -7,7 +7,7 @@ from haco.climate import Climate from haco.constants import MQTT_HOST from haco.device import Device from haco.obs import logger -from haco.pulldown import Select +from haco.select import Select from haco.switch import Switch handler = logger.LogfireLoggingHandler() diff --git a/haco/version b/haco/version index 51c467e..6c6aa7c 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.1.0-alpha005 \ No newline at end of file +0.1.0 \ No newline at end of file From a681aa897f6cd0336e9b044c7989381ad581d276 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Mon, 1 Dec 2025 12:53:14 +0000 Subject: [PATCH 110/183] Publish state for all capabilities on announce --- haco/control.py | 6 ++++++ haco/version | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/haco/control.py b/haco/control.py index 5b27953..cb6ae6d 100644 --- a/haco/control.py +++ b/haco/control.py @@ -101,6 +101,12 @@ 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__": control = Control(name="test", platform="test") diff --git a/haco/version b/haco/version index 6c6aa7c..6da28dd 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.1.0 \ No newline at end of file +0.1.1 \ No newline at end of file From e1656be71c9c92808f0d4dc92964d02e6a67df76 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Mon, 1 Dec 2025 13:08:35 +0000 Subject: [PATCH 111/183] Add Control.icon field (MDI only) --- haco/constants.py | 3 +++ haco/control.py | 10 ++++++++++ haco/version | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/haco/constants.py b/haco/constants.py index c171ab3..4b22965 100644 --- a/haco/constants.py +++ b/haco/constants.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from fmtr.tools import env, Path, net from haco.paths import paths @@ -10,3 +12,4 @@ CLIENT_ID = f'{HOSTNAME}-{MAC.hex}' TOPIC_ROOT = Path(paths.name) / env.CHANNEL TOPIC_CLIENT = TOPIC_ROOT / CLIENT_ID TOPIC_AVAIL = TOPIC_CLIENT / STATUS +PREFIX_MDI = "mdi:" diff --git a/haco/control.py b/haco/control.py index cb6ae6d..b14cdb0 100644 --- a/haco/control.py +++ b/haco/control.py @@ -6,6 +6,7 @@ from typing import TYPE_CHECKING, TypeVar, Generic, Type, ClassVar 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.obs import logger from haco.utils import sanitize_name, Converters, ConvertersBool @@ -14,11 +15,13 @@ if TYPE_CHECKING: DeviceT = TypeVar("DeviceT", bound="Device") + @dataclass(kw_only=True) class Control(Base, Generic[DeviceT]): converters: ClassVar[Type[Converters]] = ConvertersBool 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) @@ -30,6 +33,13 @@ class Control(Base, Generic[DeviceT]): def __post_init__(self): self.capabilities = self.get_capabilities() + if not self.icon: + return + + if not self.icon.startswith(PREFIX_MDI): + self.icon = f"{PREFIX_MDI}{self.icon}" + + def set_parent(self, device): self.device = device diff --git a/haco/version b/haco/version index 6da28dd..8294c18 100644 --- a/haco/version +++ b/haco/version @@ -1 +1 @@ -0.1.1 \ No newline at end of file +0.1.2 \ No newline at end of file From eaaa24e6e71b92a3b49fd57ed3c6d19d7a52cec3 Mon Sep 17 00:00:00 2001 From: Edward Brown Date: Mon, 1 Dec 2025 16:36:47 +0000 Subject: [PATCH 112/183] 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 113/183] 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 114/183] 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 115/183] 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 116/183] 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 117/183] 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 118/183] 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 119/183] 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 120/183] 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 121/183] 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 122/183] 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 123/183] 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 124/183] 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 125/183] 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 126/183] 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 127/183] 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 128/183] 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 129/183] 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 130/183] 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 131/183] 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 132/183] 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 133/183] 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 134/183] 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 135/183] 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 136/183] 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 137/183] 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 138/183] 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 139/183] 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 140/183] 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 141/183] 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 142/183] 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 143/183] 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 144/183] 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 145/183] 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 146/183] 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 147/183] 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 148/183] 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 149/183] 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 150/183] 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 151/183] 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 152/183] 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 153/183] 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 154/183] 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 155/183] 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 156/183] 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 157/183] 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 158/183] 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 159/183] 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 160/183] 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 161/183] 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 162/183] 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 163/183] 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 164/183] 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 165/183] 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 166/183] 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 167/183] 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 168/183] 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 169/183] 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 170/183] 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 171/183] 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 172/183] 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 173/183] 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 174/183] 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 175/183] 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 176/183] 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 177/183] 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 178/183] 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 179/183] 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 180/183] 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 181/183] 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 182/183] 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 183/183] 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"