Compare commits

...

10 commits
v0.4.3 ... main

Author SHA1 Message Date
Edward Brown
6aa0a6b41f Release version 0.4.7 2026-12-01 09:39:48 +00:00
Edward Brown
fbdc97a0f9 Release version 0.4.7-alpha.0 2026-12-01 09:30:52 +00:00
Edward Brown
005fa9259d Update Corio logging and test configuration 2026-12-01 09:29:36 +00:00
Edward Brown
a8c7f4ae6a Release version 0.4.6 2026-11-13 14:02:21 +00:00
Edward Brown
9dd13b4890 Release version 0.4.6-alpha.0 2026-11-13 13:14:12 +00:00
Edward Brown
06e5d43bca Configure Haco development environment 2026-10-28 18:19:03 +00:00
Edward Brown
a8359d46b1 Release version 0.4.5 2026-10-28 17:40:59 +00:00
Edward Brown
d13fd9a236 Release version 0.4.4 2026-10-28 16:12:44 +00:00
Edward Brown
362081a883 Add move completion tests 2026-10-28 16:11:35 +00:00
Edward Brown
8daac7342d Fix Corio package path logging 2026-10-28 16:10:32 +00:00
9 changed files with 202 additions and 15 deletions

View file

@ -1 +1 @@
docs/changelog/0.4.3.md docs/changelog/0.4.7.md

2
docs/changelog/0.4.4.md Normal file
View file

@ -0,0 +1,2 @@
- Updated Corio integration for the current package paths API.
- Added an automated test environment for the package test suite.

2
docs/changelog/0.4.5.md Normal file
View file

@ -0,0 +1,2 @@
- Restored the runtime dependency metadata for installations.
- Added the automated Haco test environment to release validation.

1
docs/changelog/0.4.6.md Normal file
View file

@ -0,0 +1 @@
- Update the Corio dependency to its latest stable release.

1
docs/changelog/0.4.7.md Normal file
View file

@ -0,0 +1 @@
- Logs now use the package name and version and respect the configured development or production environment.

View file

@ -3,14 +3,10 @@
Observability and logging setup for the haco library. Observability and logging setup for the haco library.
""" """
from corio import logs, debug, Constants from corio import debug, logs
from haco.paths import paths from haco.paths import paths
debug.trace() debug.trace()
logger = logs.get_logger( logger = logs.from_paths(paths)
name=paths.name_ns,
stream=Constants.DEVELOPMENT,
version=paths.metadata.version,
)

View file

@ -1,6 +1,8 @@
import asyncio import asyncio
import logging import logging
from logfire import LogfireLoggingHandler
from haco.button import Button from haco.button import Button
from haco.client import ClientHaco from haco.client import ClientHaco
from haco.climate import Climate from haco.climate import Climate
@ -9,7 +11,7 @@ from haco.obs import logger
from haco.select import Select from haco.select import Select
from haco.switch import Switch from haco.switch import Switch
handler = logger.LogfireLoggingHandler() handler = LogfireLoggingHandler(logfire_instance=logger)
logging.basicConfig(handlers=[handler], level=logging.DEBUG) logging.basicConfig(handlers=[handler], level=logging.DEBUG)
async def main(): async def main():

View file

@ -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()

View file

@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[tool.corio.metadata] [tool.corio.metadata]
version = "0.4.3" version = "0.4.7"
port = 6 port = 6
base = "python" base = "python"
description = "Home Assistant Control Objects" description = "Home Assistant Control Objects"
@ -15,44 +15,72 @@ services = []
keywords = ["homeassistant", "controls", "python", "tasmota"] keywords = ["homeassistant", "controls", "python", "tasmota"]
is_pypi = true is_pypi = true
is_dockerhub = false is_dockerhub = false
editables = ["corio"]
[tool.corio.metadata.setup] [tool.corio.metadata.setup]
[tool.corio.test-envs]
dev = ["dev"]
[tool.setuptools]
include-package-data = false
[tool.setuptools.packages.find] [tool.setuptools.packages.find]
where = ["."] where = ["."]
include = ["haco*"] include = ["haco*"]
namespaces = false namespaces = false
[tool.setuptools.package-data] [tool.setuptools.package-data]
haco = ["pyproject.package.toml", "assets/**"] haco = ["pyproject.package.toml", "**/assets/**"]
[tool.uv.sources.corio] [tool.uv.sources.corio]
path = "../corio" path = "../corio"
editable = true editable = true
[tool.uv.config-settings-package.corio]
editable_mode = "compat"
[tool.tox] [tool.tox]
requires = ["tox>=4.22", "tox-uv>=1"] requires = ["tox>=4.22", "tox-uv>=1"]
env_list = [] env_list = ["prod"]
[tool.tox.env] [tool.tox.env.dev]
description = "Run haco tests."
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.6"]
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] [project]
name = "haco" name = "haco"
version = "0.4.3" version = "0.4.7"
description = "Home Assistant Control Objects" description = "Home Assistant Control Objects"
readme = "README.md" readme = "README.md"
license = "Apache-2.0" license = "Apache-2.0"
keywords = ["homeassistant", "controls", "python", "tasmota"] keywords = ["homeassistant", "controls", "python", "tasmota"]
dependencies = ["corio[api,caching,debug,logging,mqtt,sets,version.dev,yaml]~=2.15.9", "psutil"] dependencies = ["corio[api,caching,debug,mqtt,sets,yaml]~=2.21.6", "psutil"]
[[project.authors]] [[project.authors]]
name = "Frontmatter AI" name = "Frontmatter AI"
email = "innovative.fowler@mask.pro.fmtr.dev" email = "innovative.fowler@mask.pro.fmtr.dev"
[project.optional-dependencies] [project.optional-dependencies]
test = ["corio[test]~=2.15.9"] dev = ["corio[infra]~=2.21.6"]
test = ["corio[test]~=2.21.6"]
[project.urls] [project.urls]
Homepage = "https://github.com/fmtr/haco" Homepage = "https://github.com/fmtr/haco"
[project.scripts] [project.scripts]
[dependency-groups]
dev = ["corio[infra]~=2.21.6"]