Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.13.1

- Implement dedicated boiler_temperature dict for legacy Anna via PR [#893](https://github.com/plugwise/python-plugwise/pull/893)

## v1.13.0

- Improve on v1.12.0 update by outputting dedicated boiler_ and dhw_temperature dicts with current-key added. Rename dhw_mode off to eco for standard cv-heaters.
Expand Down
10 changes: 5 additions & 5 deletions fixtures/legacy_anna/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
"flame_state": true,
"heating_state": true
},
"dev_class": "heater_central",
"location": "0000aaaa0000aaaa0000aaaa0000aa00",
"maximum_boiler_temperature": {
"boiler_temperature": {
"current": 23.6,
"lower_bound": 50.0,
"resolution": 1.0,
"setpoint": 50.0,
"upper_bound": 90.0
},
"dev_class": "heater_central",
"location": "0000aaaa0000aaaa0000aaaa0000aa00",
"model": "Generic heater",
"name": "OpenTherm",
"sensors": {
"dhw_temperature": 51.2,
"intended_boiler_temperature": 17.0,
"modulation_level": 0.0,
"return_temperature": 21.7,
"water_pressure": 1.2,
"water_temperature": 23.6
"water_pressure": 1.2
},
"vendor": "Bosch Thermotechniek B.V."
},
Expand Down
10 changes: 5 additions & 5 deletions fixtures/legacy_anna_2/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,23 @@
"flame_state": false,
"heating_state": false
},
"dev_class": "heater_central",
"location": "be81e3f8275b4129852c4d8d550ae2eb",
"maximum_boiler_temperature": {
"boiler_temperature": {
"current": 54.0,
"lower_bound": 50.0,
"resolution": 1.0,
"setpoint": 70.0,
"upper_bound": 90.0
},
"dev_class": "heater_central",
"location": "be81e3f8275b4129852c4d8d550ae2eb",
"model": "Generic heater",
"name": "OpenTherm",
"sensors": {
"dhw_temperature": 0.0,
"intended_boiler_temperature": 0.0,
"modulation_level": 0.0,
"return_temperature": 0.0,
"water_pressure": 1.7,
"water_temperature": 54.0
"water_pressure": 1.7
}
}
}
30 changes: 30 additions & 0 deletions plugwise/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@

from plugwise.constants import (
ANNA,
DHW_SETPOINT,
GROUP_TYPES,
NONE,
PRIORITY_DEVICE_CLASSES,
SPECIAL_PLUG_TYPES,
SWITCH_GROUP_TYPES,
ActuatorData,
ApplianceType,
GwEntityData,
ModuleData,
Expand Down Expand Up @@ -289,3 +291,31 @@ def _get_module_data(
break

return module_data

def _create_special_dicts(
self, item: str, data: GwEntityData, temp_dict: ActuatorData
) -> tuple[str, ActuatorData]:
"""Create dhw_temperature and boiler_temperature dicts.

The initial item-names are updated and a current key is added.
Also, the copied sensor data is removed.
"""
if item == DHW_SETPOINT:
item = "dhw_temperature"
if DHW_SETPOINT in data["sensors"]:
data["sensors"].pop(DHW_SETPOINT)
self._count -= 1
if "dhw_temperature" in data["sensors"]:
temp_dict["current"] = data["sensors"]["dhw_temperature"]
data["sensors"].pop("dhw_temperature")
elif "water_temperature" in data["sensors"]:
temp_dict["current"] = data["sensors"]["water_temperature"]
self._count += 1

if item == "maximum_boiler_temperature":
item = "boiler_temperature"
if "water_temperature" in data["sensors"]:
temp_dict["current"] = data["sensors"]["water_temperature"]
data["sensors"].pop("water_temperature")

return item, temp_dict
29 changes: 0 additions & 29 deletions plugwise/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
ATTR_NAME,
DATA,
DEVICE_MEASUREMENTS,
DHW_SETPOINT,
DOMAIN_OBJECTS,
ENERGY_WATT_HOUR,
GROUP_MEASUREMENTS,
Expand Down Expand Up @@ -587,34 +586,6 @@ def _get_actuator_functionalities(
act_item = cast(ActuatorType, item)
data[act_item] = temp_dict

def _create_special_dicts(
self, item: str, data: GwEntityData, temp_dict: ActuatorData
) -> tuple[str, ActuatorData]:
"""Create dhw_temperature and boiler_temperature dicts.

The initial item-names are updated and a current key is added.
Also, the copied sensor data is removed.
"""
if item == DHW_SETPOINT:
item = "dhw_temperature"
if DHW_SETPOINT in data["sensors"]:
data["sensors"].pop(DHW_SETPOINT)
self._count -= 1
if "dhw_temperature" in data["sensors"]:
temp_dict["current"] = data["sensors"]["dhw_temperature"]
data["sensors"].pop("dhw_temperature")
elif "water_temperature" in data["sensors"]:
temp_dict["current"] = data["sensors"]["water_temperature"]
self._count += 1

if item == "maximum_boiler_temperature":
item = "boiler_temperature"
if "water_temperature" in data["sensors"]:
temp_dict["current"] = data["sensors"]["water_temperature"]
data["sensors"].pop("water_temperature")

return item, temp_dict

def _get_actuator_mode(
self, appliance: etree.Element, entity_id: str, key: str
) -> str | None:
Expand Down
5 changes: 4 additions & 1 deletion plugwise/legacy/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ def _appliance_measurements(

self._count = count_data_items(self._count, data)

def _get_actuator_functionalities(self, xml: etree.Element, data: GwEntityData) -> None:
def _get_actuator_functionalities(
self, xml: etree.Element, data: GwEntityData
) -> None:
"""Helper-function for _get_measurement_data()."""
for item in ACTIVE_ACTUATORS:
temp_dict: ActuatorData = {}
Expand All @@ -364,6 +366,7 @@ def _get_actuator_functionalities(self, xml: etree.Element, data: GwEntityData)
self._count += 1

if temp_dict:
item, temp_dict = self._create_special_dicts(item, data, temp_dict)
act_item = cast(ActuatorType, item)
data[act_item] = temp_dict

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "plugwise"
version = "1.13.0"
version = "1.13.1"
license = "MIT"
description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3."
readme = "README.md"
Expand Down
18 changes: 12 additions & 6 deletions tests/data/anna/legacy_anna.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
"flame_state": true,
"heating_state": true
},
"dev_class": "heater_central",
"location": "0000aaaa0000aaaa0000aaaa0000aa00",
"maximum_boiler_temperature": {
"boiler_temperature": {
"current": 23.6,
"lower_bound": 50.0,
"resolution": 1.0,
"setpoint": 50.0,
"upper_bound": 90.0
},
"dev_class": "heater_central",
"location": "0000aaaa0000aaaa0000aaaa0000aa00",
"model": "Generic heater",
"name": "OpenTherm",
"sensors": {
"dhw_temperature": 51.2,
"intended_boiler_temperature": 17.0,
"modulation_level": 0.0,
"return_temperature": 21.7,
"water_pressure": 1.2,
"water_temperature": 23.6
"water_pressure": 1.2
},
"vendor": "Bosch Thermotechniek B.V."
},
Expand All @@ -44,7 +44,13 @@
"location": "0000aaaa0000aaaa0000aaaa0000aa00",
"model": "ThermoTouch",
"name": "Anna",
"preset_modes": ["away", "vacation", "asleep", "home", "no_frost"],
"preset_modes": [
"away",
"vacation",
"asleep",
"home",
"no_frost"
],
"select_schedule": null,
"sensors": {
"illuminance": 150.8,
Expand Down
23 changes: 16 additions & 7 deletions tests/data/anna/legacy_anna_2.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"9e7377867dc24e51b8098a5ba02bd89d": {
"active_preset": null,
"available_schedules": ["Thermostat schedule", "off"],
"available_schedules": [
"Thermostat schedule",
"off"
],
"climate_mode": "heat",
"control_state": "idle",
"dev_class": "thermostat",
Expand All @@ -10,7 +13,13 @@
"location": "be81e3f8275b4129852c4d8d550ae2eb",
"model": "ThermoTouch",
"name": "Anna",
"preset_modes": ["vacation", "away", "no_frost", "home", "asleep"],
"preset_modes": [
"vacation",
"away",
"no_frost",
"home",
"asleep"
],
"select_schedule": "off",
"sensors": {
"illuminance": 19.5,
Expand Down Expand Up @@ -42,23 +51,23 @@
"flame_state": false,
"heating_state": false
},
"dev_class": "heater_central",
"location": "be81e3f8275b4129852c4d8d550ae2eb",
"maximum_boiler_temperature": {
"boiler_temperature": {
"current": 54.0,
"lower_bound": 50.0,
"resolution": 1.0,
"setpoint": 70.0,
"upper_bound": 90.0
},
"dev_class": "heater_central",
"location": "be81e3f8275b4129852c4d8d550ae2eb",
"model": "Generic heater",
"name": "OpenTherm",
"sensors": {
"dhw_temperature": 0.0,
"intended_boiler_temperature": 0.0,
"modulation_level": 0.0,
"return_temperature": 0.0,
"water_pressure": 1.7,
"water_temperature": 54.0
"water_pressure": 1.7
}
}
}