feat: discover Symcon room utility meters and sum floor consumption

This commit is contained in:
jhartworks committed 2026-11-11 09:55:26 +01:00
1 parent 18e73194e0
commit a804fc8e15
27 files changed
+2504 -1874

No files matched your search

+30
View File
@@ -19,6 +19,36 @@ from custom_components.nextfloor.schema import (
ROOM = {"id": "r1", "name": "Bad", "area_id": None, "points": [[0, 0], [2, 0], [2, 2]], "floor_material": "tiles"}
def test_floor_utility_meters_keep_each_medium_and_allow_return_to_room_sum() -> None:
from custom_components.nextfloor.schema import FLOOR_SCHEMA
floor = {
"id": "f",
"name": "EG",
"elevation": 0,
"height": 2.5,
"cut_height": 1.2,
"background": None,
"rooms": [],
"openings": [],
"furniture": [],
"placements": [],
}
meters = {
kind: {"power": "sensor.power", "energy": "sensor.energy"}
for kind in ("electricity", "water", "gas", "heating", "cooling")
}
assert FLOOR_SCHEMA({**floor, "utility_meters": meters})["utility_meters"] == meters
assert (
FLOOR_SCHEMA({**floor, "utility_meters": {"electricity": {"power": None}}})["utility_meters"]["electricity"][
"power"
]
is None
)
with pytest.raises(vol.Invalid):
FLOOR_SCHEMA({**floor, "utility_meters": {"water": {"energy": 12345}}})
def test_start_view_keeps_its_target() -> None:
view = START_VIEW_SCHEMA({"theta": 1, "phi": 0.8, "radius": 9, "target": {"x": 1, "y": 0.5, "z": -2}})
assert view["target"] == {"x": 1.0, "y": 0.5, "z": -2.0}