@@ -149,14 +149,6 @@ async def async_update(self) -> PlugwiseData:
149149### API Set and HA Service-related Functions ###
150150########################################################################################################
151151
152- async def call_request (self , uri : str , ** kwargs : Any ) -> None :
153- """ConnectionFailedError wrapper for calling _request()."""
154- method : str = kwargs ["method" ]
155- try :
156- await self ._request (uri , method = method )
157- except ConnectionFailedError as exc :
158- raise ConnectionFailedError from exc
159-
160152 async def delete_notification (self ) -> None :
161153 """Delete the active Plugwise Notification."""
162154 await self .call_request (NOTIFICATIONS , method = "delete" )
@@ -189,7 +181,7 @@ async def set_number(
189181
190182 uri = f"{ APPLIANCES } ;id={ self ._heater_id } /thermostat;id={ thermostat_id } "
191183 data = f"<thermostat_functionality><setpoint>{ temp } </setpoint></thermostat_functionality>"
192- await self ._request (uri , method = "put" , data = data )
184+ await self .call_request (uri , method = "put" , data = data )
193185
194186 async def set_offset (self , dev_id : str , offset : float ) -> None :
195187 """Set the Temperature offset for thermostats that support this feature."""
@@ -202,7 +194,7 @@ async def set_offset(self, dev_id: str, offset: float) -> None:
202194 uri = f"{ APPLIANCES } ;id={ dev_id } /offset;type=temperature_offset"
203195 data = f"<offset_functionality><offset>{ value } </offset></offset_functionality>"
204196
205- await self ._request (uri , method = "put" , data = data )
197+ await self .call_request (uri , method = "put" , data = data )
206198
207199 async def set_preset (self , loc_id : str , preset : str ) -> None :
208200 """Set the given Preset on the relevant Thermostat - from LOCATIONS."""
@@ -222,7 +214,7 @@ async def set_preset(self, loc_id: str, preset: str) -> None:
222214 f"</type><preset>{ preset } </preset></location></locations>"
223215 )
224216
225- await self ._request (uri , method = "put" , data = data )
217+ await self .call_request (uri , method = "put" , data = data )
226218
227219 async def set_select (self , key : str , loc_id : str , option : str , state : str | None ) -> None :
228220 """Set a dhw/gateway/regulation mode or the thermostat schedule option."""
@@ -245,7 +237,7 @@ async def set_dhw_mode(self, mode: str) -> None:
245237 uri = f"{ APPLIANCES } ;type=heater_central/domestic_hot_water_mode_control"
246238 data = f"<domestic_hot_water_mode_control_functionality><mode>{ mode } </mode></domestic_hot_water_mode_control_functionality>"
247239
248- await self ._request (uri , method = "put" , data = data )
240+ await self .call_request (uri , method = "put" , data = data )
249241
250242 async def set_gateway_mode (self , mode : str ) -> None :
251243 """Set the gateway mode."""
@@ -268,7 +260,7 @@ async def set_gateway_mode(self, mode: str) -> None:
268260 uri = f"{ APPLIANCES } ;id={ self .gateway_id } /gateway_mode_control"
269261 data = f"<gateway_mode_control_functionality><mode>{ mode } </mode>{ valid } </gateway_mode_control_functionality>"
270262
271- await self ._request (uri , method = "put" , data = data )
263+ await self .call_request (uri , method = "put" , data = data )
272264
273265 async def set_regulation_mode (self , mode : str ) -> None :
274266 """Set the heating regulation mode."""
@@ -281,7 +273,7 @@ async def set_regulation_mode(self, mode: str) -> None:
281273 duration = "<duration>300</duration>"
282274 data = f"<regulation_mode_control_functionality>{ duration } <mode>{ mode } </mode></regulation_mode_control_functionality>"
283275
284- await self ._request (uri , method = "put" , data = data )
276+ await self .call_request (uri , method = "put" , data = data )
285277
286278 async def set_schedule_state (
287279 self ,
@@ -335,7 +327,7 @@ async def set_schedule_state(
335327 f"{ template } { contexts } </rule></rules>"
336328 )
337329
338- await self ._request (uri , method = "put" , data = data )
330+ await self .call_request (uri , method = "put" , data = data )
339331 self ._schedule_old_states [loc_id ][name ] = new_state
340332
341333 def determine_contexts (
@@ -404,7 +396,7 @@ async def set_switch_state(
404396 if self ._domain_objects .find (locator ).text == "true" :
405397 raise PlugwiseError ("Plugwise: the locked Relay was not switched." )
406398
407- await self ._request (uri , method = "put" , data = data )
399+ await self .call_request (uri , method = "put" , data = data )
408400
409401 async def _set_groupswitch_member_state (
410402 self , members : list [str ], state : str , switch : Munch
@@ -419,7 +411,7 @@ async def _set_groupswitch_member_state(
419411 uri = f"{ APPLIANCES } ;id={ member } /{ switch .device } ;id={ switch_id } "
420412 data = f"<{ switch .func_type } ><{ switch .func } >{ state } </{ switch .func } ></{ switch .func_type } >"
421413
422- await self ._request (uri , method = "put" , data = data )
414+ await self .call_request (uri , method = "put" , data = data )
423415
424416 async def set_temperature (self , loc_id : str , items : dict [str , float ]) -> None :
425417 """Set the given Temperature on the relevant Thermostat."""
@@ -460,4 +452,13 @@ async def set_temperature(self, loc_id: str, items: dict[str, float]) -> None:
460452 f"{ temperature } </setpoint></thermostat_functionality>"
461453 )
462454
463- await self ._request (uri , method = "put" , data = data )
455+ await self .call_request (uri , method = "put" , data = data )
456+
457+ async def call_request (self , uri : str , ** kwargs : Any ) -> None :
458+ """ConnectionFailedError wrapper for calling _request()."""
459+ method : str = kwargs ["method" ]
460+ data : str | None = kwargs .get ("data" )
461+ try :
462+ await self ._request (uri , method = method , data = data )
463+ except ConnectionFailedError as exc :
464+ raise ConnectionFailedError from exc
0 commit comments