Skip to content

Commit

Permalink
Merge pull request #443 from plugwise/return_control_state
Browse files Browse the repository at this point in the history
Adam: return the control_state for each thermostat/location.
  • Loading branch information
bouwew authored Nov 4, 2023
2 parents aabaebb + 3c72513 commit 2a03ddd
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog

## Ongoing
## v0.34.5

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

## v0.34.4
Expand Down
12 changes: 11 additions & 1 deletion fixtures/adam_heatpump_cooling/all_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"active_preset": "away",
"available": true,
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -151,6 +152,7 @@
"active_preset": "away",
"available": true,
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -227,6 +229,7 @@
"active_preset": "away",
"available": true,
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -354,6 +357,7 @@
"active_preset": "away",
"available": true,
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -386,6 +390,7 @@
"active_preset": "away",
"available": true,
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -417,6 +422,7 @@
"ca79d23ae0094120b877558734cff85c": {
"active_preset": "away",
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
"control_state": "off",
"dev_class": "thermostat",
"location": "fa5fa6b34f6b40a0972988b20e888ed4",
"mode": "auto",
Expand All @@ -440,6 +446,7 @@
"active_preset": "away",
"available": true,
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -472,6 +479,7 @@
"active_preset": "away",
"available": true,
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -505,6 +513,7 @@
"active_preset": "away",
"available": true,
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -537,6 +546,7 @@
"active_preset": "away",
"available": true,
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -570,7 +580,7 @@
"cooling_present": true,
"gateway_id": "7d97fc3117784cfdafe347bcedcbbbcb",
"heater_id": "0ca13e8176204ca7bf6f09de59f81c83",
"item_count": 403,
"item_count": 413,
"notifications": {},
"smile_name": "Adam"
}
Expand Down
6 changes: 5 additions & 1 deletion fixtures/adam_jip/all_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"active_preset": "no_frost",
"available": true,
"available_schedules": ["None"],
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -99,6 +100,7 @@
"active_preset": "home",
"available": true,
"available_schedules": ["None"],
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -155,6 +157,7 @@
"active_preset": "home",
"available": true,
"available_schedules": ["None"],
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -265,6 +268,7 @@
"active_preset": "home",
"available": true,
"available_schedules": ["None"],
"control_state": "off",
"dev_class": "zone_thermometer",
"firmware": "2020-09-01T02:00:00+02:00",
"hardware": "1",
Expand Down Expand Up @@ -300,7 +304,7 @@
"cooling_present": false,
"gateway_id": "b5c2386c6f6342669e50fe49dd05b188",
"heater_id": "e4684553153b44afbef2200885f379dc",
"item_count": 215,
"item_count": 219,
"notifications": {},
"smile_name": "Adam"
}
Expand Down
3 changes: 2 additions & 1 deletion fixtures/adam_onoff_cooling_fake_firmware/all_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"ca79d23ae0094120b877558734cff85c": {
"active_preset": "away",
"available_schedules": ["Opstaan weekdag", "Werkdag schema", "Weekend"],
"control_state": "off",
"dev_class": "thermostat",
"location": "fa5fa6b34f6b40a0972988b20e888ed4",
"mode": "auto",
Expand All @@ -88,7 +89,7 @@
"cooling_present": true,
"gateway_id": "7d97fc3117784cfdafe347bcedcbbbcb",
"heater_id": "0ca13e8176204ca7bf6f09de59f81c83",
"item_count": 53,
"item_count": 54,
"notifications": {},
"smile_name": "Adam"
}
Expand Down
4 changes: 3 additions & 1 deletion fixtures/adam_plus_anna_new/all_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"ad4838d7d35c4d6ea796ee12ae5aedf8": {
"active_preset": "asleep",
"available_schedules": ["Weekschema", "Badkamer", "Test"],
"control_state": "heating",
"dev_class": "thermostat",
"location": "f2bf9048bef64cc5b6d5110154e33c81",
"mode": "auto",
Expand Down Expand Up @@ -169,6 +170,7 @@
"active_preset": "home",
"available": true,
"available_schedules": ["Weekschema", "Badkamer", "Test"],
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -215,7 +217,7 @@
"cooling_present": false,
"gateway_id": "da224107914542988a88561b4452b0f6",
"heater_id": "056ee145a816487eaa69243c3280f8bf",
"item_count": 143,
"item_count": 145,
"notifications": {},
"smile_name": "Adam"
}
Expand Down
3 changes: 2 additions & 1 deletion fixtures/m_adam_cooling/all_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"active_preset": "home",
"available": true,
"available_schedules": ["Weekschema", "Badkamer", "Test"],
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -149,7 +150,7 @@
"cooling_present": true,
"gateway_id": "da224107914542988a88561b4452b0f6",
"heater_id": "056ee145a816487eaa69243c3280f8bf",
"item_count": 143,
"item_count": 145,
"notifications": {},
"smile_name": "Adam"
}
Expand Down
3 changes: 2 additions & 1 deletion fixtures/m_adam_heating/all_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"active_preset": "home",
"available": true,
"available_schedules": ["Weekschema", "Badkamer", "Test"],
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -171,7 +172,7 @@
"cooling_present": false,
"gateway_id": "da224107914542988a88561b4452b0f6",
"heater_id": "056ee145a816487eaa69243c3280f8bf",
"item_count": 143,
"item_count": 145,
"notifications": {},
"smile_name": "Adam"
}
Expand Down
5 changes: 5 additions & 0 deletions plugwise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ def _device_data_climate(
device_data["select_schedule"] = sel_schedule
self._count += 2

# Control_state, only for Adam master thermostats
if ctrl_state := self._control_state(loc_id):
device_data["control_state"] = ctrl_state
self._count += 1

# Operation modes: auto, heat, heat_cool, cool and off
device_data["mode"] = "auto"
self._count += 1
Expand Down
15 changes: 15 additions & 0 deletions plugwise/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,21 @@ def _match_locations(self) -> dict[str, ThermoLoc]:

return matched_locations

def _control_state(self, loc_id: str) -> str | bool:
"""Helper-function for _device_data_adam().
Adam: find the thermostat control_state of a location, from DOMAIN_OBJECTS.
Represents the heating/cooling demand-state of the local master thermostat.
Note: heating or cooling can still be active when the setpoint has been reached.
"""
locator = f'location[@id="{loc_id}"]'
if (location := self._domain_objects.find(locator)) is not None:
locator = './actuator_functionalities/thermostat_functionality[type="thermostat"]/control_state'
if (ctrl_state := location.find(locator)) is not None:
return str(ctrl_state.text)

return False

def _presets_legacy(self) -> dict[str, list[float]]:
"""Helper-function for presets() - collect Presets for a legacy Anna."""
presets: dict[str, list[float]] = {}
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 = "0.34.4"
version = "0.34.5"
license = {file = "LICENSE"}
description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3."
readme = "README.md"
Expand Down
Loading

0 comments on commit 2a03ddd

Please sign in to comment.