M5-T11: add HA discovery and state publishing wired to polling

This commit is contained in:
2026-06-22 15:32:43 +02:00
parent 9d05f5ea62
commit 35b95f5c88
7 changed files with 1657 additions and 23 deletions
+11 -3
View File
@@ -108,11 +108,17 @@ def test_exposable_entity_fields():
def test_exposable_entity_with_value_getter():
"""ExposableEntity.value_getter stores and calls the provided callable."""
"""ExposableEntity.value_getter stores and calls the provided callable.
value_getter now accepts a Session argument (updated in T11-rework-1).
"""
from app.integrations.expose import DeviceInfo, ExposableEntity
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
device = DeviceInfo(identifiers=("modbus", "dev1"), name="D1")
getter = lambda: 230.5 # noqa: E731
# The value_getter receives a Session; use a lambda that ignores it.
getter = lambda _sess: 230.5 # noqa: E731
entity = ExposableEntity(
key="modbus.dev1.voltage",
component="sensor",
@@ -123,7 +129,9 @@ def test_exposable_entity_with_value_getter():
value_getter=getter,
)
assert entity.value_getter is not None
assert entity.value_getter() == 230.5
eng = create_engine("sqlite:///:memory:")
with Session(eng) as session:
assert entity.value_getter(session) == 230.5
def test_entity_key_stability_uses_uuid_not_id():
File diff suppressed because it is too large Load Diff