Skip to content

Commit 2a03ddd

Browse files
authored
Merge pull request #443 from plugwise/return_control_state
Adam: return the control_state for each thermostat/location.
2 parents aabaebb + 3c72513 commit 2a03ddd

File tree

11 files changed

+68
-12
lines changed

11 files changed

+68
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Changelog
22

3-
## Ongoing
3+
## v0.34.5
44

5+
- Adam: return the control_state for each thermostat/location.
56
- Bugfix: correct removal of obsolete `outdoor_air_temperature` sensor.
67

78
## v0.34.4

fixtures/adam_heatpump_cooling/all_data.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"active_preset": "away",
4343
"available": true,
4444
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
45+
"control_state": "off",
4546
"dev_class": "zone_thermostat",
4647
"firmware": "2016-10-10T02:00:00+02:00",
4748
"hardware": "255",
@@ -151,6 +152,7 @@
151152
"active_preset": "away",
152153
"available": true,
153154
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
155+
"control_state": "off",
154156
"dev_class": "zone_thermostat",
155157
"firmware": "2016-10-10T02:00:00+02:00",
156158
"hardware": "255",
@@ -227,6 +229,7 @@
227229
"active_preset": "away",
228230
"available": true,
229231
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
232+
"control_state": "off",
230233
"dev_class": "zone_thermostat",
231234
"firmware": "2016-10-10T02:00:00+02:00",
232235
"hardware": "255",
@@ -354,6 +357,7 @@
354357
"active_preset": "away",
355358
"available": true,
356359
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
360+
"control_state": "off",
357361
"dev_class": "zone_thermostat",
358362
"firmware": "2016-10-10T02:00:00+02:00",
359363
"hardware": "255",
@@ -386,6 +390,7 @@
386390
"active_preset": "away",
387391
"available": true,
388392
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
393+
"control_state": "off",
389394
"dev_class": "zone_thermostat",
390395
"firmware": "2016-10-10T02:00:00+02:00",
391396
"hardware": "255",
@@ -417,6 +422,7 @@
417422
"ca79d23ae0094120b877558734cff85c": {
418423
"active_preset": "away",
419424
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
425+
"control_state": "off",
420426
"dev_class": "thermostat",
421427
"location": "fa5fa6b34f6b40a0972988b20e888ed4",
422428
"mode": "auto",
@@ -440,6 +446,7 @@
440446
"active_preset": "away",
441447
"available": true,
442448
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
449+
"control_state": "off",
443450
"dev_class": "zone_thermostat",
444451
"firmware": "2016-10-10T02:00:00+02:00",
445452
"hardware": "255",
@@ -472,6 +479,7 @@
472479
"active_preset": "away",
473480
"available": true,
474481
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
482+
"control_state": "off",
475483
"dev_class": "zone_thermostat",
476484
"firmware": "2016-10-10T02:00:00+02:00",
477485
"hardware": "255",
@@ -505,6 +513,7 @@
505513
"active_preset": "away",
506514
"available": true,
507515
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
516+
"control_state": "off",
508517
"dev_class": "zone_thermostat",
509518
"firmware": "2016-10-10T02:00:00+02:00",
510519
"hardware": "255",
@@ -537,6 +546,7 @@
537546
"active_preset": "away",
538547
"available": true,
539548
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
549+
"control_state": "off",
540550
"dev_class": "zone_thermostat",
541551
"firmware": "2016-10-10T02:00:00+02:00",
542552
"hardware": "255",
@@ -570,7 +580,7 @@
570580
"cooling_present": true,
571581
"gateway_id": "7d97fc3117784cfdafe347bcedcbbbcb",
572582
"heater_id": "0ca13e8176204ca7bf6f09de59f81c83",
573-
"item_count": 403,
583+
"item_count": 413,
574584
"notifications": {},
575585
"smile_name": "Adam"
576586
}

fixtures/adam_jip/all_data.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"active_preset": "no_frost",
55
"available": true,
66
"available_schedules": ["None"],
7+
"control_state": "off",
78
"dev_class": "zone_thermostat",
89
"firmware": "2016-10-27T02:00:00+02:00",
910
"hardware": "255",
@@ -99,6 +100,7 @@
99100
"active_preset": "home",
100101
"available": true,
101102
"available_schedules": ["None"],
103+
"control_state": "off",
102104
"dev_class": "zone_thermostat",
103105
"firmware": "2016-10-27T02:00:00+02:00",
104106
"hardware": "255",
@@ -155,6 +157,7 @@
155157
"active_preset": "home",
156158
"available": true,
157159
"available_schedules": ["None"],
160+
"control_state": "off",
158161
"dev_class": "zone_thermostat",
159162
"firmware": "2016-10-27T02:00:00+02:00",
160163
"hardware": "255",
@@ -265,6 +268,7 @@
265268
"active_preset": "home",
266269
"available": true,
267270
"available_schedules": ["None"],
271+
"control_state": "off",
268272
"dev_class": "zone_thermometer",
269273
"firmware": "2020-09-01T02:00:00+02:00",
270274
"hardware": "1",
@@ -300,7 +304,7 @@
300304
"cooling_present": false,
301305
"gateway_id": "b5c2386c6f6342669e50fe49dd05b188",
302306
"heater_id": "e4684553153b44afbef2200885f379dc",
303-
"item_count": 215,
307+
"item_count": 219,
304308
"notifications": {},
305309
"smile_name": "Adam"
306310
}

fixtures/adam_onoff_cooling_fake_firmware/all_data.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"ca79d23ae0094120b877558734cff85c": {
6565
"active_preset": "away",
6666
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
67+
"control_state": "off",
6768
"dev_class": "thermostat",
6869
"location": "fa5fa6b34f6b40a0972988b20e888ed4",
6970
"mode": "auto",
@@ -88,7 +89,7 @@
8889
"cooling_present": true,
8990
"gateway_id": "7d97fc3117784cfdafe347bcedcbbbcb",
9091
"heater_id": "0ca13e8176204ca7bf6f09de59f81c83",
91-
"item_count": 53,
92+
"item_count": 54,
9293
"notifications": {},
9394
"smile_name": "Adam"
9495
}

fixtures/adam_plus_anna_new/all_data.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
"ad4838d7d35c4d6ea796ee12ae5aedf8": {
128128
"active_preset": "asleep",
129129
"available_schedules": ["Weekschema", "Badkamer", "Test"],
130+
"control_state": "heating",
130131
"dev_class": "thermostat",
131132
"location": "f2bf9048bef64cc5b6d5110154e33c81",
132133
"mode": "auto",
@@ -169,6 +170,7 @@
169170
"active_preset": "home",
170171
"available": true,
171172
"available_schedules": ["Weekschema", "Badkamer", "Test"],
173+
"control_state": "off",
172174
"dev_class": "zone_thermostat",
173175
"firmware": "2016-10-10T02:00:00+02:00",
174176
"hardware": "255",
@@ -215,7 +217,7 @@
215217
"cooling_present": false,
216218
"gateway_id": "da224107914542988a88561b4452b0f6",
217219
"heater_id": "056ee145a816487eaa69243c3280f8bf",
218-
"item_count": 143,
220+
"item_count": 145,
219221
"notifications": {},
220222
"smile_name": "Adam"
221223
}

fixtures/m_adam_cooling/all_data.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
"active_preset": "home",
104104
"available": true,
105105
"available_schedules": ["Weekschema", "Badkamer", "Test"],
106+
"control_state": "off",
106107
"dev_class": "zone_thermostat",
107108
"firmware": "2016-10-10T02:00:00+02:00",
108109
"hardware": "255",
@@ -149,7 +150,7 @@
149150
"cooling_present": true,
150151
"gateway_id": "da224107914542988a88561b4452b0f6",
151152
"heater_id": "056ee145a816487eaa69243c3280f8bf",
152-
"item_count": 143,
153+
"item_count": 145,
153154
"notifications": {},
154155
"smile_name": "Adam"
155156
}

fixtures/m_adam_heating/all_data.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
"active_preset": "home",
126126
"available": true,
127127
"available_schedules": ["Weekschema", "Badkamer", "Test"],
128+
"control_state": "off",
128129
"dev_class": "zone_thermostat",
129130
"firmware": "2016-10-10T02:00:00+02:00",
130131
"hardware": "255",
@@ -171,7 +172,7 @@
171172
"cooling_present": false,
172173
"gateway_id": "da224107914542988a88561b4452b0f6",
173174
"heater_id": "056ee145a816487eaa69243c3280f8bf",
174-
"item_count": 143,
175+
"item_count": 145,
175176
"notifications": {},
176177
"smile_name": "Adam"
177178
}

plugwise/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ def _device_data_climate(
231231
device_data["select_schedule"] = sel_schedule
232232
self._count += 2
233233

234+
# Control_state, only for Adam master thermostats
235+
if ctrl_state := self._control_state(loc_id):
236+
device_data["control_state"] = ctrl_state
237+
self._count += 1
238+
234239
# Operation modes: auto, heat, heat_cool, cool and off
235240
device_data["mode"] = "auto"
236241
self._count += 1

plugwise/helper.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,21 @@ def _match_locations(self) -> dict[str, ThermoLoc]:
669669

670670
return matched_locations
671671

672+
def _control_state(self, loc_id: str) -> str | bool:
673+
"""Helper-function for _device_data_adam().
674+
675+
Adam: find the thermostat control_state of a location, from DOMAIN_OBJECTS.
676+
Represents the heating/cooling demand-state of the local master thermostat.
677+
Note: heating or cooling can still be active when the setpoint has been reached.
678+
"""
679+
locator = f'location[@id="{loc_id}"]'
680+
if (location := self._domain_objects.find(locator)) is not None:
681+
locator = './actuator_functionalities/thermostat_functionality[type="thermostat"]/control_state'
682+
if (ctrl_state := location.find(locator)) is not None:
683+
return str(ctrl_state.text)
684+
685+
return False
686+
672687
def _presets_legacy(self) -> dict[str, list[float]]:
673688
"""Helper-function for presets() - collect Presets for a legacy Anna."""
674689
presets: dict[str, list[float]] = {}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "plugwise"
7-
version = "0.34.4"
7+
version = "0.34.5"
88
license = {file = "LICENSE"}
99
description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3."
1010
readme = "README.md"

0 commit comments

Comments
 (0)