Skip to content

Commit bf48a4f

Browse files
authored
Merge pull request #201 from plugwise/pre_0_18_6
`max_boiler_temperature` related fix/update
2 parents 4e041a3 + 078751c commit bf48a4f

File tree

9 files changed

+43
-33
lines changed

9 files changed

+43
-33
lines changed

.github/workflows/merge.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ env:
88
DEFAULT_PYTHON: 3.9
99

1010
# Only run on merges
11-
on:
11+
on:
1212
pull_request:
1313
types: closed
1414
branches:
1515
- main
16+
- 0_18_5_release
1617

1718
jobs:
1819
publishing:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
# v0.18.6: Smile: Maximum_boiler_temperature related improvements
4+
- Improve set_max_boiler_temperature() function
5+
- Add lower/upper_bound and resolution for maximum_boiler_temperature
6+
37
# v0.18.5: Smile bugfix for #192
48

59
# v0.18.4: Smile: schedule-related bug-fixes and clean-up

plugwise/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Plugwise module."""
22

3-
__version__ = "0.18.5"
3+
__version__ = "0.18.6"
44

55
from plugwise.smile import Smile
66
from plugwise.stick import Stick

plugwise/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,9 @@
503503
ATTR_NAME: "outdoor_air_temperature",
504504
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
505505
},
506+
"lower_bound": {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS},
507+
"upper_bound": {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS},
508+
"resolution": {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS},
506509
}
507510

508511
# Known types of Smiles and Stretches

plugwise/helper.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
# This way of importing aiohttp is because of patch/mocking in testing (aiohttp timeouts)
1010
from aiohttp import BasicAuth, ClientError, ClientResponse, ClientSession, ClientTimeout
11+
12+
# Time related
13+
from dateutil import tz
1114
from dateutil.parser import parse
1215
from defusedxml import ElementTree as etree
1316
from munch import Munch
14-
15-
# Time related
16-
import pytz
1717
from semver import VersionInfo
1818

1919
from .constants import (
@@ -764,16 +764,17 @@ def _appliance_measurements(
764764
data[name] = format_measure(appl_i_loc.text, ENERGY_WATT_HOUR) # type: ignore [literal-required]
765765

766766
# Thermostat actuator measurements
767-
t_locator = f'.//actuator_functionalities/thermostat_functionality[type="thermostat"]/{measurement}'
768-
if (t_function := appliance.find(t_locator)) is not None:
769-
if new_name := attrs.get(ATTR_NAME):
770-
measurement = new_name
771-
772-
# Avoid double processing
773-
if measurement == "setpoint":
774-
continue
767+
for item in ["thermostat", "maximum_boiler_temperature"]:
768+
t_locator = f'.//actuator_functionalities/thermostat_functionality[type="{item}"]/{measurement}'
769+
if (t_function := appliance.find(t_locator)) is not None:
770+
if new_name := attrs.get(ATTR_NAME):
771+
measurement = new_name
772+
773+
# Avoid double processing
774+
if measurement == "setpoint":
775+
continue
775776

776-
data[measurement] = format_measure(t_function.text, attrs[ATTR_UNIT_OF_MEASUREMENT]) # type: ignore [literal-required]
777+
data[measurement] = format_measure(t_function.text, attrs[ATTR_UNIT_OF_MEASUREMENT]) # type: ignore [literal-required]
777778

778779
return data
779780

@@ -1106,7 +1107,7 @@ def _last_used_schedule(self, loc_id: str, schedules: list[str]) -> str | None:
11061107
if not schedules:
11071108
return last_used # pragma: no cover
11081109

1109-
epoch = dt.datetime(1970, 1, 1, tzinfo=pytz.utc)
1110+
epoch = dt.datetime(1970, 1, 1, tzinfo=tz.tzutc())
11101111
schedules_dates: dict[str, float] = {}
11111112

11121113
for name in schedules:

plugwise/smile.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -584,14 +584,16 @@ async def set_max_boiler_temperature(self, temperature: float) -> None:
584584
"""Set the max. Boiler Temperature on the Central heating boiler."""
585585
temp = str(temperature)
586586
locator = f'appliance[@id="{self._heater_id}"]/actuator_functionalities/thermostat_functionality'
587-
th_func = self._appliances.find(locator)
588-
if th_func.find("type").text == "maximum_boiler_temperature":
589-
thermostat_id = th_func.attrib["id"]
587+
if th_func_list := self._appliances.findall(locator):
588+
for th_func in th_func_list:
589+
if th_func.find("type").text != "maximum_boiler_temperature":
590+
continue
590591

591-
uri = f"{APPLIANCES};id={self._heater_id}/thermostat;id={thermostat_id}"
592-
data = f"<thermostat_functionality><setpoint>{temp}</setpoint></thermostat_functionality>"
592+
thermostat_id = th_func.attrib["id"]
593+
uri = f"{APPLIANCES};id={self._heater_id}/thermostat;id={thermostat_id}"
594+
data = f"<thermostat_functionality><setpoint>{temp}</setpoint></thermostat_functionality>"
593595

594-
await self._request(uri, method="put", data=data)
596+
await self._request(uri, method="put", data=data)
595597

596598
async def _set_groupswitch_member_state(
597599
self, members: list[str], state: str, switch: Munch

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def readme():
4242
"defusedxml",
4343
"munch",
4444
"pyserial",
45-
"pytz",
4645
"python-dateutil",
4746
"semver",
4847
],

tests/test_smile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ async def test_connect_adam_plus_anna(self):
13341334
"model": "Generic heater",
13351335
"name": "OpenTherm",
13361336
"lower_bound": 0.0,
1337-
"upper_bound": 30.0,
1337+
"upper_bound": 100.0,
13381338
"resolution": 1.0,
13391339
"maximum_boiler_temperature": 80.0,
13401340
"binary_sensors": {

userdata/adam_jip/core.appliances.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,16 @@
419419
</point_log>
420420
</logs>
421421
<actuator_functionalities>
422+
<thermostat_functionality id='7fd75eb3275d4502b97b81780cff5b31'>
423+
<updated_date>2021-01-15T15:05:43.778+01:00</updated_date>
424+
<type>domestic_hot_water_setpoint</type>
425+
<setpoint>60</setpoint>
426+
<lower_bound>40</lower_bound>
427+
<upper_bound>60</upper_bound>
428+
<resolution>0.01</resolution>
429+
<regulations/>
430+
<thermostat id='029dce4abaeb499d9f254ac38b4dc72f'/>
431+
</thermostat_functionality>
422432
<toggle_functionality id='4c95a2a0ae4e41da8333bd60b48f1af2'>
423433
<domestic_hot_water_toggle id='d90cc53830864417b94b2bd08064c77a'/>
424434
<updated_date>2021-06-04T15:37:30.430+02:00</updated_date>
@@ -435,16 +445,6 @@
435445
<regulations/>
436446
<thermostat id='522f5746986f4f4b86307e82278f5d15'/>
437447
</thermostat_functionality>
438-
<thermostat_functionality id='7fd75eb3275d4502b97b81780cff5b31'>
439-
<updated_date>2021-01-15T15:05:43.778+01:00</updated_date>
440-
<type>domestic_hot_water_setpoint</type>
441-
<setpoint>60</setpoint>
442-
<lower_bound>40</lower_bound>
443-
<upper_bound>60</upper_bound>
444-
<resolution>0.01</resolution>
445-
<regulations/>
446-
<thermostat id='029dce4abaeb499d9f254ac38b4dc72f'/>
447-
</thermostat_functionality>
448448
</actuator_functionalities>
449449
</appliance>
450450
<appliance id='a6abc6a129ee499c88a4d420cc413b47'>

0 commit comments

Comments
 (0)