ESPHome 2025.12.0-dev
Loading...
Searching...
No Matches
esphome::climate Namespace Reference

Data Structures

class  Climate
 ClimateDevice - This is the base class for all climate integrations. More...
 
class  ClimateCall
 This class is used to encode all control actions on a climate device. More...
 
struct  ClimateDeviceRestoreState
 Struct used to save the state of the climate device in restore memory. More...
 
class  ClimateTraits
 
class  ControlAction
 
class  ControlTrigger
 
class  StateTrigger
 

Typedefs

using ClimateModeMask = FiniteSetMask<ClimateMode, DefaultBitPolicy<ClimateMode, CLIMATE_MODE_AUTO + 1>>
 
using ClimateFanModeMask = FiniteSetMask<ClimateFanMode, DefaultBitPolicy<ClimateFanMode, CLIMATE_FAN_QUIET + 1>>
 
using ClimateSwingModeMask
 
using ClimatePresetMask = FiniteSetMask<ClimatePreset, DefaultBitPolicy<ClimatePreset, CLIMATE_PRESET_ACTIVITY + 1>>
 

Enumerations

enum  ClimateMode : uint8_t {
  CLIMATE_MODE_OFF = 0 , CLIMATE_MODE_HEAT_COOL = 1 , CLIMATE_MODE_COOL = 2 , CLIMATE_MODE_HEAT = 3 ,
  CLIMATE_MODE_FAN_ONLY = 4 , CLIMATE_MODE_DRY = 5 , CLIMATE_MODE_AUTO = 6
}
 Enum for all modes a climate device can be in. More...
 
enum  ClimateAction : uint8_t {
  CLIMATE_ACTION_OFF = 0 , CLIMATE_ACTION_COOLING = 2 , CLIMATE_ACTION_HEATING = 3 , CLIMATE_ACTION_IDLE = 4 ,
  CLIMATE_ACTION_DRYING = 5 , CLIMATE_ACTION_FAN = 6
}
 Enum for the current action of the climate device. Values match those of ClimateMode. More...
 
enum  ClimateFanMode : uint8_t {
  CLIMATE_FAN_ON = 0 , CLIMATE_FAN_OFF = 1 , CLIMATE_FAN_AUTO = 2 , CLIMATE_FAN_LOW = 3 ,
  CLIMATE_FAN_MEDIUM = 4 , CLIMATE_FAN_HIGH = 5 , CLIMATE_FAN_MIDDLE = 6 , CLIMATE_FAN_FOCUS = 7 ,
  CLIMATE_FAN_DIFFUSE = 8 , CLIMATE_FAN_QUIET = 9
}
 NOTE: If adding values, update ClimateFanModeMask in climate_traits.h to use the new last value. More...
 
enum  ClimateSwingMode : uint8_t { CLIMATE_SWING_OFF = 0 , CLIMATE_SWING_BOTH = 1 , CLIMATE_SWING_VERTICAL = 2 , CLIMATE_SWING_HORIZONTAL = 3 }
 Enum for all modes a climate swing can be in NOTE: If adding values, update ClimateSwingModeMask in climate_traits.h to use the new last value. More...
 
enum  ClimatePreset : uint8_t {
  CLIMATE_PRESET_NONE = 0 , CLIMATE_PRESET_HOME = 1 , CLIMATE_PRESET_AWAY = 2 , CLIMATE_PRESET_BOOST = 3 ,
  CLIMATE_PRESET_COMFORT = 4 , CLIMATE_PRESET_ECO = 5 , CLIMATE_PRESET_SLEEP = 6 , CLIMATE_PRESET_ACTIVITY = 7
}
 Enum for all preset modes NOTE: If adding values, update ClimatePresetMask in climate_traits.h to use the new last value. More...
 
enum  ClimateFeature : uint32_t {
  CLIMATE_SUPPORTS_CURRENT_TEMPERATURE = 1 << 0 , CLIMATE_SUPPORTS_TWO_POINT_TARGET_TEMPERATURE = 1 << 1 , CLIMATE_REQUIRES_TWO_POINT_TARGET_TEMPERATURE = 1 << 2 , CLIMATE_SUPPORTS_CURRENT_HUMIDITY = 1 << 3 ,
  CLIMATE_SUPPORTS_TARGET_HUMIDITY = 1 << 4 , CLIMATE_SUPPORTS_ACTION = 1 << 5
}
 

Functions

template<typename T >
bool set_primary_mode (optional< T > &primary, const char *&custom_ptr, T value)
 Template helper for setting primary modes (fan_mode, preset) with mutual exclusion.
 
template<typename T >
bool set_custom_mode (const char *&custom_ptr, optional< T > &primary, const char *found_ptr, bool has_custom)
 Template helper for setting custom modes (custom_fan_mode_, custom_preset_) with mutual exclusion.
 
struct esphome::climate::ClimateDeviceRestoreState __attribute__ ((packed))
 
const LogString * climate_mode_to_string (ClimateMode mode)
 Convert the given ClimateMode to a human-readable string.
 
const LogString * climate_action_to_string (ClimateAction action)
 Convert the given ClimateAction to a human-readable string.
 
const LogString * climate_fan_mode_to_string (ClimateFanMode mode)
 Convert the given ClimateFanMode to a human-readable string.
 
const LogString * climate_swing_mode_to_string (ClimateSwingMode mode)
 Convert the given ClimateSwingMode to a human-readable string.
 
const LogString * climate_preset_to_string (ClimatePreset preset)
 Convert the given PresetMode to a human-readable string.
 
bool vector_contains (const std::vector< const char * > &vec, const char *value)
 
const char * vector_find (const std::vector< const char * > &vec, const char *value)
 

Variables

constexpr StringToUint8 CLIMATE_MODES_BY_STR []
 
constexpr StringToUint8 CLIMATE_FAN_MODES_BY_STR []
 
constexpr StringToUint8 CLIMATE_PRESETS_BY_STR []
 
constexpr StringToUint8 CLIMATE_SWING_MODES_BY_STR []
 
esphome::climate::Climate __attribute__
 

Typedef Documentation

◆ ClimateFanModeMask

◆ ClimateModeMask

◆ ClimatePresetMask

◆ ClimateSwingModeMask

Initial value:
FiniteSetMask<ClimateSwingMode, DefaultBitPolicy<ClimateSwingMode, CLIMATE_SWING_HORIZONTAL + 1>>

Definition at line 18 of file climate_traits.h.

Enumeration Type Documentation

◆ ClimateAction

Enum for the current action of the climate device. Values match those of ClimateMode.

Enumerator
CLIMATE_ACTION_OFF 

The climate device is off (inactive or no power)

CLIMATE_ACTION_COOLING 

The climate device is actively cooling.

CLIMATE_ACTION_HEATING 

The climate device is actively heating.

CLIMATE_ACTION_IDLE 

The climate device is idle (monitoring climate but no action needed)

CLIMATE_ACTION_DRYING 

The climate device is drying.

CLIMATE_ACTION_FAN 

The climate device is in fan only mode.

Definition at line 32 of file climate_mode.h.

◆ ClimateFanMode

NOTE: If adding values, update ClimateFanModeMask in climate_traits.h to use the new last value.

Enumerator
CLIMATE_FAN_ON 

The fan mode is set to On.

CLIMATE_FAN_OFF 

The fan mode is set to Off.

CLIMATE_FAN_AUTO 

The fan mode is set to Auto.

CLIMATE_FAN_LOW 

The fan mode is set to Low.

CLIMATE_FAN_MEDIUM 

The fan mode is set to Medium.

CLIMATE_FAN_HIGH 

The fan mode is set to High.

CLIMATE_FAN_MIDDLE 

The fan mode is set to Middle.

CLIMATE_FAN_FOCUS 

The fan mode is set to Focus.

CLIMATE_FAN_DIFFUSE 

The fan mode is set to Diffuse.

CLIMATE_FAN_QUIET 

The fan mode is set to Quiet.

Definition at line 48 of file climate_mode.h.

◆ ClimateFeature

Enumerator
CLIMATE_SUPPORTS_CURRENT_TEMPERATURE 
CLIMATE_SUPPORTS_TWO_POINT_TARGET_TEMPERATURE 
CLIMATE_REQUIRES_TWO_POINT_TARGET_TEMPERATURE 
CLIMATE_SUPPORTS_CURRENT_HUMIDITY 
CLIMATE_SUPPORTS_TARGET_HUMIDITY 
CLIMATE_SUPPORTS_ACTION 

Definition at line 105 of file climate_mode.h.

◆ ClimateMode

Enum for all modes a climate device can be in.

NOTE: If adding values, update ClimateModeMask in climate_traits.h to use the new last value

Enumerator
CLIMATE_MODE_OFF 

The climate device is off.

CLIMATE_MODE_HEAT_COOL 

The climate device is set to heat/cool to reach the target temperature.

CLIMATE_MODE_COOL 

The climate device is set to cool to reach the target temperature.

CLIMATE_MODE_HEAT 

The climate device is set to heat to reach the target temperature.

CLIMATE_MODE_FAN_ONLY 

The climate device only has the fan enabled, no heating or cooling is taking place.

CLIMATE_MODE_DRY 

The climate device is set to dry/humidity mode.

CLIMATE_MODE_AUTO 

The climate device is adjusting the temperature dynamically.

For example, the target temperature can be adjusted based on a schedule, or learned behavior. The target temperature can't be adjusted when in this mode.

Definition at line 11 of file climate_mode.h.

◆ ClimatePreset

Enum for all preset modes NOTE: If adding values, update ClimatePresetMask in climate_traits.h to use the new last value.

Enumerator
CLIMATE_PRESET_NONE 

No preset is active.

CLIMATE_PRESET_HOME 

Device is in home preset.

CLIMATE_PRESET_AWAY 

Device is in away preset.

CLIMATE_PRESET_BOOST 

Device is in boost preset.

CLIMATE_PRESET_COMFORT 

Device is in comfort preset.

CLIMATE_PRESET_ECO 

Device is running an energy-saving preset.

CLIMATE_PRESET_SLEEP 

Device is prepared for sleep.

CLIMATE_PRESET_ACTIVITY 

Device is reacting to activity (e.g., movement sensors)

Definition at line 86 of file climate_mode.h.

◆ ClimateSwingMode

Enum for all modes a climate swing can be in NOTE: If adding values, update ClimateSwingModeMask in climate_traits.h to use the new last value.

Enumerator
CLIMATE_SWING_OFF 

The swing mode is set to Off.

CLIMATE_SWING_BOTH 

The fan mode is set to Both.

CLIMATE_SWING_VERTICAL 

The fan mode is set to Vertical.

CLIMATE_SWING_HORIZONTAL 

The fan mode is set to Horizontal.

Definition at line 73 of file climate_mode.h.

Function Documentation

◆ __attribute__()

struct esphome::climate::ClimateDeviceRestoreState esphome::climate::__attribute__ ( (packed) )

◆ climate_action_to_string()

const LogString * esphome::climate::climate_action_to_string ( ClimateAction action)

Convert the given ClimateAction to a human-readable string.

Definition at line 26 of file climate_mode.cpp.

◆ climate_fan_mode_to_string()

const LogString * esphome::climate::climate_fan_mode_to_string ( ClimateFanMode fan_mode)

Convert the given ClimateFanMode to a human-readable string.

Definition at line 45 of file climate_mode.cpp.

◆ climate_mode_to_string()

const LogString * esphome::climate::climate_mode_to_string ( ClimateMode mode)

Convert the given ClimateMode to a human-readable string.

Definition at line 6 of file climate_mode.cpp.

◆ climate_preset_to_string()

const LogString * esphome::climate::climate_preset_to_string ( ClimatePreset preset)

Convert the given PresetMode to a human-readable string.

Definition at line 87 of file climate_mode.cpp.

◆ climate_swing_mode_to_string()

const LogString * esphome::climate::climate_swing_mode_to_string ( ClimateSwingMode swing_mode)

Convert the given ClimateSwingMode to a human-readable string.

Definition at line 72 of file climate_mode.cpp.

◆ set_custom_mode()

template<typename T >
bool esphome::climate::set_custom_mode ( const char *& custom_ptr,
optional< T > & primary,
const char * found_ptr,
bool has_custom )

Template helper for setting custom modes (custom_fan_mode_, custom_preset_) with mutual exclusion.

This helper ensures setting a custom mode automatically clears its corresponding primary mode. It also validates that the custom mode exists in the device's supported modes (lifetime safety).

Example state transitions: Before: fan_mode=CLIMATE_FAN_HIGH, custom_fan_mode_=nullptr Call: set_custom_fan_mode_("Turbo") After: fan_mode=nullopt, custom_fan_mode_="Turbo" (pointer from traits)

Lifetime Safety:

  • found_ptr must come from traits.find_custom_*_mode_()
  • Only pointers found in traits are stored, ensuring they remain valid
  • Prevents dangling pointers from temporary strings
Parameters
custom_ptrReference to the custom mode pointer to set
primaryThe primary mode optional to clear
found_ptrThe validated pointer from traits (nullptr if not found)
has_customWhether a custom mode is currently active
Returns
true if state changed, false otherwise

Definition at line 646 of file climate.cpp.

◆ set_primary_mode()

template<typename T >
bool esphome::climate::set_primary_mode ( optional< T > & primary,
const char *& custom_ptr,
T value )

Template helper for setting primary modes (fan_mode, preset) with mutual exclusion.

Climate devices have mutually exclusive mode pairs:

  • fan_mode (enum) vs custom_fan_mode_ (const char*)
  • preset (enum) vs custom_preset_ (const char*)

Only one mode in each pair can be active at a time. This helper ensures setting a primary mode automatically clears its corresponding custom mode.

Example state transitions: Before: custom_fan_mode_="Turbo", fan_mode=nullopt Call: set_fan_mode_(CLIMATE_FAN_HIGH) After: custom_fan_mode_=nullptr, fan_mode=CLIMATE_FAN_HIGH

Parameters
primaryThe primary mode optional (fan_mode or preset)
custom_ptrReference to the custom mode pointer (custom_fan_mode_ or custom_preset_)
valueThe new primary mode value to set
Returns
true if state changed, false if already set to this value

Definition at line 612 of file climate.cpp.

◆ vector_contains()

bool esphome::climate::vector_contains ( const std::vector< const char * > & vec,
const char * value )
inline

Definition at line 24 of file climate_traits.h.

◆ vector_find()

const char * esphome::climate::vector_find ( const std::vector< const char * > & vec,
const char * value )
inline

Definition at line 33 of file climate_traits.h.

Variable Documentation

◆ __attribute__

esphome::climate::Climate esphome::climate::__attribute__

◆ CLIMATE_FAN_MODES_BY_STR

StringToUint8 esphome::climate::CLIMATE_FAN_MODES_BY_STR[]
constexpr
Initial value:
= {
{"ON", CLIMATE_FAN_ON}, {"OFF", CLIMATE_FAN_OFF}, {"AUTO", CLIMATE_FAN_AUTO},
{"LOW", CLIMATE_FAN_LOW}, {"MEDIUM", CLIMATE_FAN_MEDIUM}, {"HIGH", CLIMATE_FAN_HIGH},
{"MIDDLE", CLIMATE_FAN_MIDDLE}, {"FOCUS", CLIMATE_FAN_FOCUS}, {"DIFFUSE", CLIMATE_FAN_DIFFUSE},
{"QUIET", CLIMATE_FAN_QUIET},
}

Definition at line 27 of file climate.cpp.

◆ CLIMATE_MODES_BY_STR

StringToUint8 esphome::climate::CLIMATE_MODES_BY_STR[]
constexpr
Initial value:
= {
{"OFF", CLIMATE_MODE_OFF},
{"AUTO", CLIMATE_MODE_AUTO},
{"COOL", CLIMATE_MODE_COOL},
{"HEAT", CLIMATE_MODE_HEAT},
{"FAN_ONLY", CLIMATE_MODE_FAN_ONLY},
{"DRY", CLIMATE_MODE_DRY},
{"HEAT_COOL", CLIMATE_MODE_HEAT_COOL},
}

Definition at line 17 of file climate.cpp.

◆ CLIMATE_PRESETS_BY_STR

StringToUint8 esphome::climate::CLIMATE_PRESETS_BY_STR[]
constexpr
Initial value:
= {
{"ECO", CLIMATE_PRESET_ECO}, {"AWAY", CLIMATE_PRESET_AWAY}, {"BOOST", CLIMATE_PRESET_BOOST},
{"COMFORT", CLIMATE_PRESET_COMFORT}, {"HOME", CLIMATE_PRESET_HOME}, {"SLEEP", CLIMATE_PRESET_SLEEP},
{"ACTIVITY", CLIMATE_PRESET_ACTIVITY}, {"NONE", CLIMATE_PRESET_NONE},
}

Definition at line 34 of file climate.cpp.

◆ CLIMATE_SWING_MODES_BY_STR

StringToUint8 esphome::climate::CLIMATE_SWING_MODES_BY_STR[]
constexpr
Initial value:
= {
{"OFF", CLIMATE_SWING_OFF},
{"BOTH", CLIMATE_SWING_BOTH},
{"VERTICAL", CLIMATE_SWING_VERTICAL},
{"HORIZONTAL", CLIMATE_SWING_HORIZONTAL},
}

Definition at line 40 of file climate.cpp.