|
ESPHome 2025.12.0-dev
|
ClimateDevice - This is the base class for all climate integrations. More...
#include <climate.h>
Public Member Functions | |
| Climate () | |
| void | add_on_state_callback (std::function< void(Climate &)> &&callback) |
| Add a callback for the climate device state, each time the state of the climate device is updated (using publish_state), this callback will be called. | |
| void | add_on_control_callback (std::function< void(ClimateCall &)> &&callback) |
| Add a callback for the climate device configuration; each time the configuration parameters of a climate device is updated (using perform() of a ClimateCall), this callback will be called, before any on_state callback. | |
| ClimateCall | make_call () |
| Make a climate device control call, this is used to control the climate device, see the ClimateCall description for more info. | |
| void | publish_state () |
| Publish the state of the climate device, to be called from integrations. | |
| ClimateTraits | get_traits () |
| Get the traits of this climate device with all overrides applied. | |
| void | set_visual_min_temperature_override (float visual_min_temperature_override) |
| void | set_visual_max_temperature_override (float visual_max_temperature_override) |
| void | set_visual_temperature_step_override (float target, float current) |
| void | set_visual_min_humidity_override (float visual_min_humidity_override) |
| void | set_visual_max_humidity_override (float visual_max_humidity_override) |
| bool | has_custom_fan_mode () const |
| Check if a custom fan mode is currently active. | |
| bool | has_custom_preset () const |
| Check if a custom preset is currently active. | |
| const char * | get_custom_fan_mode () const |
| Get the active custom fan mode (read-only access). | |
| const char * | get_custom_preset () const |
| Get the active custom preset (read-only access). | |
Public Member Functions inherited from esphome::EntityBase | |
| const StringRef & | get_name () const |
| void | set_name (const char *name) |
| bool | has_own_name () const |
| std::string | get_object_id () const |
| void | set_object_id (const char *object_id) |
| uint32_t | get_object_id_hash () |
| bool | is_internal () const |
| void | set_internal (bool internal) |
| bool | is_disabled_by_default () const |
| void | set_disabled_by_default (bool disabled_by_default) |
| EntityCategory | get_entity_category () const |
| void | set_entity_category (EntityCategory entity_category) |
| ESPDEPRECATED("Use get_icon_ref() instead for better performance (avoids string copy). Will be removed in ESPHome 2026.5.0", "2025.11.0") std void | set_icon (const char *icon) |
| StringRef | get_icon_ref () const |
| uint32_t | get_device_id () const |
| void | set_device (Device *device) |
| bool | has_state () const |
| void | set_has_state (bool state) |
| uint32_t | get_preference_hash () |
| Get a unique hash for storing preferences/settings for this entity. | |
Data Fields | ||
| float | current_temperature {NAN} | |
| The current temperature of the climate device, as reported from the integration. | ||
| float | current_humidity {NAN} | |
| The current humidity of the climate device, as reported from the integration. | ||
| union { | ||
| float target_temperature | ||
| The target temperature of the climate device. More... | ||
| struct { | ||
| float target_temperature_low {NAN} | ||
| The minimum target temperature of the climate device, for climate devices with split target temperature. More... | ||
| float target_temperature_high {NAN} | ||
| The maximum target temperature of the climate device, for climate devices with split target temperature. More... | ||
| } | ||
| }; | ||
| float | target_humidity | |
| The target humidity of the climate device. | ||
| optional< ClimateFanMode > | fan_mode | |
| The active fan mode of the climate device. | ||
| optional< ClimatePreset > | preset | |
| The active preset of the climate device. | ||
| ClimateMode | mode {CLIMATE_MODE_OFF} | |
| The active mode of the climate device. | ||
| ClimateAction | action {CLIMATE_ACTION_OFF} | |
| The active state of the climate device. | ||
| ClimateSwingMode | swing_mode {CLIMATE_SWING_OFF} | |
| The active swing mode of the climate device. | ||
Protected Member Functions | |
| bool | set_fan_mode_ (ClimateFanMode mode) |
| Set fan mode. Reset custom fan mode. Return true if fan mode has been changed. | |
| bool | set_custom_fan_mode_ (const char *mode) |
| Set custom fan mode. Reset primary fan mode. Return true if fan mode has been changed. | |
| void | clear_custom_fan_mode_ () |
| Clear custom fan mode. | |
| bool | set_preset_ (ClimatePreset preset) |
| Set preset. Reset custom preset. Return true if preset has been changed. | |
| bool | set_custom_preset_ (const char *preset) |
| Set custom preset. Reset primary preset. Return true if preset has been changed. | |
| void | clear_custom_preset_ () |
| Clear custom preset. | |
| const char * | find_custom_fan_mode_ (const char *custom_fan_mode) |
| Find and return the matching custom fan mode pointer from traits, or nullptr if not found. | |
| const char * | find_custom_preset_ (const char *custom_preset) |
| Find and return the matching custom preset pointer from traits, or nullptr if not found. | |
| virtual ClimateTraits | traits ()=0 |
| Get the default traits of this climate device. | |
| virtual void | control (const ClimateCall &call)=0 |
| Control the climate device, this is a virtual method that each climate integration must implement. | |
| optional< ClimateDeviceRestoreState > | restore_state_ () |
| Restore the state of the climate device, call this from your setup() method. | |
| void | save_state_ () |
| Internal method to save the state of the climate device to recover memory. | |
| void | dump_traits_ (const char *tag) |
Protected Member Functions inherited from esphome::EntityBase | |
| StringRef | get_object_id_ref_for_api_ () const |
| void | calc_object_id_ () |
| bool | is_object_id_dynamic_ () const |
| Check if the object_id is dynamic (changes with MAC suffix) | |
Protected Attributes | |
| friend | ClimateCall |
| CallbackManager< void(Climate &)> | state_callback_ {} |
| CallbackManager< void(ClimateCall &)> | control_callback_ {} |
| ESPPreferenceObject | rtc_ |
| optional< float > | visual_min_temperature_override_ {} |
| optional< float > | visual_max_temperature_override_ {} |
| optional< float > | visual_target_temperature_step_override_ {} |
| optional< float > | visual_current_temperature_step_override_ {} |
| optional< float > | visual_min_humidity_override_ {} |
| optional< float > | visual_max_humidity_override_ {} |
Protected Attributes inherited from esphome::EntityBase | |
| StringRef | name_ |
| const char * | object_id_c_str_ {nullptr} |
| const char * | icon_c_str_ {nullptr} |
| uint32_t | object_id_hash_ {} |
| Device * | device_ {} |
| struct esphome::EntityBase::EntityFlags | flags_ |
ClimateDevice - This is the base class for all climate integrations.
Each integration needs to extend this class and implement two functions:
To write data to the frontend, the integration must first set the properties using this->property = value; (for example this->current_temperature = 42.0;); then the integration must call this->publish_state(); to send the entire state to the frontend.
The entire state of the climate device is encoded in public properties of the base class (current_temperature, mode etc). These are read-only for the user and rw for integrations. The reason these are public is for simple access to them from lambdas if (id(my_climate).mode == climate::CLIMATE_MODE_HEAT_COOL) ...
| void esphome::climate::Climate::add_on_control_callback | ( | std::function< void(ClimateCall &)> && | callback | ) |
Add a callback for the climate device configuration; each time the configuration parameters of a climate device is updated (using perform() of a ClimateCall), this callback will be called, before any on_state callback.
| callback | The callback to call. |
Definition at line 343 of file climate.cpp.
| void esphome::climate::Climate::add_on_state_callback | ( | std::function< void(Climate &)> && | callback | ) |
Add a callback for the climate device state, each time the state of the climate device is updated (using publish_state), this callback will be called.
| callback | The callback to call. |
Definition at line 339 of file climate.cpp.
|
protected |
Clear custom fan mode.
Definition at line 676 of file climate.cpp.
|
protected |
Clear custom preset.
Definition at line 686 of file climate.cpp.
|
protectedpure virtual |
Control the climate device, this is a virtual method that each climate integration must implement.
See more info in ClimateCall. The integration should check all of its values in this method and set them accordingly. At the end of the call, the integration must call publish_state() to notify the frontend of a changed state.
| call | The ClimateCall instance encoding all attribute changes. |
Implemented in esphome::anova::Anova, esphome::bang_bang::BangBangClimate, esphome::bedjet::BedJetClimate, esphome::climate_ir::ClimateIR, esphome::climate_ir_lg::LgIrClimate, esphome::coolix::CoolixClimate, esphome::daikin_arc::DaikinArcClimate, esphome::daikin_brc::DaikinBrcClimate, esphome::demo::DemoClimate, esphome::haier::HaierClimateBase, esphome::midea::ac::AirConditioner, esphome::midea_ir::MideaIR, esphome::noblex::NoblexClimate, esphome::pid::PIDClimate, esphome::thermostat::ThermostatClimate, esphome::tuya::TuyaClimate, esphome::uponor_smatrix::UponorSmatrixClimate, esphome::whirlpool::WhirlpoolClimate, esphome::whynter::Whynter, and esphome::yashima::YashimaClimate.
|
protected |
Definition at line 696 of file climate.cpp.
|
protected |
Find and return the matching custom fan mode pointer from traits, or nullptr if not found.
Definition at line 688 of file climate.cpp.
|
protected |
Find and return the matching custom preset pointer from traits, or nullptr if not found.
Definition at line 692 of file climate.cpp.
|
inline |
|
inline |
| ClimateTraits esphome::climate::Climate::get_traits | ( | ) |
Get the traits of this climate device with all overrides applied.
Traits are static data that encode the capabilities and static data for a climate device such as supported modes, temperature range etc.
Definition at line 475 of file climate.cpp.
|
inline |
|
inline |
| ClimateCall esphome::climate::Climate::make_call | ( | ) |
Make a climate device control call, this is used to control the climate device, see the ClimateCall description for more info.
Definition at line 518 of file climate.cpp.
| void esphome::climate::Climate::publish_state | ( | ) |
Publish the state of the climate device, to be called from integrations.
This will schedule the climate device to publish its state to all listeners and save the current state to recover memory.
Definition at line 426 of file climate.cpp.
|
protected |
Restore the state of the climate device, call this from your setup() method.
Definition at line 350 of file climate.cpp.
|
protected |
Internal method to save the state of the climate device to recover memory.
This is automatically called from publish_state()
Definition at line 359 of file climate.cpp.
|
protected |
Set custom fan mode. Reset primary fan mode. Return true if fan mode has been changed.
Definition at line 670 of file climate.cpp.
|
protected |
Set custom preset. Reset primary preset. Return true if preset has been changed.
Definition at line 680 of file climate.cpp.
|
protected |
Set fan mode. Reset custom fan mode. Return true if fan mode has been changed.
Definition at line 666 of file climate.cpp.
|
protected |
Set preset. Reset custom preset. Return true if preset has been changed.
Definition at line 678 of file climate.cpp.
| void esphome::climate::Climate::set_visual_max_humidity_override | ( | float | visual_max_humidity_override | ) |
Definition at line 514 of file climate.cpp.
| void esphome::climate::Climate::set_visual_max_temperature_override | ( | float | visual_max_temperature_override | ) |
Definition at line 501 of file climate.cpp.
| void esphome::climate::Climate::set_visual_min_humidity_override | ( | float | visual_min_humidity_override | ) |
Definition at line 510 of file climate.cpp.
| void esphome::climate::Climate::set_visual_min_temperature_override | ( | float | visual_min_temperature_override | ) |
Definition at line 497 of file climate.cpp.
| void esphome::climate::Climate::set_visual_temperature_step_override | ( | float | target, |
| float | current ) |
Definition at line 505 of file climate.cpp.
|
protectedpure virtual |
Get the default traits of this climate device.
Traits are static data that encode the capabilities and static data for a climate device such as supported modes, temperature range etc. Each integration must implement this method and the return value must be constant during all of execution time.
Implemented in esphome::anova::Anova, esphome::bang_bang::BangBangClimate, esphome::bedjet::BedJetClimate, esphome::climate_ir::ClimateIR, esphome::daikin_arc::DaikinArcClimate, esphome::demo::DemoClimate, esphome::haier::HaierClimateBase, esphome::midea::ac::AirConditioner, esphome::mitsubishi::MitsubishiClimate, esphome::pid::PIDClimate, esphome::thermostat::ThermostatClimate, esphome::tuya::TuyaClimate, esphome::uponor_smatrix::UponorSmatrixClimate, and esphome::yashima::YashimaClimate.
| union { ... } esphome::climate::Climate |
| ClimateAction esphome::climate::Climate::action {CLIMATE_ACTION_OFF} |
|
protected |
| float esphome::climate::Climate::current_humidity {NAN} |
| float esphome::climate::Climate::current_temperature {NAN} |
| optional<ClimateFanMode> esphome::climate::Climate::fan_mode |
| ClimateMode esphome::climate::Climate::mode {CLIMATE_MODE_OFF} |
| optional<ClimatePreset> esphome::climate::Climate::preset |
|
protected |
|
protected |
| ClimateSwingMode esphome::climate::Climate::swing_mode {CLIMATE_SWING_OFF} |
| float esphome::climate::Climate::target_humidity |
| float esphome::climate::Climate::target_temperature |
| float esphome::climate::Climate::target_temperature_high {NAN} |
| float esphome::climate::Climate::target_temperature_low {NAN} |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |