Skip to content

Commit a03a6d6

Browse files
authored
Fix climate-parameters not updating
1 parent fe09188 commit a03a6d6

File tree

1 file changed

+39
-38
lines changed

1 file changed

+39
-38
lines changed

custom_components/plugwise-beta/climate.py

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,6 @@ def __init__(self, api, updater, name, dev_id, loc_id, min_temp, max_temp):
116116
self._hvac_mode = None
117117
self._unique_id = f"{dev_id}-climate"
118118

119-
cdata = api.get_device_data(self._api._gateway_id)
120-
if "central_heating_state" in cdata:
121-
self._central_heating_state = cdata["central_heating_state"] == "on"
122-
if "domestic_hot_water_state" in cdata:
123-
self._domestic_hot_water_state = cdata["domestic_hot_water_state"] == "on"
124-
125119
@property
126120
def unique_id(self):
127121
"""Return a unique ID."""
@@ -290,49 +284,56 @@ async def async_set_preset_mode(self, preset_mode):
290284
def update(self):
291285
"""Update the data for this climate device."""
292286
_LOGGER.info("Updating climate...")
293-
data = self._api.get_device_data(self._dev_id)
287+
climate_data = self._api.get_device_data(self._dev_id)
288+
heater_central_data = self._api.get_device_data(self._api._gateway_id)
294289

295-
if data is None:
296-
_LOGGER.debug("Received no data for device %s.", self._name)
290+
if climate_data is None:
291+
_LOGGER.debug("Received no climate_data for device %s.", self._name)
297292
else:
298-
_LOGGER.debug("Device data collected from Plugwise API")
299-
if "thermostat" in data:
300-
self._thermostat = data["thermostat"]
301-
if "temperature" in data:
302-
self._temperature = data["temperature"]
303-
if "boiler_temp" in data:
304-
self._boiler_temp = data["boiler_temp"]
305-
if "available_schedules" in data:
306-
self._schema_names = data["available_schedules"]
307-
if "selected_schedule" in data:
308-
self._selected_schema = data["selected_schedule"]
293+
_LOGGER.debug("Climate_data collected from Plugwise API")
294+
if "thermostat" in climate_data:
295+
self._thermostat = climate_data["thermostat"]
296+
if "temperature" in climate_data:
297+
self._temperature = climate_data["temperature"]
298+
if "available_schedules" in climate_data:
299+
self._schema_names = climate_data["available_schedules"]
300+
if "selected_schedule" in climate_data:
301+
self._selected_schema = climate_data["selected_schedule"]
309302
if self._selected_schema is not None:
310303
self._schema_status = True
311304
self._schedule_temp = self._thermostat
312305
else:
313306
self._schema_status = False
314-
if "last_used" in data:
315-
self._last_active_schema = data["last_used"]
316-
if "presets" in data:
317-
self._presets = data["presets"]
307+
if "last_used" in climate_data:
308+
self._last_active_schema = climate_data["last_used"]
309+
if "presets" in climate_data:
310+
self._presets = climate_data["presets"]
318311
if self._presets:
319312
self._presets_list = list(self._presets)
320-
if "active_preset" in data:
321-
self._preset_mode = data["active_preset"]
322-
if "boiler_state" in data:
323-
if data["boiler_state"] is not None:
324-
self._boiler_status = data["boiler_state"] == "on"
325-
if "central_heating_state" in data:
326-
if data["central_heating_state"] is not None:
327-
self._central_heating_state = data["central_heating_state"] == "on"
328-
if "cooling_state" in data:
329-
if data["cooling_state"] is not None:
330-
self._cooling_status = data["cooling_state"] == "on"
331-
if "domestic_hot_water_state" in data:
332-
if data["domestic_hot_water_state"] is not None:
313+
if "active_preset" in climate_data:
314+
self._preset_mode = climate_data["active_preset"]
315+
316+
if heater_central_data is None:
317+
_LOGGER.debug("Received no heater_central_data for device %s.", self._name)
318+
else:
319+
_LOGGER.debug("Heater_central_data collected from Plugwise API")
320+
if "boiler_temp" in heater_central_data:
321+
self._boiler_temp = heater_central_data["boiler_temp"]
322+
if "boiler_state" in heater_central_data:
323+
if heater_central_data["boiler_state"] is not None:
324+
self._boiler_status = heater_central_data["boiler_state"] == "on"
325+
if "central_heating_state" in heater_central_data:
326+
if heater_central_data["central_heating_state"] is not None:
327+
self._central_heating_state = heater_central_data["central_heating_state"] == "on"
328+
if "cooling_state" in heater_central_data:
329+
if heater_central_data["cooling_state"] is not None:
330+
self._cooling_status = heater_central_data["cooling_state"] == "on"
331+
if "domestic_hot_water_state" in heater_central_data:
332+
if heater_central_data["domestic_hot_water_state"] is not None:
333333
self._domestic_hot_water_state = (
334-
data["domestic_hot_water_state"] == "on"
334+
heater_central_data["domestic_hot_water_state"] == "on"
335335
)
336+
336337
if self._schema_status:
337338
self._hvac_mode = HVAC_MODE_AUTO
338339
elif (

0 commit comments

Comments
 (0)