Skip to content

Commit f347b6b

Browse files
committed
Update test-jsons
1 parent 2f53805 commit f347b6b

File tree

9 files changed

+516
-360
lines changed

9 files changed

+516
-360
lines changed

fixtures/anna_v4/all_data.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@
3333
"setpoint": 0.0,
3434
"upper_bound": 2.0
3535
},
36-
"thermostat": {
37-
"lower_bound": 4.0,
38-
"resolution": 0.1,
39-
"setpoint": 20.5,
40-
"upper_bound": 30.0
41-
},
4236
"vendor": "Plugwise"
4337
},
4438
"0466eae8520144c78afb29628384edeb": {
@@ -99,9 +93,10 @@
9993
"cooling_present": false,
10094
"gateway_id": "0466eae8520144c78afb29628384edeb",
10195
"heater_id": "cd0e6156b1f04d5f952349ffbe397481",
102-
"item_count": 58,
96+
"item_count": 50,
10397
"notifications": {},
10498
"reboot": true,
10599
"smile_name": "Smile Anna"
106-
}
100+
},
101+
"zones": {}
107102
}

plugwise/data.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def _all_device_data(self) -> None:
3434
Collect data for each device and add to self.gw_data and self.gw_devices.
3535
"""
3636
self._update_gw_devices()
37-
self._update_zones()
37+
if self.smile(ADAM):
38+
self._update_zones()
3839
self.gw_data.update(
3940
{
4041
"gateway_id": self.gateway_id,
@@ -190,6 +191,10 @@ def _get_device_data(self, dev_id: str) -> DeviceData:
190191
# Adam data
191192
self._device_data_adam(device, data)
192193

194+
# Thermostat data for Anna (presets, temperatures etc)
195+
if self.smile(ANNA) and device["dev_class"] == "thermostat":
196+
self._device_data_climate(dev_id, device, data)
197+
193198
return data
194199

195200
def _check_availability(
@@ -232,11 +237,15 @@ def _device_data_adam(self, device: DeviceData, data: DeviceData) -> None:
232237
self._count += 1
233238

234239

235-
def _device_data_climate(self, loc_id: str, device: DeviceData, data: DeviceData) -> None:
240+
def _device_data_climate(self, location_id: str, device: DeviceData, data: DeviceData) -> None:
236241
"""Helper-function for _get_device_data().
237242
238243
Determine climate-control device data.
239244
"""
245+
loc_id = location_id
246+
if (dev_loc := device.get("location")) is not None:
247+
loc_id = dev_loc
248+
240249
# Presets
241250
data["preset_modes"] = None
242251
data["active_preset"] = None

plugwise/helper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ def _match_locations(self) -> dict[str, ThermoLoc]:
855855
for appliance_details in self.gw_devices.values():
856856
if appliance_details["location"] == location_id:
857857
location_details.update(
858-
{"primary": set(), "primary_prio": 0, "secondary": set()}
858+
{"primary": [], "primary_prio": 0, "secondary": []}
859859
)
860860
matched_locations[location_id] = location_details
861861

@@ -880,13 +880,13 @@ def _rank_thermostat(
880880
if thermo_matching[appl_class] > self._thermo_locs[loc_id]["primary_prio"]:
881881
# Demote former primary
882882
if (tl_primary:= self._thermo_locs[loc_id]["primary"]):
883-
self._thermo_locs[loc_id]["secondary"].add(tl_primary)
883+
self._thermo_locs[loc_id]["secondary"].append(tl_primary)
884884

885885
# Crown primary
886886
self._thermo_locs[loc_id]["primary_prio"] = thermo_matching[appl_class]
887-
self._thermo_locs[loc_id]["primary"].add(appliance_id)
887+
self._thermo_locs[loc_id]["primary"].append(appliance_id)
888888
else:
889-
self._thermo_locs[loc_id]["secondary"].add(appliance_id)
889+
self._thermo_locs[loc_id]["secondary"].append(appliance_id)
890890

891891
def _control_state(self, loc_id: str) -> str | bool:
892892
"""Helper-function for _device_data_adam().

0 commit comments

Comments
 (0)