@@ -28,15 +28,14 @@ async def control_queue(self):
28
28
None
29
29
"""
30
30
while True :
31
+ if self .ignore_states :
32
+ await asyncio .sleep (1 )
33
+ continue
31
34
controls_to_process = await self .control_queue_task .get ()
32
35
if controls_to_process is not None :
33
- if self .ignore_states :
34
- await asyncio .sleep (1 )
35
- continue
36
- else :
37
- _LOGGER .debug (f"better_thermostat { self .name } : processing controls" )
38
- await control_trv (controls_to_process )
39
- self .control_queue_task .task_done ()
36
+ _LOGGER .debug (f"better_thermostat { self .name } : processing controls" )
37
+ await control_trv (controls_to_process )
38
+ self .control_queue_task .task_done ()
40
39
41
40
42
41
async def control_trv (self , force_mode_change : bool = False ):
@@ -114,10 +113,10 @@ async def control_trv(self, force_mode_change: bool = False):
114
113
calibration = remapped_states .get ("local_temperature_calibration" ) or None
115
114
116
115
if converted_hvac_mode is not None :
117
- _LOGGER .debug (
118
- f"better_thermostat { self .name } : control_trv: current TRV mode: { _current_TRV_mode } new TRV mode: { converted_hvac_mode } "
119
- )
120
116
if _current_TRV_mode != converted_hvac_mode or force_mode_change :
117
+ _LOGGER .debug (
118
+ f"better_thermostat { self .name } : control_trv: current TRV mode: { _current_TRV_mode } new TRV mode: { converted_hvac_mode } "
119
+ )
121
120
system_mode_change = True
122
121
await set_trv_values (self , "hvac_mode" , converted_hvac_mode )
123
122
if current_heating_setpoint is not None :
@@ -264,23 +263,37 @@ async def set_trv_values(self, key, value, hvac_mode=None):
264
263
)
265
264
elif key == "local_temperature_calibration" :
266
265
value = round_to_hundredth_degree (value )
267
-
268
- max_calibration = self .hass .states .get (
269
- self .local_temperature_calibration_entity
270
- ).attributes .get ("max" , 127 )
271
- min_calibration = self .hass .states .get (
266
+ current_calibration = self .hass .states .get (
272
267
self .local_temperature_calibration_entity
273
- ).attributes .get ("min" , - 128 )
274
- if value > max_calibration :
275
- value = max_calibration
276
- if value < min_calibration :
277
- value = min_calibration
278
- await self .hass .services .async_call (
279
- "number" ,
280
- SERVICE_SET_VALUE ,
281
- {"entity_id" : self .local_temperature_calibration_entity , "value" : value },
282
- blocking = True ,
283
- )
268
+ ).state
269
+ if current_calibration != value and (
270
+ (self ._last_calibration + timedelta (minutes = 5 )).timestamp ()
271
+ < datetime .now ().timestamp ()
272
+ ):
273
+ max_calibration = self .hass .states .get (
274
+ self .local_temperature_calibration_entity
275
+ ).attributes .get ("max" , 127 )
276
+ min_calibration = self .hass .states .get (
277
+ self .local_temperature_calibration_entity
278
+ ).attributes .get ("min" , - 128 )
279
+ if value > max_calibration :
280
+ value = max_calibration
281
+ if value < min_calibration :
282
+ value = min_calibration
283
+ await self .hass .services .async_call (
284
+ "number" ,
285
+ SERVICE_SET_VALUE ,
286
+ {
287
+ "entity_id" : self .local_temperature_calibration_entity ,
288
+ "value" : value ,
289
+ },
290
+ blocking = True ,
291
+ )
292
+ self ._last_calibration = datetime .now ()
293
+ else :
294
+ _LOGGER .debug (
295
+ f"better_thermostat { self .name } : set_trv_values: skipping local calibration because of throttling"
296
+ )
284
297
elif key == "valve_position" :
285
298
await self .hass .services .async_call (
286
299
"number" ,
0 commit comments