ESPHome 2026.10.0-dev
Loading...
Searching...
No Matches
template_climate.h
Go to the documentation of this file.
1#pragma once
2
6#ifdef USE_SENSOR
8#endif
9
10namespace esphome::template_ {
11
16
17class TemplateClimate final : public climate::Climate, public Component {
18 public:
19 void setup() override;
20 void dump_config() override;
21
22 climate::ClimateTraits traits() override { return this->traits_; }
23
25
26#ifdef USE_SENSOR
27 // The matching feature flag is added from codegen, so the configuration alone decides it.
28 void set_sensor(sensor::Sensor *sensor) { this->sensor_ = sensor; }
29 void set_humidity_sensor(sensor::Sensor *sensor) { this->humidity_sensor_ = sensor; }
30#endif
31
36
37 void set_optimistic(bool optimistic) { this->optimistic_ = optimistic; }
38 void set_restore_mode(TemplateClimateRestoreMode restore_mode) { this->restore_mode_ = restore_mode; }
39
40 // Fired from control() for each field the call carries, so a device-backed config can forward
41 // it on. Which of these are configured also decides the two-point/target-humidity traits.
52
53 // Used by TemplateClimatePublishAction, which is not a Climate subclass and so cannot reach the
54 // protected setters, and by codegen to apply `initial_state:` before setup() runs.
55 void set_target_temperature(float value) { this->target_temperature = value; }
56 void set_target_temperature_low(float value) { this->target_temperature_low = value; }
57 void set_target_temperature_high(float value) { this->target_temperature_high = value; }
58 void set_target_humidity(float value) { this->target_humidity = value; }
67
68 protected:
69 void control(const climate::ClimateCall &call) override;
70
72 bool optimistic_{false};
74
75#ifdef USE_SENSOR
78#endif
79
90};
91
92} // namespace esphome::template_
StringRef is a reference to a string owned by something else.
Definition string_ref.h:26
This class is used to encode all control actions on a climate device.
Definition climate.h:34
ClimateDevice - This is the base class for all climate integrations.
Definition climate.h:187
ClimateMode mode
The active mode of the climate device.
Definition climate.h:304
float target_temperature
The target temperature of the climate device.
Definition climate.h:285
float target_temperature_low
The minimum target temperature of the climate device, for climate devices with split target temperatu...
Definition climate.h:288
optional< ClimatePreset > preset
The active preset of the climate device.
Definition climate.h:301
float target_humidity
The target humidity of the climate device.
Definition climate.h:295
float target_temperature_high
The maximum target temperature of the climate device, for climate devices with split target temperatu...
Definition climate.h:290
void add_feature_flags(uint32_t feature_flags)
void add_supported_fan_mode(ClimateFanMode mode)
void add_supported_preset(ClimatePreset preset)
void add_supported_mode(ClimateMode mode)
void add_supported_swing_mode(ClimateSwingMode mode)
Base-class for all sensors.
Definition sensor.h:47
Trigger< climate::ClimateMode > set_mode_trigger_
Trigger< climate::ClimateMode > * get_set_mode_trigger()
Trigger< StringRef > * get_set_custom_fan_mode_trigger()
void set_sensor(sensor::Sensor *sensor)
Trigger< climate::ClimateFanMode > * get_set_fan_mode_trigger()
void set_swing_mode(climate::ClimateSwingMode mode)
Trigger< float > * get_set_target_temperature_high_trigger()
Trigger< climate::ClimatePreset > set_preset_trigger_
Trigger< float > * get_set_target_temperature_trigger()
void set_mode(climate::ClimateMode mode)
Trigger< climate::ClimateSwingMode > set_swing_mode_trigger_
void set_preset(climate::ClimatePreset preset)
climate::ClimateTraits traits() override
Trigger< StringRef > set_custom_fan_mode_trigger_
Trigger< climate::ClimateSwingMode > * get_set_swing_mode_trigger()
Trigger< float > * get_set_target_temperature_low_trigger()
void set_custom_fan_mode(const char *mode)
void add_supported_mode(climate::ClimateMode mode)
void control(const climate::ClimateCall &call) override
void add_supported_preset(climate::ClimatePreset preset)
Trigger< float > set_target_temperature_low_trigger_
void add_supported_fan_mode(climate::ClimateFanMode mode)
Trigger< StringRef > * get_set_custom_preset_trigger()
void set_restore_mode(TemplateClimateRestoreMode restore_mode)
TemplateClimateRestoreMode restore_mode_
Trigger< StringRef > set_custom_preset_trigger_
void set_custom_preset(const char *preset)
void set_fan_mode(climate::ClimateFanMode mode)
Trigger< climate::ClimateFanMode > set_fan_mode_trigger_
Trigger< climate::ClimatePreset > * get_set_preset_trigger()
void add_supported_swing_mode(climate::ClimateSwingMode mode)
Trigger< float > set_target_temperature_high_trigger_
Trigger< float > * get_set_target_humidity_trigger()
void set_humidity_sensor(sensor::Sensor *sensor)
uint16_t flags
ClimatePreset
Enum for all preset modes NOTE: If adding values, update ClimatePresetMask in climate_traits....
ClimateSwingMode
Enum for all modes a climate swing can be in NOTE: If adding values, update ClimateSwingModeMask in c...
ClimateMode
Enum for all modes a climate device can be in.
ClimateFanMode
NOTE: If adding values, update ClimateFanModeMask in climate_traits.h to use the new last value.
static void uint32_t