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