mirror of
https://github.com/fmtr/haco.git
synced 2026-10-25 18:40:15 -04:00
Compare commits
12 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61ea555cf2 | ||
|
|
c3299ab0c1 | ||
|
|
0d6872797a | ||
|
|
5fc71ce126 | ||
|
|
1dc5b3711c | ||
|
|
953d31db55 | ||
|
|
aacb79ab61 | ||
|
|
57a5f5c329 | ||
|
|
b4b7c44a64 | ||
|
|
26a93e9a89 | ||
|
|
09f451348b | ||
|
|
d9a8561e41 |
5 changed files with 44 additions and 10 deletions
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@
|
|||
Path definitions for the haco library.
|
||||
|
||||
"""
|
||||
from corio import sets
|
||||
from corio import paths
|
||||
|
||||
paths = sets.PackagePaths()
|
||||
paths = paths.PackagePaths()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ requires = ["setuptools>=82", "wheel"]
|
|||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.corio.metadata]
|
||||
version = "0.3.7"
|
||||
version = "0.4.2"
|
||||
port = 6
|
||||
base = "python"
|
||||
description = "Home Assistant Control Objects"
|
||||
|
|
@ -24,27 +24,33 @@ include = ["haco*"]
|
|||
namespaces = false
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
haco = ["pyproject.package.toml"]
|
||||
haco = ["pyproject.package.toml", "assets/**"]
|
||||
|
||||
[tool.uv.sources.corio]
|
||||
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.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.2.2", "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 = ["pytest>=8.0", "pytest-cov>=5.0"]
|
||||
test = ["corio[test]~=2.8.2"]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://github.com/fmtr/haco"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue