Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 1a2454f

Browse files
authored
Support rooms with activeControl property (#31)
1 parent a899839 commit 1a2454f

1 file changed

Lines changed: 33 additions & 21 deletions

File tree

custom_components/ngenic/climate.py

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,39 @@ async def async_setup_entry(hass, entry, async_add_entities):
3232
# listing tunes contain less information than when querying a single tune
3333
tune = await ngenic.async_tune(tmp_tune.uuid())
3434

35-
# get the room whose sensor data and target temperature should be used as inputs to the Tune control system
36-
control_room = await tune.async_room(tune["roomToControlUuid"])
37-
38-
# get the room node
39-
control_node = await tune.async_node(control_room["nodeUuid"])
40-
41-
device = NgenicTune(
42-
hass,
43-
ngenic,
44-
tune,
45-
control_room,
46-
control_node
47-
)
48-
49-
# Initial update
50-
await device._async_update()
51-
52-
# Setup update timer
53-
device._setup_updater()
54-
55-
devices.append(device)
35+
# rooms with control sensors can be found either directly on the tune, or by looking at the activeControl
36+
# property on the room object. if roomToControlUuid is set, it takes precedence and the activeControl
37+
# attribute will not be used
38+
control_room_uuids = []
39+
if tune["roomToControlUuid"]:
40+
control_room_uuids.append(tune["roomToControlUuid"])
41+
else:
42+
for room in tune["rooms"]:
43+
if room["activeControl"] is True:
44+
control_room_uuids.append(room['uuid'])
45+
46+
for control_room_uuid in control_room_uuids:
47+
# get the room whose sensor data and target temperature should be used as inputs to the Tune control system
48+
control_room = await tune.async_room(control_room_uuid)
49+
50+
# get the room node
51+
control_node = await tune.async_node(control_room["nodeUuid"])
52+
53+
device = NgenicTune(
54+
hass,
55+
ngenic,
56+
tune,
57+
control_room,
58+
control_node
59+
)
60+
61+
# Initial update
62+
await device._async_update()
63+
64+
# Setup update timer
65+
device._setup_updater()
66+
67+
devices.append(device)
5668

5769
async_add_entities(devices)
5870

0 commit comments

Comments
 (0)