@@ -174,13 +174,13 @@ async def set_number(
174174 if thermostat_id is None :
175175 raise PlugwiseError (f"Plugwise: cannot change setpoint, { key } not found." )
176176
177- data = f"""
178- <thermostat_functionality>
179- <setpoint>{ temp } </setpoint>
180- </thermostat_functionality>
181- """
177+ data = (
178+ " <thermostat_functionality>"
179+ f" <setpoint>{ temp } </setpoint>"
180+ " </thermostat_functionality>"
181+ )
182182 uri = f"{ APPLIANCES } ;id={ self ._heater_id } /thermostat;id={ thermostat_id } "
183- await self .call_request (uri , method = "put" , data = data . strip () )
183+ await self .call_request (uri , method = "put" , data = data )
184184
185185 async def set_offset (self , dev_id : str , offset : float ) -> None :
186186 """Set the Temperature offset for thermostats that support this feature."""
@@ -190,13 +190,13 @@ async def set_offset(self, dev_id: str, offset: float) -> None:
190190 )
191191
192192 value = str (offset )
193- data = f"""
194- <offset_functionality>
195- <offset>{ value } </offset>
196- </offset_functionality>
197- """
193+ data = (
194+ " <offset_functionality>"
195+ f" <offset>{ value } </offset>"
196+ " </offset_functionality>"
197+ )
198198 uri = f"{ APPLIANCES } ;id={ dev_id } /offset;type=temperature_offset"
199- await self .call_request (uri , method = "put" , data = data . strip () )
199+ await self .call_request (uri , method = "put" , data = data )
200200
201201 async def set_preset (self , loc_id : str , preset : str ) -> None :
202202 """Set the given Preset on the relevant Thermostat - from LOCATIONS."""
@@ -208,17 +208,17 @@ async def set_preset(self, loc_id: str, preset: str) -> None:
208208 current_location = self ._domain_objects .find (f'location[@id="{ loc_id } "]' )
209209 location_name = current_location .find ("name" ).text
210210 location_type = current_location .find ("type" ).text
211- data = f'''
212- <locations>
213- <location id=" { loc_id } ">
214- <name>{ location_name } </name>
215- <type>{ location_type } </type>
216- <preset>{ preset } </preset>
217- </location>
218- </locations>
219- '''
211+ data = (
212+ " <locations>"
213+ f" <location id=' { loc_id } ''>"
214+ f" <name>{ location_name } </name>"
215+ f" <type>{ location_type } </type>"
216+ f" <preset>{ preset } </preset>"
217+ " </location>"
218+ " </locations>"
219+ )
220220 uri = f"{ LOCATIONS } ;id={ loc_id } "
221- await self .call_request (uri , method = "put" , data = data . strip () )
221+ await self .call_request (uri , method = "put" , data = data )
222222
223223 async def set_select (
224224 self , key : str , loc_id : str , option : str , state : str | None
@@ -240,13 +240,13 @@ async def set_dhw_mode(self, mode: str) -> None:
240240 if mode not in self ._dhw_allowed_modes :
241241 raise PlugwiseError ("Plugwise: invalid dhw mode." )
242242
243- data = f"""
244- <domestic_hot_water_mode_control_functionality>
245- <mode>{ mode } </mode>
246- </domestic_hot_water_mode_control_functionality>
247- """
243+ data = (
244+ " <domestic_hot_water_mode_control_functionality>"
245+ f" <mode>{ mode } </mode>"
246+ " </domestic_hot_water_mode_control_functionality>"
247+ )
248248 uri = f"{ APPLIANCES } ;type=heater_central/domestic_hot_water_mode_control"
249- await self .call_request (uri , method = "put" , data = data . strip () )
249+ await self .call_request (uri , method = "put" , data = data )
250250
251251 async def set_gateway_mode (self , mode : str ) -> None :
252252 """Set the gateway mode."""
@@ -271,14 +271,14 @@ async def set_gateway_mode(self, mode: str) -> None:
271271 vacation_time = time_2 + "T23:00:00.000Z"
272272 valid = f"<valid_from>{ vacation_time } </valid_from><valid_to>{ end_time } </valid_to>"
273273
274- data = f"""
275- <gateway_mode_control_functionality>
276- <mode>{ mode } </mode>
277- { valid }
278- </gateway_mode_control_functionality>
279- """
274+ data = (
275+ " <gateway_mode_control_functionality>"
276+ f" <mode>{ mode } </mode>"
277+ f" { valid } "
278+ " </gateway_mode_control_functionality>"
279+ )
280280 uri = f"{ APPLIANCES } ;id={ self ._smile_props ['gateway_id' ]} /gateway_mode_control"
281- await self .call_request (uri , method = "put" , data = data . strip () )
281+ await self .call_request (uri , method = "put" , data = data )
282282
283283 async def set_regulation_mode (self , mode : str ) -> None :
284284 """Set the heating regulation mode."""
@@ -289,14 +289,14 @@ async def set_regulation_mode(self, mode: str) -> None:
289289 if "bleeding" in mode :
290290 duration = "<duration>300</duration>"
291291
292- data = f"""
293- <regulation_mode_control_functionality>
294- { duration }
295- <mode>{ mode } </mode>
296- </regulation_mode_control_functionality>
297- """
292+ data = (
293+ " <regulation_mode_control_functionality>"
294+ f" { duration } "
295+ f" <mode>{ mode } </mode>"
296+ " </regulation_mode_control_functionality>"
297+ )
298298 uri = f"{ APPLIANCES } ;type=gateway/regulation_mode_control"
299- await self .call_request (uri , method = "put" , data = data . strip () )
299+ await self .call_request (uri , method = "put" , data = data )
300300
301301 async def set_schedule_state (
302302 self ,
@@ -344,17 +344,17 @@ async def set_schedule_state(
344344 template = f'<template id="{ template_id } " />'
345345
346346 contexts = self .determine_contexts (loc_id , name , new_state , schedule_rule_id )
347- data = f'''
348- <rules>
349- <rule id=" { schedule_rule_id } ">
350- <name><![CDATA[{ name } ]]></name>
351- { template }
352- { contexts }
353- </rule>
354- </rules>
355- '''
347+ data = (
348+ " <rules>"
349+ f" <rule id=' { schedule_rule_id } '>"
350+ f" <name><![CDATA[{ name } ]]></name>"
351+ f" { template } "
352+ f" { contexts } "
353+ " </rule>"
354+ " </rules>"
355+ )
356356 uri = f"{ RULES } ;id={ schedule_rule_id } "
357- await self .call_request (uri , method = "put" , data = data . strip () )
357+ await self .call_request (uri , method = "put" , data = data )
358358 self ._schedule_old_states [loc_id ][name ] = new_state
359359
360360 def determine_contexts (
@@ -412,11 +412,11 @@ async def set_switch_state(
412412 switch_id = item .attrib ["id" ]
413413 break
414414
415- data = f"""
416- <{ switch .func_type } >
417- <{ switch .func } >{ state } </{ switch .func } >
418- </{ switch .func_type } >
419- """
415+ data = (
416+ f" <{ switch .func_type } >"
417+ f" <{ switch .func } >{ state } </{ switch .func } >"
418+ f" </{ switch .func_type } >"
419+ )
420420 uri = f"{ APPLIANCES } ;id={ appl_id } /{ switch .device } ;id={ switch_id } "
421421 if model == "relay" :
422422 locator = (
@@ -426,7 +426,7 @@ async def set_switch_state(
426426 if self ._domain_objects .find (locator ).text == "true" :
427427 raise PlugwiseError ("Plugwise: the locked Relay was not switched." )
428428
429- await self .call_request (uri , method = "put" , data = data . strip () )
429+ await self .call_request (uri , method = "put" , data = data )
430430
431431 async def _set_groupswitch_member_state (
432432 self , members : list [str ], state : str , switch : Munch
@@ -439,12 +439,12 @@ async def _set_groupswitch_member_state(
439439 locator = f'appliance[@id="{ member } "]/{ switch .actuator } /{ switch .func_type } '
440440 switch_id = self ._domain_objects .find (locator ).attrib ["id" ]
441441 uri = f"{ APPLIANCES } ;id={ member } /{ switch .device } ;id={ switch_id } "
442- data = f"""
443- <{ switch .func_type } >
444- <{ switch .func } >{ state } </{ switch .func } >
445- </{ switch .func_type } >
446- """
447- await self .call_request (uri , method = "put" , data = data . strip () )
442+ data = (
443+ f" <{ switch .func_type } >"
444+ f" <{ switch .func } >{ state } </{ switch .func } >"
445+ f" </{ switch .func_type } >"
446+ )
447+ await self .call_request (uri , method = "put" , data = data )
448448
449449 async def set_temperature (self , loc_id : str , items : dict [str , float ]) -> None :
450450 """Set the given Temperature on the relevant Thermostat."""
@@ -479,13 +479,13 @@ async def set_temperature(self, loc_id: str, items: dict[str, float]) -> None:
479479 ) # pragma: no cover"
480480
481481 temperature = str (setpoint )
482- data = f"""
483- <thermostat_functionality>
484- <setpoint>{ temperature } </setpoint>
485- </thermostat_functionality>
486- """
482+ data = (
483+ " <thermostat_functionality>"
484+ f" <setpoint>{ temperature } </setpoint>"
485+ " </thermostat_functionality>"
486+ )
487487 uri = self ._thermostat_uri (loc_id )
488- await self .call_request (uri , method = "put" , data = data . strip () )
488+ await self .call_request (uri , method = "put" , data = data )
489489
490490 async def call_request (self , uri : str , ** kwargs : Any ) -> None :
491491 """ConnectionFailedError wrapper for calling request()."""
0 commit comments