Skip to content

Commit 504275c

Browse files
author
Vilppu Vuorinen
committed
Add ATW boiler flow and mixing tank temps
1 parent ea4cf93 commit 504275c

File tree

4 files changed

+51
-11
lines changed

4 files changed

+51
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- Boiler flow and mixing tank temperatures for Atw devices.
10+
811
### Changed
912
- Increate ListDevices poll rate to match the sensor poll rates.
1013

pymelcloud/atw_device.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -334,16 +334,12 @@ def apply_write(self, state: Dict[str, Any], key: str, value: Any):
334334
@property
335335
def tank_temperature(self) -> Optional[float]:
336336
"""Return tank water temperature."""
337-
if self._state is None:
338-
return None
339-
return self._state.get("TankWaterTemperature")
337+
return self.get_state_prop("TankWaterTemperature")
340338

341339
@property
342340
def target_tank_temperature(self) -> Optional[float]:
343341
"""Return target tank water temperature."""
344-
if self._state is None:
345-
return None
346-
return self._state.get("SetTankWaterTemperature")
342+
return self.get_state_prop("SetTankWaterTemperature")
347343

348344
@property
349345
def target_tank_temperature_min(self) -> Optional[float]:
@@ -360,8 +356,7 @@ def target_tank_temperature_max(self) -> Optional[float]:
360356
361357
This value can be set using PROPERTY_TARGET_TANK_TEMPERATURE.
362358
"""
363-
device = self._device_conf.get("Device", {})
364-
return device.get("MaxTankTemperature")
359+
return self.get_device_prop("MaxTankTemperature")
365360

366361
@property
367362
def outside_temperature(self) -> Optional[float]:
@@ -371,9 +366,22 @@ def outside_temperature(self) -> Optional[float]:
371366
rate. The value is reported using 1°C (2°F?) accuracy and updated every 2
372367
hours.
373368
"""
374-
if self._state is None:
375-
return None
376-
return self._state.get("OutdoorTemperature")
369+
return self.get_state_prop("OutdoorTemperature")
370+
371+
@property
372+
def flow_temperature_boiler(self) -> Optional[float]:
373+
"""Return flow temperature of the boiler."""
374+
return self.get_device_prop("FlowTemperatureBoiler")
375+
376+
@property
377+
def return_temperature_boiler(self) -> Optional[float]:
378+
"""Return flow temperature of the boiler."""
379+
return self.get_device_prop("FlowTemperatureBoiler")
380+
381+
@property
382+
def mixing_tank_temperature(self) -> Optional[float]:
383+
"""Return mixing tank temperature."""
384+
return self.get_device_prop("MixingTankWaterTemperature")
377385

378386
@property
379387
def zones(self) -> Optional[List[Zone]]:

pymelcloud/device.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ def __init__(
4949
self._write_task: Optional[asyncio.Future[None]] = None
5050
self._pending_writes: Dict[str, Any] = {}
5151

52+
def get_device_prop(self, name: str) -> Optional[Any]:
53+
"""Access device properties while shortcutting the nested device access."""
54+
device = self._device_conf.get("Device", {})
55+
return device.get(name)
56+
57+
def get_state_prop(self, name: str) -> Optional[Any]:
58+
"""Access state prop without None check."""
59+
if self._state is None:
60+
return None
61+
return self._state.get(name)
62+
5263
@abstractmethod
5364
def apply_write(self, state: Dict[str, Any], key: str, value: Any):
5465
"""Apply writes to state object.

tests/test_atw_properties.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ async def test_1zone():
5959
assert device.target_tank_temperature is None
6060
assert device.target_tank_temperature_min == 40
6161
assert device.target_tank_temperature_max == 60
62+
assert device.flow_temperature_boiler == 25
63+
assert device.return_temperature_boiler == 25
64+
assert device.mixing_tank_temperature == 0
6265
assert device.holiday_mode is None
6366
assert device.wifi_signal == -73
6467
assert device.has_error is False
@@ -88,6 +91,9 @@ async def test_1zone():
8891
assert device.status == STATUS_HEAT_ZONES
8992
assert device.tank_temperature == 52.0
9093
assert device.target_tank_temperature == 50.0
94+
assert device.flow_temperature_boiler == 25
95+
assert device.return_temperature_boiler == 25
96+
assert device.mixing_tank_temperature == 0
9197
assert device.holiday_mode is False
9298
assert device.wifi_signal == -73
9399
assert device.has_error is False
@@ -123,6 +129,9 @@ async def test_2zone():
123129
assert device.target_tank_temperature is None
124130
assert device.target_tank_temperature_min == 40
125131
assert device.target_tank_temperature_max == 60
132+
assert device.flow_temperature_boiler == 25
133+
assert device.return_temperature_boiler == 25
134+
assert device.mixing_tank_temperature == 0
126135
assert device.holiday_mode is None
127136
assert device.wifi_signal == -37
128137
assert device.has_error is False
@@ -167,6 +176,9 @@ async def test_2zone():
167176
assert device.status == STATUS_HEAT_ZONES
168177
assert device.tank_temperature == 49.5
169178
assert device.target_tank_temperature == 50.0
179+
assert device.flow_temperature_boiler == 25
180+
assert device.return_temperature_boiler == 25
181+
assert device.mixing_tank_temperature == 0
170182
assert device.holiday_mode is False
171183
assert device.wifi_signal == -37
172184
assert device.has_error is False
@@ -215,6 +227,9 @@ async def test_2zone_cancool():
215227
assert device.target_tank_temperature is None
216228
assert device.target_tank_temperature_min == 40
217229
assert device.target_tank_temperature_max == 60
230+
assert device.flow_temperature_boiler == 25
231+
assert device.return_temperature_boiler == 25
232+
assert device.mixing_tank_temperature is None
218233
assert device.holiday_mode is None
219234
assert device.wifi_signal == -82
220235
assert device.has_error is False
@@ -263,6 +278,9 @@ async def test_2zone_cancool():
263278
assert device.status == STATUS_HEAT_WATER
264279
assert device.tank_temperature == 47.5
265280
assert device.target_tank_temperature == 52.0
281+
assert device.flow_temperature_boiler == 25
282+
assert device.return_temperature_boiler == 25
283+
assert device.mixing_tank_temperature is None
266284
assert device.holiday_mode is False
267285
assert device.wifi_signal == -82
268286
assert device.has_error is False

0 commit comments

Comments
 (0)