@@ -149,39 +149,6 @@ async def delete_notification(self) -> None:
149149 """Delete the active Plugwise Notification."""
150150 await self ._request (NOTIFICATIONS , method = "delete" )
151151
152- async def set_dhw_mode (self , mode : str ) -> None :
153- """Set the domestic hot water heating regulation mode."""
154- if mode not in self ._dhw_allowed_modes :
155- raise PlugwiseError ("Plugwise: invalid dhw mode." )
156-
157- uri = f"{ APPLIANCES } ;type=heater_central/domestic_hot_water_mode_control"
158- data = f"<domestic_hot_water_mode_control_functionality><mode>{ mode } </mode></domestic_hot_water_mode_control_functionality>"
159-
160- await self ._request (uri , method = "put" , data = data )
161-
162- async def set_gateway_mode (self , mode : str ) -> None :
163- """Set the gateway mode."""
164- if mode not in self ._gw_allowed_modes :
165- raise PlugwiseError ("Plugwise: invalid gateway mode." )
166-
167- end_time = "2037-04-21T08:00:53.000Z"
168- valid = ""
169- if mode == "away" :
170- time_1 = self ._domain_objects .find ("./gateway/time" ).text
171- away_time = dt .datetime .fromisoformat (time_1 ).astimezone (dt .UTC ).isoformat (timespec = "milliseconds" ).replace ("+00:00" , "Z" )
172- valid = (
173- f"<valid_from>{ away_time } </valid_from><valid_to>{ end_time } </valid_to>"
174- )
175- if mode == "vacation" :
176- time_2 = str (dt .date .today () - dt .timedelta (1 ))
177- vacation_time = time_2 + "T23:00:00.000Z"
178- valid = f"<valid_from>{ vacation_time } </valid_from><valid_to>{ end_time } </valid_to>"
179-
180- uri = f"{ APPLIANCES } ;id={ self .gateway_id } /gateway_mode_control"
181- data = f"<gateway_mode_control_functionality><mode>{ mode } </mode>{ valid } </gateway_mode_control_functionality>"
182-
183- await self ._request (uri , method = "put" , data = data )
184-
185152 async def set_number (
186153 self ,
187154 dev_id : str ,
@@ -241,6 +208,53 @@ async def set_preset(self, loc_id: str, preset: str) -> None:
241208
242209 await self ._request (uri , method = "put" , data = data )
243210
211+ async def set_select (self , key : str , loc_id : str , option : str , name : str | None ) -> None :
212+ """Set a dhw/gateway/regulation mode or the thermostat schedule option."""
213+ match key :
214+ case "select_dhw_mode" :
215+ await self .set_dhw_mode (option )
216+ case "select_gateway_mode" :
217+ await self .set_gateway_mode (option )
218+ case "select_regulation_mode" :
219+ await self .set_regulation_mode (option )
220+ case "select_schedule" :
221+ # schedule state corresponds to select option
222+ # schedule name corresponds to select name
223+ await self .set_schedule_state (loc_id , option , name )
224+
225+ async def set_dhw_mode (self , mode : str ) -> None :
226+ """Set the domestic hot water heating regulation mode."""
227+ if mode not in self ._dhw_allowed_modes :
228+ raise PlugwiseError ("Plugwise: invalid dhw mode." )
229+
230+ uri = f"{ APPLIANCES } ;type=heater_central/domestic_hot_water_mode_control"
231+ data = f"<domestic_hot_water_mode_control_functionality><mode>{ mode } </mode></domestic_hot_water_mode_control_functionality>"
232+
233+ await self ._request (uri , method = "put" , data = data )
234+
235+ async def set_gateway_mode (self , mode : str ) -> None :
236+ """Set the gateway mode."""
237+ if mode not in self ._gw_allowed_modes :
238+ raise PlugwiseError ("Plugwise: invalid gateway mode." )
239+
240+ end_time = "2037-04-21T08:00:53.000Z"
241+ valid = ""
242+ if mode == "away" :
243+ time_1 = self ._domain_objects .find ("./gateway/time" ).text
244+ away_time = dt .datetime .fromisoformat (time_1 ).astimezone (dt .UTC ).isoformat (timespec = "milliseconds" ).replace ("+00:00" , "Z" )
245+ valid = (
246+ f"<valid_from>{ away_time } </valid_from><valid_to>{ end_time } </valid_to>"
247+ )
248+ if mode == "vacation" :
249+ time_2 = str (dt .date .today () - dt .timedelta (1 ))
250+ vacation_time = time_2 + "T23:00:00.000Z"
251+ valid = f"<valid_from>{ vacation_time } </valid_from><valid_to>{ end_time } </valid_to>"
252+
253+ uri = f"{ APPLIANCES } ;id={ self .gateway_id } /gateway_mode_control"
254+ data = f"<gateway_mode_control_functionality><mode>{ mode } </mode>{ valid } </gateway_mode_control_functionality>"
255+
256+ await self ._request (uri , method = "put" , data = data )
257+
244258 async def set_regulation_mode (self , mode : str ) -> None :
245259 """Set the heating regulation mode."""
246260 if mode not in self ._reg_allowed_modes :
@@ -258,7 +272,7 @@ async def set_schedule_state(
258272 self ,
259273 loc_id : str ,
260274 new_state : str ,
261- name : str | None = None ,
275+ name : str | None ,
262276 ) -> None :
263277 """Activate/deactivate the Schedule, with the given name, on the relevant Thermostat.
264278
0 commit comments