ESPHome  2021.11.3
thermostat_climate.cpp
Go to the documentation of this file.
1 #include "thermostat_climate.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace thermostat {
6 
7 static const char *const TAG = "thermostat.climate";
8 
10  if (this->use_startup_delay_) {
11  // start timers so that no actions are called for a moment
17  }
18  // add a callback so that whenever the sensor state changes we can take action
19  this->sensor_->add_on_state_callback([this](float state) {
20  this->current_temperature = state;
21  // required action may have changed, recompute, refresh, we'll publish_state() later
22  this->switch_to_action_(this->compute_action_(), false);
24  // current temperature and possibly action changed, so publish the new state
25  this->publish_state();
26  });
27  this->current_temperature = this->sensor_->state;
28  // restore all climate data, if possible
29  auto restore = this->restore_state_();
30  if (restore.has_value()) {
31  restore->to_call(this).perform();
32  } else {
33  // restore from defaults, change_away handles temps for us
34  this->mode = this->default_mode_;
35  this->change_away_(false);
36  }
37  // refresh the climate action based on the restored settings, we'll publish_state() later
38  this->switch_to_action_(this->compute_action_(), false);
40  this->setup_complete_ = true;
41  this->publish_state();
42 }
43 
48 
50  this->switch_to_mode_(this->mode, false);
51  this->switch_to_action_(this->compute_action_(), false);
53  this->switch_to_fan_mode_(this->fan_mode.value(), false);
54  this->switch_to_swing_mode_(this->swing_mode, false);
56  this->publish_state();
57 }
58 
60  bool state_mismatch = this->action != this->compute_action_(true);
61 
62  switch (this->compute_action_(true)) {
65  return state_mismatch && (!this->idle_action_ready_());
67  return state_mismatch && (!this->cooling_action_ready_());
69  return state_mismatch && (!this->heating_action_ready_());
71  return state_mismatch && (!this->fanning_action_ready_());
73  return state_mismatch && (!this->drying_action_ready_());
74  default:
75  break;
76  }
77  return false;
78 }
79 
81  bool state_mismatch = this->fan_mode.value_or(climate::CLIMATE_FAN_ON) != this->prev_fan_mode_;
82  return state_mismatch && (!this->fan_mode_ready_());
83 }
84 
86 
88 
90  if ((this->supports_cool_ || (this->supports_fan_only_ && this->supports_fan_only_cooling_)) &&
91  (std::isnan(this->cooling_deadband_) || std::isnan(this->cooling_overrun_)))
92  return false;
93 
94  if (this->supports_heat_ && (std::isnan(this->heating_deadband_) || std::isnan(this->heating_overrun_)))
95  return false;
96 
97  return true;
98 }
99 
101  if (std::isnan(this->target_temperature)) {
102  this->target_temperature =
105  } else {
106  // target_temperature must be between the visual minimum and the visual maximum
107  if (this->target_temperature < this->get_traits().get_visual_min_temperature())
109  if (this->target_temperature > this->get_traits().get_visual_max_temperature())
111  }
112 }
113 
115  if (this->supports_two_points_) {
118  } else {
120  }
121 }
122 
124  if (std::isnan(this->target_temperature_low)) {
126  } else {
127  // target_temperature_low must not be lower than the visual minimum
128  if (this->target_temperature_low < this->get_traits().get_visual_min_temperature())
130  // target_temperature_low must not be greater than the visual maximum minus set_point_minimum_differential_
131  if (this->target_temperature_low >
132  this->get_traits().get_visual_max_temperature() - this->set_point_minimum_differential_)
133  this->target_temperature_low =
135  // if target_temperature_low is set greater than target_temperature_high, move up target_temperature_high
138  }
139 }
140 
142  if (std::isnan(this->target_temperature_high)) {
144  } else {
145  // target_temperature_high must not be lower than the visual maximum
146  if (this->target_temperature_high > this->get_traits().get_visual_max_temperature())
148  // target_temperature_high must not be lower than the visual minimum plus set_point_minimum_differential_
149  if (this->target_temperature_high <
150  this->get_traits().get_visual_min_temperature() + this->set_point_minimum_differential_)
153  // if target_temperature_high is set less than target_temperature_low, move down target_temperature_low
154  if (this->target_temperature_high < this->target_temperature_low + this->set_point_minimum_differential_)
156  }
157 }
158 
160  if (call.get_preset().has_value()) {
161  // setup_complete_ blocks modifying/resetting the temps immediately after boot
162  if (this->setup_complete_) {
164  } else {
165  this->preset = *call.get_preset();
166  }
167  }
168  if (call.get_mode().has_value())
169  this->mode = *call.get_mode();
170  if (call.get_fan_mode().has_value())
171  this->fan_mode = *call.get_fan_mode();
172  if (call.get_swing_mode().has_value())
173  this->swing_mode = *call.get_swing_mode();
174  if (this->supports_two_points_) {
175  if (call.get_target_temperature_low().has_value()) {
178  }
179  if (call.get_target_temperature_high().has_value()) {
182  }
183  } else {
184  if (call.get_target_temperature().has_value()) {
187  }
188  }
189  // make any changes happen
190  refresh();
191 }
192 
196  if (supports_auto_)
200  if (supports_cool_)
202  if (supports_dry_)
204  if (supports_fan_only_)
206  if (supports_heat_)
208 
227 
236 
237  if (supports_away_)
239 
242  return traits;
243 }
244 
246  auto target_action = climate::CLIMATE_ACTION_IDLE;
247  // if any hysteresis values or current_temperature is not valid, we go to OFF;
248  if (std::isnan(this->current_temperature) || !this->hysteresis_valid()) {
250  }
251  // do not change the action if an "ON" timer is running
252  if ((!ignore_timers) &&
255  return this->action;
256  }
257 
258  // ensure set point(s) is/are valid before computing the action
260  // everything has been validated so we can now safely compute the action
261  switch (this->mode) {
262  // if the climate mode is OFF then the climate action must be OFF
264  target_action = climate::CLIMATE_ACTION_OFF;
265  break;
267  if (this->fanning_required_())
268  target_action = climate::CLIMATE_ACTION_FAN;
269  break;
271  target_action = climate::CLIMATE_ACTION_DRYING;
272  break;
274  if (this->cooling_required_() && this->heating_required_()) {
275  // this is bad and should never happen, so just stop.
276  // target_action = climate::CLIMATE_ACTION_IDLE;
277  } else if (this->cooling_required_()) {
278  target_action = climate::CLIMATE_ACTION_COOLING;
279  } else if (this->heating_required_()) {
280  target_action = climate::CLIMATE_ACTION_HEATING;
281  }
282  break;
284  if (this->cooling_required_()) {
285  target_action = climate::CLIMATE_ACTION_COOLING;
286  }
287  break;
289  if (this->heating_required_()) {
290  target_action = climate::CLIMATE_ACTION_HEATING;
291  }
292  break;
293  default:
294  break;
295  }
296  // do not abruptly switch actions. cycle through IDLE, first. we'll catch this at the next update.
298  (target_action == climate::CLIMATE_ACTION_HEATING)) ||
300  ((target_action == climate::CLIMATE_ACTION_COOLING) || (target_action == climate::CLIMATE_ACTION_DRYING)))) {
302  }
303 
304  return target_action;
305 }
306 
308  auto target_action = climate::CLIMATE_ACTION_IDLE;
309  // if any hysteresis values or current_temperature is not valid, we go to OFF;
310  if (std::isnan(this->current_temperature) || !this->hysteresis_valid()) {
312  }
313 
314  // ensure set point(s) is/are valid before computing the action
316  // everything has been validated so we can now safely compute the action
317  switch (this->mode) {
318  // if the climate mode is OFF then the climate action must be OFF
320  target_action = climate::CLIMATE_ACTION_OFF;
321  break;
324  // this is bad and should never happen, so just stop.
325  // target_action = climate::CLIMATE_ACTION_IDLE;
326  } else if (this->supplemental_cooling_required_()) {
327  target_action = climate::CLIMATE_ACTION_COOLING;
328  } else if (this->supplemental_heating_required_()) {
329  target_action = climate::CLIMATE_ACTION_HEATING;
330  }
331  break;
333  if (this->supplemental_cooling_required_()) {
334  target_action = climate::CLIMATE_ACTION_COOLING;
335  }
336  break;
338  if (this->supplemental_heating_required_()) {
339  target_action = climate::CLIMATE_ACTION_HEATING;
340  }
341  break;
342  default:
343  break;
344  }
345 
346  return target_action;
347 }
348 
350  // setup_complete_ helps us ensure an action is called immediately after boot
351  if ((action == this->action) && this->setup_complete_)
352  // already in target mode
353  return;
354 
355  if (((action == climate::CLIMATE_ACTION_OFF && this->action == climate::CLIMATE_ACTION_IDLE) ||
356  (action == climate::CLIMATE_ACTION_IDLE && this->action == climate::CLIMATE_ACTION_OFF)) &&
357  this->setup_complete_) {
358  // switching from OFF to IDLE or vice-versa -- this is only a visual difference.
359  // OFF means user manually disabled, IDLE means the temperature is in target range.
360  this->action = action;
361  if (publish_state)
362  this->publish_state();
363  return;
364  }
365 
366  bool action_ready = false;
367  Trigger<> *trig = this->idle_action_trigger_, *trig_fan = nullptr;
368  switch (action) {
371  if (this->idle_action_ready_()) {
373  if (this->action == climate::CLIMATE_ACTION_COOLING)
375  if (this->action == climate::CLIMATE_ACTION_FAN) {
378  else
380  }
381  if (this->action == climate::CLIMATE_ACTION_HEATING)
383  // trig = this->idle_action_trigger_;
384  ESP_LOGVV(TAG, "Switching to IDLE/OFF action");
385  this->cooling_max_runtime_exceeded_ = false;
386  this->heating_max_runtime_exceeded_ = false;
387  action_ready = true;
388  }
389  break;
391  if (this->cooling_action_ready_()) {
394  if (this->supports_fan_with_cooling_) {
396  trig_fan = this->fan_only_action_trigger_;
397  }
398  trig = this->cool_action_trigger_;
399  ESP_LOGVV(TAG, "Switching to COOLING action");
400  action_ready = true;
401  }
402  break;
404  if (this->heating_action_ready_()) {
407  if (this->supports_fan_with_heating_) {
409  trig_fan = this->fan_only_action_trigger_;
410  }
411  trig = this->heat_action_trigger_;
412  ESP_LOGVV(TAG, "Switching to HEATING action");
413  action_ready = true;
414  }
415  break;
417  if (this->fanning_action_ready_()) {
420  else
422  trig = this->fan_only_action_trigger_;
423  ESP_LOGVV(TAG, "Switching to FAN_ONLY action");
424  action_ready = true;
425  }
426  break;
428  if (this->drying_action_ready_()) {
431  trig = this->dry_action_trigger_;
432  ESP_LOGVV(TAG, "Switching to DRYING action");
433  action_ready = true;
434  }
435  break;
436  default:
437  // we cannot report an invalid mode back to HA (even if it asked for one)
438  // and must assume some valid value
440  // trig = this->idle_action_trigger_;
441  }
442 
443  if (action_ready) {
444  if (this->prev_action_trigger_ != nullptr) {
446  this->prev_action_trigger_ = nullptr;
447  }
448  this->action = action;
449  this->prev_action_trigger_ = trig;
450  assert(trig != nullptr);
451  trig->trigger();
452  // if enabled, call the fan_only action with cooling/heating actions
453  if (trig_fan != nullptr) {
454  ESP_LOGVV(TAG, "Calling FAN_ONLY action with HEATING/COOLING action");
455  trig_fan->trigger();
456  }
457  if (publish_state)
458  this->publish_state();
459  }
460 }
461 
463  // setup_complete_ helps us ensure an action is called immediately after boot
464  if ((action == this->supplemental_action_) && this->setup_complete_)
465  // already in target mode
466  return;
467 
468  switch (action) {
473  break;
476  break;
479  break;
480  default:
481  return;
482  }
483  ESP_LOGVV(TAG, "Updating supplemental action...");
486 }
487 
489  Trigger<> *trig = nullptr;
490 
491  switch (this->supplemental_action_) {
495  }
497  ESP_LOGVV(TAG, "Calling supplemental COOLING action");
498  break;
502  }
504  ESP_LOGVV(TAG, "Calling supplemental HEATING action");
505  break;
506  default:
507  break;
508  }
509 
510  if (trig != nullptr) {
511  assert(trig != nullptr);
512  trig->trigger();
513  }
514 }
515 
517  // setup_complete_ helps us ensure an action is called immediately after boot
518  if ((fan_mode == this->prev_fan_mode_) && this->setup_complete_)
519  // already in target mode
520  return;
521 
522  this->fan_mode = fan_mode;
523  if (publish_state)
524  this->publish_state();
525 
526  if (this->fan_mode_ready_()) {
527  Trigger<> *trig = this->fan_mode_auto_trigger_;
528  switch (fan_mode) {
530  trig = this->fan_mode_on_trigger_;
531  ESP_LOGVV(TAG, "Switching to FAN_ON mode");
532  break;
534  trig = this->fan_mode_off_trigger_;
535  ESP_LOGVV(TAG, "Switching to FAN_OFF mode");
536  break;
538  // trig = this->fan_mode_auto_trigger_;
539  ESP_LOGVV(TAG, "Switching to FAN_AUTO mode");
540  break;
542  trig = this->fan_mode_low_trigger_;
543  ESP_LOGVV(TAG, "Switching to FAN_LOW mode");
544  break;
546  trig = this->fan_mode_medium_trigger_;
547  ESP_LOGVV(TAG, "Switching to FAN_MEDIUM mode");
548  break;
550  trig = this->fan_mode_high_trigger_;
551  ESP_LOGVV(TAG, "Switching to FAN_HIGH mode");
552  break;
554  trig = this->fan_mode_middle_trigger_;
555  ESP_LOGVV(TAG, "Switching to FAN_MIDDLE mode");
556  break;
558  trig = this->fan_mode_focus_trigger_;
559  ESP_LOGVV(TAG, "Switching to FAN_FOCUS mode");
560  break;
562  trig = this->fan_mode_diffuse_trigger_;
563  ESP_LOGVV(TAG, "Switching to FAN_DIFFUSE mode");
564  break;
565  default:
566  // we cannot report an invalid mode back to HA (even if it asked for one)
567  // and must assume some valid value
568  fan_mode = climate::CLIMATE_FAN_AUTO;
569  // trig = this->fan_mode_auto_trigger_;
570  }
571  if (this->prev_fan_mode_trigger_ != nullptr) {
573  this->prev_fan_mode_trigger_ = nullptr;
574  }
576  assert(trig != nullptr);
577  trig->trigger();
578  this->prev_fan_mode_ = fan_mode;
579  this->prev_fan_mode_trigger_ = trig;
580  }
581 }
582 
584  // setup_complete_ helps us ensure an action is called immediately after boot
585  if ((mode == this->prev_mode_) && this->setup_complete_)
586  // already in target mode
587  return;
588 
589  if (this->prev_mode_trigger_ != nullptr) {
591  this->prev_mode_trigger_ = nullptr;
592  }
593  Trigger<> *trig = this->auto_mode_trigger_;
594  switch (mode) {
596  trig = this->off_mode_trigger_;
597  break;
599  // trig = this->auto_mode_trigger_;
600  break;
602  trig = this->cool_mode_trigger_;
603  break;
605  trig = this->heat_mode_trigger_;
606  break;
608  trig = this->fan_only_mode_trigger_;
609  break;
611  trig = this->dry_mode_trigger_;
612  break;
613  default:
614  // we cannot report an invalid mode back to HA (even if it asked for one)
615  // and must assume some valid value
617  // trig = this->auto_mode_trigger_;
618  }
619  assert(trig != nullptr);
620  trig->trigger();
621  this->mode = mode;
622  this->prev_mode_ = mode;
623  this->prev_mode_trigger_ = trig;
624  if (publish_state)
625  this->publish_state();
626 }
627 
629  // setup_complete_ helps us ensure an action is called immediately after boot
630  if ((swing_mode == this->prev_swing_mode_) && this->setup_complete_)
631  // already in target mode
632  return;
633 
634  if (this->prev_swing_mode_trigger_ != nullptr) {
636  this->prev_swing_mode_trigger_ = nullptr;
637  }
638  Trigger<> *trig = this->swing_mode_off_trigger_;
639  switch (swing_mode) {
641  trig = this->swing_mode_both_trigger_;
642  break;
644  trig = this->swing_mode_horizontal_trigger_;
645  break;
647  // trig = this->swing_mode_off_trigger_;
648  break;
650  trig = this->swing_mode_vertical_trigger_;
651  break;
652  default:
653  // we cannot report an invalid mode back to HA (even if it asked for one)
654  // and must assume some valid value
655  swing_mode = climate::CLIMATE_SWING_OFF;
656  // trig = this->swing_mode_off_trigger_;
657  }
658  assert(trig != nullptr);
659  trig->trigger();
660  this->swing_mode = swing_mode;
662  this->prev_swing_mode_trigger_ = trig;
663  if (publish_state)
664  this->publish_state();
665 }
666 
671  }
674 }
675 
679 }
680 
684 }
685 
687 
690  return !(this->timer_active_(thermostat::TIMER_FAN_MODE));
691  }
693 }
694 
698 }
699 
701  if (this->timer_duration_(timer_index) > 0) {
702  this->set_timeout(this->timer_[timer_index].name, this->timer_duration_(timer_index),
703  this->timer_cbf_(timer_index));
704  this->timer_[timer_index].active = true;
705  }
706 }
707 
709  this->timer_[timer_index].active = false;
710  return this->cancel_timeout(this->timer_[timer_index].name);
711 }
712 
714  return this->timer_[timer_index].active;
715 }
716 
718  return this->timer_[timer_index].time;
719 }
720 
721 std::function<void()> ThermostatClimate::timer_cbf_(ThermostatClimateTimerIndex timer_index) {
722  return this->timer_[timer_index].func;
723 }
724 
726  ESP_LOGVV(TAG, "cooling_max_run_time timer expired");
727  this->timer_[thermostat::TIMER_COOLING_MAX_RUN_TIME].active = false;
728  this->cooling_max_runtime_exceeded_ = true;
731 }
732 
734  ESP_LOGVV(TAG, "cooling_off timer expired");
735  this->timer_[thermostat::TIMER_COOLING_OFF].active = false;
736  this->switch_to_action_(this->compute_action_());
738 }
739 
741  ESP_LOGVV(TAG, "cooling_on timer expired");
742  this->timer_[thermostat::TIMER_COOLING_ON].active = false;
743  this->switch_to_action_(this->compute_action_());
745 }
746 
748  ESP_LOGVV(TAG, "fan_mode timer expired");
749  this->timer_[thermostat::TIMER_FAN_MODE].active = false;
752  this->switch_to_action_(this->compute_action_());
753 }
754 
756  ESP_LOGVV(TAG, "fanning_off timer expired");
757  this->timer_[thermostat::TIMER_FANNING_OFF].active = false;
758  this->switch_to_action_(this->compute_action_());
759 }
760 
762  ESP_LOGVV(TAG, "fanning_on timer expired");
763  this->timer_[thermostat::TIMER_FANNING_ON].active = false;
764  this->switch_to_action_(this->compute_action_());
765 }
766 
768  ESP_LOGVV(TAG, "heating_max_run_time timer expired");
769  this->timer_[thermostat::TIMER_HEATING_MAX_RUN_TIME].active = false;
770  this->heating_max_runtime_exceeded_ = true;
773 }
774 
776  ESP_LOGVV(TAG, "heating_off timer expired");
777  this->timer_[thermostat::TIMER_HEATING_OFF].active = false;
778  this->switch_to_action_(this->compute_action_());
780 }
781 
783  ESP_LOGVV(TAG, "heating_on timer expired");
784  this->timer_[thermostat::TIMER_HEATING_ON].active = false;
785  this->switch_to_action_(this->compute_action_());
787 }
788 
790  ESP_LOGVV(TAG, "idle_on timer expired");
791  this->timer_[thermostat::TIMER_IDLE_ON].active = false;
792  this->switch_to_action_(this->compute_action_());
794 }
795 
797  if (this->supports_two_points_) {
798  // setup_complete_ helps us ensure an action is called immediately after boot
801  return; // nothing changed, no reason to trigger
802  } else {
803  // save the new temperatures so we can check them again later; the trigger will fire below
806  }
807  } else {
808  if ((this->prev_target_temperature_ == this->target_temperature) && this->setup_complete_) {
809  return; // nothing changed, no reason to trigger
810  } else {
811  // save the new temperature so we can check it again later; the trigger will fire below
813  }
814  }
815  // trigger the action
817  assert(trig != nullptr);
818  trig->trigger();
819 }
820 
822  auto temperature = this->supports_two_points_ ? this->target_temperature_high : this->target_temperature;
823 
824  if (this->supports_cool_) {
825  if (this->current_temperature > temperature + this->cooling_deadband_) {
826  // if the current temperature exceeds the target + deadband, cooling is required
827  return true;
828  } else if (this->current_temperature < temperature - this->cooling_overrun_) {
829  // if the current temperature is less than the target - overrun, cooling should stop
830  return false;
831  } else {
832  // if we get here, the current temperature is between target + deadband and target - overrun,
833  // so the action should not change unless it conflicts with the current mode
834  return (this->action == climate::CLIMATE_ACTION_COOLING) &&
836  }
837  }
838  return false;
839 }
840 
842  auto temperature = this->supports_two_points_ ? this->target_temperature_high : this->target_temperature;
843 
844  if (this->supports_fan_only_) {
845  if (this->supports_fan_only_cooling_) {
846  if (this->current_temperature > temperature + this->cooling_deadband_) {
847  // if the current temperature exceeds the target + deadband, fanning is required
848  return true;
849  } else if (this->current_temperature < temperature - this->cooling_overrun_) {
850  // if the current temperature is less than the target - overrun, fanning should stop
851  return false;
852  } else {
853  // if we get here, the current temperature is between target + deadband and target - overrun,
854  // so the action should not change unless it conflicts with the current mode
856  }
857  } else {
858  return true;
859  }
860  }
861  return false;
862 }
863 
865  auto temperature = this->supports_two_points_ ? this->target_temperature_low : this->target_temperature;
866 
867  if (this->supports_heat_) {
868  if (this->current_temperature < temperature - this->heating_deadband_) {
869  // if the current temperature is below the target - deadband, heating is required
870  return true;
871  } else if (this->current_temperature > temperature + this->heating_overrun_) {
872  // if the current temperature is above the target + overrun, heating should stop
873  return false;
874  } else {
875  // if we get here, the current temperature is between target - deadband and target + overrun,
876  // so the action should not change unless it conflicts with the current mode
877  return (this->action == climate::CLIMATE_ACTION_HEATING) &&
879  }
880  }
881  return false;
882 }
883 
885  auto temperature = this->supports_two_points_ ? this->target_temperature_high : this->target_temperature;
886  // the component must supports_cool_ and the climate action must be climate::CLIMATE_ACTION_COOLING. then...
887  // supplemental cooling is required if the max delta or max runtime was exceeded or the action is already engaged
888  return this->supports_cool_ && (this->action == climate::CLIMATE_ACTION_COOLING) &&
890  (this->current_temperature > temperature + this->supplemental_cool_delta_) ||
892 }
893 
895  auto temperature = this->supports_two_points_ ? this->target_temperature_low : this->target_temperature;
896  // the component must supports_heat_ and the climate action must be climate::CLIMATE_ACTION_HEATING. then...
897  // supplemental heating is required if the max delta or max runtime was exceeded or the action is already engaged
898  return this->supports_heat_ && (this->action == climate::CLIMATE_ACTION_HEATING) &&
900  (this->current_temperature < temperature - this->supplemental_heat_delta_) ||
902 }
903 
905  if (!away) {
906  if (this->supports_two_points_) {
909  } else
911  } else {
912  if (this->supports_two_points_) {
915  } else
917  }
919 }
920 
922  this->normal_config_ = normal_config;
923 }
924 
926  this->supports_away_ = true;
927  this->away_config_ = away_config;
928 }
929 
931  : cool_action_trigger_(new Trigger<>()),
933  cool_mode_trigger_(new Trigger<>()),
934  dry_action_trigger_(new Trigger<>()),
935  dry_mode_trigger_(new Trigger<>()),
936  heat_action_trigger_(new Trigger<>()),
938  heat_mode_trigger_(new Trigger<>()),
939  auto_mode_trigger_(new Trigger<>()),
940  idle_action_trigger_(new Trigger<>()),
941  off_mode_trigger_(new Trigger<>()),
944  fan_mode_on_trigger_(new Trigger<>()),
958 
959 void ThermostatClimate::set_default_mode(climate::ClimateMode default_mode) { this->default_mode_ = default_mode; }
961  this->set_point_minimum_differential_ = differential;
962 }
963 void ThermostatClimate::set_cool_deadband(float deadband) { this->cooling_deadband_ = deadband; }
964 void ThermostatClimate::set_cool_overrun(float overrun) { this->cooling_overrun_ = overrun; }
965 void ThermostatClimate::set_heat_deadband(float deadband) { this->heating_deadband_ = deadband; }
966 void ThermostatClimate::set_heat_overrun(float overrun) { this->heating_overrun_ = overrun; }
971  1000 * (time < this->min_timer_duration_ ? this->min_timer_duration_ : time);
972 }
975  1000 * (time < this->min_timer_duration_ ? this->min_timer_duration_ : time);
976 }
979  1000 * (time < this->min_timer_duration_ ? this->min_timer_duration_ : time);
980 }
982  this->timer_[thermostat::TIMER_FAN_MODE].time =
983  1000 * (time < this->min_timer_duration_ ? this->min_timer_duration_ : time);
984 }
987  1000 * (time < this->min_timer_duration_ ? this->min_timer_duration_ : time);
988 }
991  1000 * (time < this->min_timer_duration_ ? this->min_timer_duration_ : time);
992 }
995  1000 * (time < this->min_timer_duration_ ? this->min_timer_duration_ : time);
996 }
999  1000 * (time < this->min_timer_duration_ ? this->min_timer_duration_ : time);
1000 }
1002  this->timer_[thermostat::TIMER_HEATING_ON].time =
1003  1000 * (time < this->min_timer_duration_ ? this->min_timer_duration_ : time);
1004 }
1006  this->timer_[thermostat::TIMER_IDLE_ON].time =
1007  1000 * (time < this->min_timer_duration_ ? this->min_timer_duration_ : time);
1008 }
1009 void ThermostatClimate::set_sensor(sensor::Sensor *sensor) { this->sensor_ = sensor; }
1010 void ThermostatClimate::set_use_startup_delay(bool use_startup_delay) { this->use_startup_delay_ = use_startup_delay; }
1011 void ThermostatClimate::set_supports_heat_cool(bool supports_heat_cool) {
1012  this->supports_heat_cool_ = supports_heat_cool;
1013 }
1014 void ThermostatClimate::set_supports_auto(bool supports_auto) { this->supports_auto_ = supports_auto; }
1015 void ThermostatClimate::set_supports_cool(bool supports_cool) { this->supports_cool_ = supports_cool; }
1016 void ThermostatClimate::set_supports_dry(bool supports_dry) { this->supports_dry_ = supports_dry; }
1017 void ThermostatClimate::set_supports_fan_only(bool supports_fan_only) { this->supports_fan_only_ = supports_fan_only; }
1019  bool supports_fan_only_action_uses_fan_mode_timer) {
1020  this->supports_fan_only_action_uses_fan_mode_timer_ = supports_fan_only_action_uses_fan_mode_timer;
1021 }
1022 void ThermostatClimate::set_supports_fan_only_cooling(bool supports_fan_only_cooling) {
1023  this->supports_fan_only_cooling_ = supports_fan_only_cooling;
1024 }
1025 void ThermostatClimate::set_supports_fan_with_cooling(bool supports_fan_with_cooling) {
1026  this->supports_fan_with_cooling_ = supports_fan_with_cooling;
1027 }
1028 void ThermostatClimate::set_supports_fan_with_heating(bool supports_fan_with_heating) {
1029  this->supports_fan_with_heating_ = supports_fan_with_heating;
1030 }
1031 void ThermostatClimate::set_supports_heat(bool supports_heat) { this->supports_heat_ = supports_heat; }
1032 void ThermostatClimate::set_supports_fan_mode_on(bool supports_fan_mode_on) {
1033  this->supports_fan_mode_on_ = supports_fan_mode_on;
1034 }
1035 void ThermostatClimate::set_supports_fan_mode_off(bool supports_fan_mode_off) {
1036  this->supports_fan_mode_off_ = supports_fan_mode_off;
1037 }
1038 void ThermostatClimate::set_supports_fan_mode_auto(bool supports_fan_mode_auto) {
1039  this->supports_fan_mode_auto_ = supports_fan_mode_auto;
1040 }
1041 void ThermostatClimate::set_supports_fan_mode_low(bool supports_fan_mode_low) {
1042  this->supports_fan_mode_low_ = supports_fan_mode_low;
1043 }
1044 void ThermostatClimate::set_supports_fan_mode_medium(bool supports_fan_mode_medium) {
1045  this->supports_fan_mode_medium_ = supports_fan_mode_medium;
1046 }
1047 void ThermostatClimate::set_supports_fan_mode_high(bool supports_fan_mode_high) {
1048  this->supports_fan_mode_high_ = supports_fan_mode_high;
1049 }
1050 void ThermostatClimate::set_supports_fan_mode_middle(bool supports_fan_mode_middle) {
1051  this->supports_fan_mode_middle_ = supports_fan_mode_middle;
1052 }
1053 void ThermostatClimate::set_supports_fan_mode_focus(bool supports_fan_mode_focus) {
1054  this->supports_fan_mode_focus_ = supports_fan_mode_focus;
1055 }
1056 void ThermostatClimate::set_supports_fan_mode_diffuse(bool supports_fan_mode_diffuse) {
1057  this->supports_fan_mode_diffuse_ = supports_fan_mode_diffuse;
1058 }
1059 void ThermostatClimate::set_supports_swing_mode_both(bool supports_swing_mode_both) {
1060  this->supports_swing_mode_both_ = supports_swing_mode_both;
1061 }
1062 void ThermostatClimate::set_supports_swing_mode_off(bool supports_swing_mode_off) {
1063  this->supports_swing_mode_off_ = supports_swing_mode_off;
1064 }
1065 void ThermostatClimate::set_supports_swing_mode_horizontal(bool supports_swing_mode_horizontal) {
1066  this->supports_swing_mode_horizontal_ = supports_swing_mode_horizontal;
1067 }
1068 void ThermostatClimate::set_supports_swing_mode_vertical(bool supports_swing_mode_vertical) {
1069  this->supports_swing_mode_vertical_ = supports_swing_mode_vertical;
1070 }
1071 void ThermostatClimate::set_supports_two_points(bool supports_two_points) {
1072  this->supports_two_points_ = supports_two_points;
1073 }
1074 
1077  return this->supplemental_cool_action_trigger_;
1078 }
1083  return this->supplemental_heat_action_trigger_;
1084 }
1106 
1108  LOG_CLIMATE("", "Thermostat", this);
1109  if (this->supports_heat_) {
1110  if (this->supports_two_points_)
1111  ESP_LOGCONFIG(TAG, " Default Target Temperature Low: %.1f°C", this->normal_config_.default_temperature_low);
1112  else
1113  ESP_LOGCONFIG(TAG, " Default Target Temperature Low: %.1f°C", this->normal_config_.default_temperature);
1114  }
1115  if ((this->supports_cool_) || (this->supports_fan_only_ && this->supports_fan_only_cooling_)) {
1116  if (this->supports_two_points_)
1117  ESP_LOGCONFIG(TAG, " Default Target Temperature High: %.1f°C", this->normal_config_.default_temperature_high);
1118  else
1119  ESP_LOGCONFIG(TAG, " Default Target Temperature High: %.1f°C", this->normal_config_.default_temperature);
1120  }
1121  if (this->supports_two_points_)
1122  ESP_LOGCONFIG(TAG, " Minimum Set Point Differential: %.1f°C", this->set_point_minimum_differential_);
1123  ESP_LOGCONFIG(TAG, " Start-up Delay Enabled: %s", YESNO(this->use_startup_delay_));
1124  if (this->supports_cool_) {
1125  ESP_LOGCONFIG(TAG, " Cooling Parameters:");
1126  ESP_LOGCONFIG(TAG, " Deadband: %.1f°C", this->cooling_deadband_);
1127  ESP_LOGCONFIG(TAG, " Overrun: %.1f°C", this->cooling_overrun_);
1129  ESP_LOGCONFIG(TAG, " Supplemental Delta: %.1f°C", this->supplemental_cool_delta_);
1130  ESP_LOGCONFIG(TAG, " Maximum Run Time: %us",
1132  }
1133  ESP_LOGCONFIG(TAG, " Minimum Off Time: %us", this->timer_duration_(thermostat::TIMER_COOLING_OFF) / 1000);
1134  ESP_LOGCONFIG(TAG, " Minimum Run Time: %us", this->timer_duration_(thermostat::TIMER_COOLING_ON) / 1000);
1135  }
1136  if (this->supports_heat_) {
1137  ESP_LOGCONFIG(TAG, " Heating Parameters:");
1138  ESP_LOGCONFIG(TAG, " Deadband: %.1f°C", this->heating_deadband_);
1139  ESP_LOGCONFIG(TAG, " Overrun: %.1f°C", this->heating_overrun_);
1141  ESP_LOGCONFIG(TAG, " Supplemental Delta: %.1f°C", this->supplemental_heat_delta_);
1142  ESP_LOGCONFIG(TAG, " Maximum Run Time: %us",
1144  }
1145  ESP_LOGCONFIG(TAG, " Minimum Off Time: %us", this->timer_duration_(thermostat::TIMER_HEATING_OFF) / 1000);
1146  ESP_LOGCONFIG(TAG, " Minimum Run Time: %us", this->timer_duration_(thermostat::TIMER_HEATING_ON) / 1000);
1147  }
1148  if (this->supports_fan_only_) {
1149  ESP_LOGCONFIG(TAG, " Fanning Minimum Off Time: %us", this->timer_duration_(thermostat::TIMER_FANNING_OFF) / 1000);
1150  ESP_LOGCONFIG(TAG, " Fanning Minimum Run Time: %us", this->timer_duration_(thermostat::TIMER_FANNING_ON) / 1000);
1151  }
1155  ESP_LOGCONFIG(TAG, " Minimum Fan Mode Switching Time: %us",
1157  }
1158  ESP_LOGCONFIG(TAG, " Minimum Idle Time: %us", this->timer_[thermostat::TIMER_IDLE_ON].time / 1000);
1159  ESP_LOGCONFIG(TAG, " Supports AUTO: %s", YESNO(this->supports_auto_));
1160  ESP_LOGCONFIG(TAG, " Supports HEAT/COOL: %s", YESNO(this->supports_heat_cool_));
1161  ESP_LOGCONFIG(TAG, " Supports COOL: %s", YESNO(this->supports_cool_));
1162  ESP_LOGCONFIG(TAG, " Supports DRY: %s", YESNO(this->supports_dry_));
1163  ESP_LOGCONFIG(TAG, " Supports FAN_ONLY: %s", YESNO(this->supports_fan_only_));
1164  ESP_LOGCONFIG(TAG, " Supports FAN_ONLY_ACTION_USES_FAN_MODE_TIMER: %s",
1166  ESP_LOGCONFIG(TAG, " Supports FAN_ONLY_COOLING: %s", YESNO(this->supports_fan_only_cooling_));
1167  if (this->supports_cool_)
1168  ESP_LOGCONFIG(TAG, " Supports FAN_WITH_COOLING: %s", YESNO(this->supports_fan_with_cooling_));
1169  if (this->supports_heat_)
1170  ESP_LOGCONFIG(TAG, " Supports FAN_WITH_HEATING: %s", YESNO(this->supports_fan_with_heating_));
1171  ESP_LOGCONFIG(TAG, " Supports HEAT: %s", YESNO(this->supports_heat_));
1172  ESP_LOGCONFIG(TAG, " Supports FAN MODE ON: %s", YESNO(this->supports_fan_mode_on_));
1173  ESP_LOGCONFIG(TAG, " Supports FAN MODE OFF: %s", YESNO(this->supports_fan_mode_off_));
1174  ESP_LOGCONFIG(TAG, " Supports FAN MODE AUTO: %s", YESNO(this->supports_fan_mode_auto_));
1175  ESP_LOGCONFIG(TAG, " Supports FAN MODE LOW: %s", YESNO(this->supports_fan_mode_low_));
1176  ESP_LOGCONFIG(TAG, " Supports FAN MODE MEDIUM: %s", YESNO(this->supports_fan_mode_medium_));
1177  ESP_LOGCONFIG(TAG, " Supports FAN MODE HIGH: %s", YESNO(this->supports_fan_mode_high_));
1178  ESP_LOGCONFIG(TAG, " Supports FAN MODE MIDDLE: %s", YESNO(this->supports_fan_mode_middle_));
1179  ESP_LOGCONFIG(TAG, " Supports FAN MODE FOCUS: %s", YESNO(this->supports_fan_mode_focus_));
1180  ESP_LOGCONFIG(TAG, " Supports FAN MODE DIFFUSE: %s", YESNO(this->supports_fan_mode_diffuse_));
1181  ESP_LOGCONFIG(TAG, " Supports SWING MODE BOTH: %s", YESNO(this->supports_swing_mode_both_));
1182  ESP_LOGCONFIG(TAG, " Supports SWING MODE OFF: %s", YESNO(this->supports_swing_mode_off_));
1183  ESP_LOGCONFIG(TAG, " Supports SWING MODE HORIZONTAL: %s", YESNO(this->supports_swing_mode_horizontal_));
1184  ESP_LOGCONFIG(TAG, " Supports SWING MODE VERTICAL: %s", YESNO(this->supports_swing_mode_vertical_));
1185  ESP_LOGCONFIG(TAG, " Supports TWO SET POINTS: %s", YESNO(this->supports_two_points_));
1186  ESP_LOGCONFIG(TAG, " Supports AWAY mode: %s", YESNO(this->supports_away_));
1187  if (this->supports_away_) {
1188  if (this->supports_heat_) {
1189  if (this->supports_two_points_)
1190  ESP_LOGCONFIG(TAG, " Away Default Target Temperature Low: %.1f°C",
1192  else
1193  ESP_LOGCONFIG(TAG, " Away Default Target Temperature Low: %.1f°C", this->away_config_.default_temperature);
1194  }
1195  if ((this->supports_cool_) || (this->supports_fan_only_)) {
1196  if (this->supports_two_points_)
1197  ESP_LOGCONFIG(TAG, " Away Default Target Temperature High: %.1f°C",
1199  else
1200  ESP_LOGCONFIG(TAG, " Away Default Target Temperature High: %.1f°C", this->away_config_.default_temperature);
1201  }
1202  }
1203 }
1204 
1206 
1208  : default_temperature(default_temperature) {}
1209 
1212  : default_temperature_low(default_temperature_low), default_temperature_high(default_temperature_high) {}
1213 
1214 } // namespace thermostat
1215 } // namespace esphome
Trigger * swing_mode_vertical_trigger_
The trigger to call when the controller should switch the swing mode to "vertical".
float set_point_minimum_differential_
Minimum differential required between set points.
This class is used to encode all control actions on a climate device.
Definition: climate.h:33
void set_supports_swing_mode_horizontal(bool supports_swing_mode_horizontal)
The fan mode is set to Low.
Definition: climate_mode.h:54
value_type const & value() const
Definition: optional.h:89
The climate device is off (inactive or no power)
Definition: climate_mode.h:33
Trigger * cool_action_trigger_
The trigger to call when the controller should switch to cooling action/mode.
ClimateSwingMode swing_mode
The active swing mode of the climate device.
Definition: climate.h:204
climate::ClimateTraits traits() override
Return the traits of this controller.
void control(const climate::ClimateCall &call) override
Override control to change settings of the climate device.
void add_on_state_callback(std::function< void(float)> &&callback)
Add a callback that will be called every time a filtered value arrives.
Definition: sensor.cpp:71
Trigger * swing_mode_both_trigger_
The trigger to call when the controller should switch the swing mode to "both".
void set_supports_fan_mode_on(bool supports_fan_mode_on)
The fan mode is set to Both.
Definition: climate_mode.h:72
ThermostatClimateTargetTempConfig away_config_
The climate device is drying.
Definition: climate_mode.h:41
bool cancel_timeout(const std::string &name)
Cancel a timeout function.
Definition: component.cpp:62
void set_supports_fan_mode_auto(bool supports_fan_mode_auto)
void switch_to_action_(climate::ClimateAction action, bool publish_state=true)
Switch the climate device to the given climate action.
Trigger * prev_action_trigger_
A reference to the trigger that was previously active.
Trigger * fan_mode_auto_trigger_
The trigger to call when the controller should switch the fan to "auto" mode.
float target_temperature
The target temperature of the climate device.
Definition: climate.h:183
void set_supports_fan_with_cooling(bool supports_fan_with_cooling)
Trigger * dry_action_trigger_
The trigger to call when the controller should switch to dry (dehumidification) mode.
bool supports_fan_mode_auto_
Whether the controller supports fan auto mode.
void switch_to_supplemental_action_(climate::ClimateAction action)
The climate device is in fan only mode.
Definition: climate_mode.h:43
Device is in home preset.
Definition: climate_mode.h:84
void set_supports_fan_only(bool supports_fan_only)
const optional< ClimateMode > & get_mode() const
Definition: climate.cpp:259
The fan mode is set to Middle.
Definition: climate_mode.h:60
float prev_target_temperature_
Store previously-known temperatures.
This class contains all static data for climate devices.
bool supports_auto_
Whether the controller supports auto/cooling/drying/fanning/heating.
Trigger * fan_mode_middle_trigger_
The trigger to call when the controller should switch the fan to "middle" position.
void set_supports_fan_mode_diffuse(bool supports_fan_mode_diffuse)
The climate device is set to heat to reach the target temperature.
Definition: climate_mode.h:18
ClimateMode mode
The active mode of the climate device.
Definition: climate.h:175
Trigger * heat_action_trigger_
The trigger to call when the controller should switch to heating action/mode.
void set_supports_fan_mode_medium(bool supports_fan_mode_medium)
void set_supports_fan_mode_middle(bool supports_fan_mode_middle)
const optional< float > & get_target_temperature_low() const
Definition: climate.cpp:261
float target_temperature_high
The maximum target temperature of the climate device, for climate devices with split target temperatu...
Definition: climate.h:188
float current_temperature
The current temperature of the climate device, as reported from the integration.
Definition: climate.h:179
The fan mode is set to Diffuse.
Definition: climate_mode.h:64
void set_supports_two_points(bool supports_two_points)
bool has_value() const
Definition: optional.h:87
The climate device is set to dry/humidity mode.
Definition: climate_mode.h:22
void set_supports_swing_mode_vertical(bool supports_swing_mode_vertical)
void set_supports_fan_mode_focus(bool supports_fan_mode_focus)
void set_fan_mode_minimum_switching_time_in_sec(uint32_t time)
climate::ClimateAction compute_supplemental_action_()
void set_supported_presets(std::set< ClimatePreset > presets)
void refresh()
Call triggers based on updated climate states (modes/actions)
void set_supports_fan_only_action_uses_fan_mode_timer(bool fan_only_action_uses_fan_mode_timer)
void switch_to_swing_mode_(climate::ClimateSwingMode swing_mode, bool publish_state=true)
Switch the climate device to the given climate swing mode.
bool hysteresis_valid()
Set point and hysteresis validation.
ClimateSwingMode
Enum for all modes a climate swing can be in.
Definition: climate_mode.h:68
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
Definition: automation.h:90
uint32_t timer_duration_(ThermostatClimateTimerIndex timer_index)
Device is in away preset.
Definition: climate_mode.h:86
void set_supports_heat_cool(bool supports_heat_cool)
Trigger * fan_mode_high_trigger_
The trigger to call when the controller should switch the fan to "high" speed.
float cooling_deadband_
Hysteresis values used for computing climate actions.
bool supports_fan_with_cooling_
Special flags – enables fan_only action to be called with cooling/heating actions.
void add_supported_swing_mode(ClimateSwingMode mode)
void set_supports_swing_mode_off(bool supports_swing_mode_off)
The fan mode is set to Horizontal.
Definition: climate_mode.h:76
The climate device is set to cool to reach the target temperature.
Definition: climate_mode.h:16
float state
This member variable stores the last state that has passed through all filters.
Definition: sensor.h:132
void set_supports_fan_only_cooling(bool supports_fan_only_cooling)
const optional< ClimatePreset > & get_preset() const
Definition: climate.cpp:270
The fan mode is set to Auto.
Definition: climate_mode.h:52
void cooling_max_run_time_timer_callback_()
set_timeout() callbacks for various actions (see above)
optional< ClimatePreset > preset
The active preset of the climate device.
Definition: climate.h:210
bool supports_fan_mode_low_
Whether the controller supports various fan speeds and/or positions.
Trigger * fan_mode_low_trigger_
The trigger to call when the controller should switch the fan to "low" speed.
Trigger * fan_only_action_trigger_
The trigger to call when the controller should switch to fan-only action/mode.
bool idle_action_ready_()
Is the action ready to be called? Returns true if so.
Trigger * temperature_change_trigger_
The trigger to call when the target temperature(s) change(es).
bool cooling_required_()
Check if cooling/fanning/heating actions are required; returns true if so.
bool supports_swing_mode_both_
Whether the controller supports various swing modes.
ClimateAction
Enum for the current action of the climate device. Values match those of ClimateMode.
Definition: climate_mode.h:31
ClimateTraits get_traits()
Get the traits of this climate device with all overrides applied.
Definition: climate.cpp:420
bool cancel_timer_(ThermostatClimateTimerIndex timer_index)
void set_timeout(uint32_t timeout, std::function< void()> &&f)
Definition: component.cpp:117
Trigger * fan_mode_medium_trigger_
The trigger to call when the controller should switch the fan to "medium" speed.
The climate device is adjusting the temperatre dynamically.
Definition: climate_mode.h:27
Trigger * swing_mode_off_trigger_
The trigger to call when the controller should switch the swing mode to "off".
The climate device is set to heat/cool to reach the target temperature.
Definition: climate_mode.h:14
void set_normal_config(const ThermostatClimateTargetTempConfig &normal_config)
The fan mode is set to Vertical.
Definition: climate_mode.h:74
bool supports_away_
Whether the controller supports an "away" mode.
bool timer_active_(ThermostatClimateTimerIndex timer_index)
The climate device is actively heating.
Definition: climate_mode.h:37
The fan mode is set to Focus.
Definition: climate_mode.h:62
climate::ClimateAction supplemental_action_
Store previously-known states.
The fan mode is set to Off.
Definition: climate_mode.h:50
void add_supported_fan_mode(ClimateFanMode mode)
Trigger * idle_action_trigger_
The trigger to call when the controller should switch to idle action/off mode.
Trigger * auto_mode_trigger_
The trigger to call when the controller should switch to auto mode.
void set_away_config(const ThermostatClimateTargetTempConfig &away_config)
const optional< float > & get_target_temperature() const
Definition: climate.cpp:260
climate::ClimateAction delayed_climate_action()
Returns the climate action that is being delayed (check climate_action_change_delayed(), first!)
void publish_state()
Publish the state of the climate device, to be called from integrations.
Definition: climate.cpp:380
Trigger * fan_mode_off_trigger_
The trigger to call when the controller should switch off the fan.
The fan mode is set to High.
Definition: climate_mode.h:58
ClimateMode
Enum for all modes a climate device can be in.
Definition: climate_mode.h:10
The swing mode is set to Off.
Definition: climate_mode.h:70
The climate device is off.
Definition: climate_mode.h:12
void set_use_startup_delay(bool use_startup_delay)
bool climate_action_change_delayed()
Returns true if a climate action/fan mode transition is being delayed.
void set_supports_fan_with_heating(bool supports_fan_with_heating)
void set_supports_action(bool supports_action)
bool cooling_max_runtime_exceeded_
Flags indicating if maximum allowable run time was exceeded.
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
Definition: climate.h:198
void switch_to_fan_mode_(climate::ClimateFanMode fan_mode, bool publish_state=true)
Switch the climate device to the given climate fan mode.
const optional< ClimateFanMode > & get_fan_mode() const
Definition: climate.cpp:268
void change_away_(bool away)
Change the away setting, will reset target temperatures to defaults.
void set_supports_fan_mode_low(bool supports_fan_mode_low)
Trigger * fan_mode_focus_trigger_
The trigger to call when the controller should switch the fan to "focus" position.
The fan mode is set to On.
Definition: climate_mode.h:48
climate::ClimateAction compute_action_(bool ignore_timers=false)
Re-compute the required action of this climate controller.
float cool_deadband()
Get current hysteresis values.
Trigger * swing_mode_horizontal_trigger_
The trigger to call when the controller should switch the swing mode to "horizontal".
std::function< void()> timer_cbf_(ThermostatClimateTimerIndex timer_index)
void set_supports_fan_mode_off(bool supports_fan_mode_off)
sensor::Sensor * sensor_
The sensor used for getting the current temperature.
std::vector< ThermostatClimateTimer > timer_
Climate action timers.
void start_timer_(ThermostatClimateTimerIndex timer_index)
Start/cancel/get status of climate action timer.
float supplemental_cool_delta_
Maximum allowable temperature deltas before engauging supplemental cooling/heating actions...
const optional< ClimateSwingMode > & get_swing_mode() const
Definition: climate.cpp:272
climate::ClimateSwingMode prev_swing_mode_
bool supports_two_points_
Whether the controller supports two set points.
climate::ClimateFanMode locked_fan_mode()
Returns the fan mode that is locked in (check fan_mode_change_delayed(), first!)
void set_set_point_minimum_differential(float differential)
Library based on https://github.com/miguelbalboa/rfid and adapted to ESPHome by . ...
Definition: a4988.cpp:4
void check_temperature_change_trigger_()
Check if the temperature change trigger should be called.
void switch_to_mode_(climate::ClimateMode mode, bool publish_state=true)
Switch the climate device to the given climate mode.
The climate device is idle (monitoring climate but no action needed)
Definition: climate_mode.h:39
void set_supports_two_point_target_temperature(bool supports_two_point_target_temperature)
optional< ClimateDeviceRestoreState > restore_state_()
Restore the state of the climate device, call this from your setup() method.
Definition: climate.cpp:320
Trigger * fan_mode_on_trigger_
The trigger to call when the controller should switch on the fan.
bool supports_fan_mode_on_
Whether the controller supports turning on or off just the fan.
Trigger * fan_mode_diffuse_trigger_
The trigger to call when the controller should switch the fan to "diffuse" position.
void set_supports_current_temperature(bool supports_current_temperature)
The fan mode is set to Medium.
Definition: climate_mode.h:56
const optional< float > & get_target_temperature_high() const
Definition: climate.cpp:262
void set_default_mode(climate::ClimateMode default_mode)
bool supports_fan_only_action_uses_fan_mode_timer_
Special flag – enables fan_modes to share timer with fan_only climate action.
Base-class for all sensors.
Definition: sensor.h:47
void set_supports_fan_mode_high(bool supports_fan_mode_high)
ThermostatClimateTargetTempConfig normal_config_
Temperature data for normal/home and away modes.
void set_supports_swing_mode_both(bool supports_swing_mode_both)
The climate device only has the fan enabled, no heating or cooling is taking place.
Definition: climate_mode.h:20
const uint8_t min_timer_duration_
Minimum allowable duration in seconds for action timers.
The climate device is actively cooling.
Definition: climate_mode.h:35
value_type value_or(U const &v) const
Definition: optional.h:93
void add_supported_mode(ClimateMode mode)
float target_temperature_low
The minimum target temperature of the climate device, for climate devices with split target temperatu...
Definition: climate.h:186
void stop_action()
Stop any action connected to this trigger.
Definition: automation.h:98
bool use_startup_delay_
Used to start "off" delay timers at boot.
ClimateAction action
The active state of the climate device.
Definition: climate.h:177
bool setup_complete_
setup_complete_ blocks modifying/resetting the temps immediately after boot
bool supports_fan_only_cooling_
Special flag – enables fan to be switched based on target_temperature_high.