Skip to content

Commit aca4bfc

Browse files
authored
Merge pull request #486 from plugwise/pauze_3
Implement limited access to gateway modes for Adam
2 parents a937a7b + 7808055 commit aca4bfc

File tree

17 files changed

+107
-23
lines changed

17 files changed

+107
-23
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.36.0
44

5+
- New Feature: For Adam, implement limited access to the gateway-modes.
56
- Refresh adam_plus_anna_new userdata and adapt.
67
- Bump actions and requirements to Python 3.12.
78
- Ruff as per #470 (defaulting black and isort to ruff).

fixtures/adam_heatpump_cooling/all_data.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@
216216
},
217217
"dev_class": "gateway",
218218
"firmware": "3.2.8",
219+
"gateway_modes": ["away", "full", "vacation"],
219220
"hardware": "AME Smile 2.0 board",
220221
"location": "eedadcb297564f1483faa509179aebed",
221222
"mac_address": "012345670001",
@@ -228,6 +229,7 @@
228229
"bleeding_hot",
229230
"cooling"
230231
],
232+
"select_gateway_mode": "full",
231233
"select_regulation_mode": "cooling",
232234
"sensors": {
233235
"outdoor_temperature": 13.4
@@ -630,7 +632,7 @@
630632
"cooling_present": true,
631633
"gateway_id": "7d97fc3117784cfdafe347bcedcbbbcb",
632634
"heater_id": "0ca13e8176204ca7bf6f09de59f81c83",
633-
"item_count": 413,
635+
"item_count": 415,
634636
"notifications": {},
635637
"smile_name": "Adam"
636638
}

fixtures/adam_jip/all_data.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,14 @@
193193
},
194194
"dev_class": "gateway",
195195
"firmware": "3.2.8",
196+
"gateway_modes": ["away", "full", "vacation"],
196197
"hardware": "AME Smile 2.0 board",
197198
"location": "9e4433a9d69f40b3aefd15e74395eaec",
198199
"mac_address": "012345670001",
199200
"model": "Gateway",
200201
"name": "Adam",
201202
"regulation_modes": ["heating", "off", "bleeding_cold", "bleeding_hot"],
203+
"select_gateway_mode": "full",
202204
"select_regulation_mode": "heating",
203205
"sensors": {
204206
"outdoor_temperature": 24.9
@@ -304,7 +306,7 @@
304306
"cooling_present": false,
305307
"gateway_id": "b5c2386c6f6342669e50fe49dd05b188",
306308
"heater_id": "e4684553153b44afbef2200885f379dc",
307-
"item_count": 219,
309+
"item_count": 221,
308310
"notifications": {},
309311
"smile_name": "Adam"
310312
}

fixtures/adam_onoff_cooling_fake_firmware/all_data.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
},
4343
"dev_class": "gateway",
4444
"firmware": "3.2.8",
45+
"gateway_modes": ["away", "full", "vacation"],
4546
"hardware": "AME Smile 2.0 board",
4647
"location": "eedadcb297564f1483faa509179aebed",
4748
"mac_address": "012345670001",
@@ -54,6 +55,7 @@
5455
"bleeding_hot",
5556
"cooling"
5657
],
58+
"select_gateway_mode": "full",
5759
"select_regulation_mode": "cooling",
5860
"sensors": {
5961
"outdoor_temperature": 13.4
@@ -94,7 +96,7 @@
9496
"cooling_present": true,
9597
"gateway_id": "7d97fc3117784cfdafe347bcedcbbbcb",
9698
"heater_id": "0ca13e8176204ca7bf6f09de59f81c83",
97-
"item_count": 54,
99+
"item_count": 56,
98100
"notifications": {},
99101
"smile_name": "Adam"
100102
}

fixtures/adam_plus_anna_new/all_data.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,14 @@
159159
},
160160
"dev_class": "gateway",
161161
"firmware": "3.7.8",
162+
"gateway_modes": ["away", "full", "vacation"],
162163
"hardware": "AME Smile 2.0 board",
163164
"location": "bc93488efab249e5bc54fd7e175a6f91",
164165
"mac_address": "012345679891",
165166
"model": "Gateway",
166167
"name": "Adam",
167168
"regulation_modes": ["bleeding_hot", "bleeding_cold", "off", "heating"],
169+
"select_gateway_mode": "full",
168170
"select_regulation_mode": "heating",
169171
"sensors": {
170172
"outdoor_temperature": 9.19
@@ -229,7 +231,7 @@
229231
"cooling_present": false,
230232
"gateway_id": "da224107914542988a88561b4452b0f6",
231233
"heater_id": "056ee145a816487eaa69243c3280f8bf",
232-
"item_count": 145,
234+
"item_count": 147,
233235
"notifications": {},
234236
"smile_name": "Adam"
235237
}

fixtures/m_adam_cooling/all_data.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
},
8787
"dev_class": "gateway",
8888
"firmware": "3.7.8",
89+
"gateway_modes": ["away", "full", "vacation"],
8990
"hardware": "AME Smile 2.0 board",
9091
"location": "bc93488efab249e5bc54fd7e175a6f91",
9192
"mac_address": "012345679891",
@@ -98,6 +99,7 @@
9899
"heating",
99100
"cooling"
100101
],
102+
"select_gateway_mode": "full",
101103
"select_regulation_mode": "cooling",
102104
"sensors": {
103105
"outdoor_temperature": 29.65
@@ -162,7 +164,7 @@
162164
"cooling_present": true,
163165
"gateway_id": "da224107914542988a88561b4452b0f6",
164166
"heater_id": "056ee145a816487eaa69243c3280f8bf",
165-
"item_count": 145,
167+
"item_count": 147,
166168
"notifications": {},
167169
"smile_name": "Adam"
168170
}

fixtures/m_adam_heating/all_data.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,14 @@
114114
},
115115
"dev_class": "gateway",
116116
"firmware": "3.7.8",
117+
"gateway_modes": ["away", "full", "vacation"],
117118
"hardware": "AME Smile 2.0 board",
118119
"location": "bc93488efab249e5bc54fd7e175a6f91",
119120
"mac_address": "012345679891",
120121
"model": "Gateway",
121122
"name": "Adam",
122123
"regulation_modes": ["bleeding_hot", "bleeding_cold", "off", "heating"],
124+
"select_gateway_mode": "full",
123125
"select_regulation_mode": "heating",
124126
"sensors": {
125127
"outdoor_temperature": -1.25
@@ -184,7 +186,7 @@
184186
"cooling_present": false,
185187
"gateway_id": "da224107914542988a88561b4452b0f6",
186188
"heater_id": "056ee145a816487eaa69243c3280f8bf",
187-
"item_count": 145,
189+
"item_count": 147,
188190
"notifications": {},
189191
"smile_name": "Adam"
190192
}

fixtures/m_adam_jip/all_data.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,14 @@
193193
},
194194
"dev_class": "gateway",
195195
"firmware": "3.2.8",
196+
"gateway_modes": ["away", "full", "vacation"],
196197
"hardware": "AME Smile 2.0 board",
197198
"location": "9e4433a9d69f40b3aefd15e74395eaec",
198199
"mac_address": "012345670001",
199200
"model": "Gateway",
200201
"name": "Adam",
201202
"regulation_modes": ["heating", "off", "bleeding_cold", "bleeding_hot"],
203+
"select_gateway_mode": "full",
202204
"select_regulation_mode": "heating",
203205
"sensors": {
204206
"outdoor_temperature": 24.9
@@ -304,7 +306,7 @@
304306
"cooling_present": false,
305307
"gateway_id": "b5c2386c6f6342669e50fe49dd05b188",
306308
"heater_id": "e4684553153b44afbef2200885f379dc",
307-
"item_count": 219,
309+
"item_count": 221,
308310
"notifications": {},
309311
"smile_name": "Adam"
310312
}

plugwise/__init__.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,14 @@ def _device_data_adam(self, device: DeviceData, data: DeviceData) -> None:
198198
):
199199
data["binary_sensors"]["heating_state"] = self._heating_valves() != 0
200200

201-
# Show the allowed regulation modes for Adam
202-
if device["dev_class"] == "gateway" and self._reg_allowed_modes:
203-
data["regulation_modes"] = self._reg_allowed_modes
204-
self._count += 1
201+
# Show the allowed regulation modes and gateway_modes
202+
if device["dev_class"] == "gateway":
203+
if self._reg_allowed_modes:
204+
data["regulation_modes"] = self._reg_allowed_modes
205+
self._count += 1
206+
if self._gw_allowed_modes:
207+
data["gateway_modes"] = self._gw_allowed_modes
208+
self._count += 1
205209

206210
# Control_state, only for Adam master thermostats
207211
if device["dev_class"] in ZONE_THERMOSTATS:
@@ -862,6 +866,29 @@ async def set_switch_state(
862866

863867
await self._request(uri, method="put", data=data)
864868

869+
async def set_gateway_mode(self, mode: str) -> None:
870+
"""Set the gateway mode."""
871+
if mode not in self._gw_allowed_modes:
872+
raise PlugwiseError("Plugwise: invalid gateway mode.")
873+
874+
time_1 = dt.datetime.now(dt.UTC)
875+
away_time = time_1.isoformat(timespec="milliseconds") + "Z"
876+
time_2 = str(dt.date.today() - dt.timedelta(1))
877+
vacation_time = time_2 + "T23:00:00.000Z"
878+
end_time = "2037-04-21T08:00:53.000Z"
879+
valid = ""
880+
if mode == "away":
881+
valid = (
882+
f"<valid_from>{away_time}</valid_from><valid_to>{end_time}</valid_to>"
883+
)
884+
if mode == "vacation":
885+
valid = f"<valid_from>{vacation_time}</valid_from><valid_to>{end_time}</valid_to>"
886+
887+
uri = f"{APPLIANCES};type=gateway/gateway_mode_control"
888+
data = f"<gateway_mode_control_functionality><mode>{mode}</mode>{valid}</gateway_mode_control_functionality>"
889+
890+
await self._request(uri, method="put", data=data)
891+
865892
async def set_regulation_mode(self, mode: str) -> None:
866893
"""Set the heating regulation mode."""
867894
if mode not in self._reg_allowed_modes:

plugwise/constants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,10 @@ class DeviceData(TypedDict, total=False):
519519
dhw_modes: list[str]
520520

521521
# Gateway
522-
select_regulation_mode: str
522+
gateway_modes: list[str]
523523
regulation_modes: list[str]
524+
select_gateway_mode: str
525+
select_regulation_mode: str
524526

525527
# Master Thermostats
526528
# Presets:

0 commit comments

Comments
 (0)