ESPHome 2026.3.0-dev
Loading...
Searching...
No Matches
mqtt_climate.cpp
Go to the documentation of this file.
1#include "mqtt_climate.h"
2#include "esphome/core/log.h"
4
5#include "mqtt_const.h"
6
7#ifdef USE_MQTT
8#ifdef USE_CLIMATE
9
10namespace esphome::mqtt {
11
12static const char *const TAG = "mqtt.climate";
13
14using namespace esphome::climate;
15
16// Climate mode MQTT strings indexed by ClimateMode enum (0-6): OFF, HEAT_COOL, COOL, HEAT, FAN_ONLY, DRY, AUTO
17PROGMEM_STRING_TABLE(ClimateMqttModeStrings, "off", "heat_cool", "cool", "heat", "fan_only", "dry", "auto", "unknown");
18
19static ProgmemStr climate_mode_to_mqtt_str(ClimateMode mode) {
20 return ClimateMqttModeStrings::get_progmem_str(static_cast<uint8_t>(mode), ClimateMqttModeStrings::LAST_INDEX);
21}
22
23// Climate action MQTT strings indexed by ClimateAction enum (0,2-7): OFF, (gap), COOLING, HEATING, IDLE, DRYING, FAN,
24// DEFROSTING
25PROGMEM_STRING_TABLE(ClimateMqttActionStrings, "off", "unknown", "cooling", "heating", "idle", "drying", "fan",
26 "defrosting", "unknown");
27
28static ProgmemStr climate_action_to_mqtt_str(ClimateAction action) {
29 return ClimateMqttActionStrings::get_progmem_str(static_cast<uint8_t>(action), ClimateMqttActionStrings::LAST_INDEX);
30}
31
32// Climate fan mode MQTT strings indexed by ClimateFanMode enum (0-9)
33PROGMEM_STRING_TABLE(ClimateMqttFanModeStrings, "on", "off", "auto", "low", "medium", "high", "middle", "focus",
34 "diffuse", "quiet", "unknown");
35
36static ProgmemStr climate_fan_mode_to_mqtt_str(ClimateFanMode fan_mode) {
37 return ClimateMqttFanModeStrings::get_progmem_str(static_cast<uint8_t>(fan_mode),
38 ClimateMqttFanModeStrings::LAST_INDEX);
39}
40
41// Climate swing mode MQTT strings indexed by ClimateSwingMode enum (0-3): OFF, BOTH, VERTICAL, HORIZONTAL
42PROGMEM_STRING_TABLE(ClimateMqttSwingModeStrings, "off", "both", "vertical", "horizontal", "unknown");
43
44static ProgmemStr climate_swing_mode_to_mqtt_str(ClimateSwingMode swing_mode) {
45 return ClimateMqttSwingModeStrings::get_progmem_str(static_cast<uint8_t>(swing_mode),
46 ClimateMqttSwingModeStrings::LAST_INDEX);
47}
48
49// Climate preset MQTT strings indexed by ClimatePreset enum (0-7)
50PROGMEM_STRING_TABLE(ClimateMqttPresetStrings, "none", "home", "away", "boost", "comfort", "eco", "sleep", "activity",
51 "unknown");
52
53static ProgmemStr climate_preset_to_mqtt_str(ClimatePreset preset) {
54 return ClimateMqttPresetStrings::get_progmem_str(static_cast<uint8_t>(preset), ClimateMqttPresetStrings::LAST_INDEX);
55}
56
58 // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks) false positive with ArduinoJson
59 auto traits = this->device_->get_traits();
60 // current_temperature_topic
61 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_TEMPERATURE)) {
62 root[MQTT_CURRENT_TEMPERATURE_TOPIC] = this->get_current_temperature_state_topic();
63 }
64 // current_humidity_topic
65 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_HUMIDITY)) {
66 root[MQTT_CURRENT_HUMIDITY_TOPIC] = this->get_current_humidity_state_topic();
67 }
68 // mode_command_topic
69 root[MQTT_MODE_COMMAND_TOPIC] = this->get_mode_command_topic();
70 // mode_state_topic
71 root[MQTT_MODE_STATE_TOPIC] = this->get_mode_state_topic();
72 // modes
73 JsonArray modes = root[MQTT_MODES].to<JsonArray>();
74 // sort array for nice UI in HA
75 if (traits.supports_mode(CLIMATE_MODE_AUTO))
76 modes.add(ESPHOME_F("auto"));
77 modes.add(ESPHOME_F("off"));
78 if (traits.supports_mode(CLIMATE_MODE_COOL))
79 modes.add(ESPHOME_F("cool"));
80 if (traits.supports_mode(CLIMATE_MODE_HEAT))
81 modes.add(ESPHOME_F("heat"));
82 if (traits.supports_mode(CLIMATE_MODE_FAN_ONLY))
83 modes.add(ESPHOME_F("fan_only"));
84 if (traits.supports_mode(CLIMATE_MODE_DRY))
85 modes.add(ESPHOME_F("dry"));
86 if (traits.supports_mode(CLIMATE_MODE_HEAT_COOL))
87 modes.add(ESPHOME_F("heat_cool"));
88
91 // temperature_low_command_topic
92 root[MQTT_TEMPERATURE_LOW_COMMAND_TOPIC] = this->get_target_temperature_low_command_topic();
93 // temperature_low_state_topic
94 root[MQTT_TEMPERATURE_LOW_STATE_TOPIC] = this->get_target_temperature_low_state_topic();
95 // temperature_high_command_topic
96 root[MQTT_TEMPERATURE_HIGH_COMMAND_TOPIC] = this->get_target_temperature_high_command_topic();
97 // temperature_high_state_topic
98 root[MQTT_TEMPERATURE_HIGH_STATE_TOPIC] = this->get_target_temperature_high_state_topic();
99 } else {
100 // temperature_command_topic
101 root[MQTT_TEMPERATURE_COMMAND_TOPIC] = this->get_target_temperature_command_topic();
102 // temperature_state_topic
103 root[MQTT_TEMPERATURE_STATE_TOPIC] = this->get_target_temperature_state_topic();
104 }
105
106 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_TARGET_HUMIDITY)) {
107 // target_humidity_command_topic
108 root[MQTT_TARGET_HUMIDITY_COMMAND_TOPIC] = this->get_target_humidity_command_topic();
109 // target_humidity_state_topic
110 root[MQTT_TARGET_HUMIDITY_STATE_TOPIC] = this->get_target_humidity_state_topic();
111 }
112
113 // min_temp
114 root[MQTT_MIN_TEMP] = traits.get_visual_min_temperature();
115 // max_temp
116 root[MQTT_MAX_TEMP] = traits.get_visual_max_temperature();
117 // target_temp_step
118 root[MQTT_TARGET_TEMPERATURE_STEP] = roundf(traits.get_visual_target_temperature_step() * 10) * 0.1;
119 // current_temp_step
120 root[MQTT_CURRENT_TEMPERATURE_STEP] = roundf(traits.get_visual_current_temperature_step() * 10) * 0.1;
121 // temperature units are always coerced to Celsius internally
122 root[MQTT_TEMPERATURE_UNIT] = "C";
123
124 // min_humidity
125 root[MQTT_MIN_HUMIDITY] = traits.get_visual_min_humidity();
126 // max_humidity
127 root[MQTT_MAX_HUMIDITY] = traits.get_visual_max_humidity();
128
129 if (traits.get_supports_presets() || !traits.get_supported_custom_presets().empty()) {
130 // preset_mode_command_topic
131 root[MQTT_PRESET_MODE_COMMAND_TOPIC] = this->get_preset_command_topic();
132 // preset_mode_state_topic
133 root[MQTT_PRESET_MODE_STATE_TOPIC] = this->get_preset_state_topic();
134 // presets
135 JsonArray presets = root[ESPHOME_F("preset_modes")].to<JsonArray>();
136 if (traits.supports_preset(CLIMATE_PRESET_HOME))
137 presets.add(ESPHOME_F("home"));
138 if (traits.supports_preset(CLIMATE_PRESET_AWAY))
139 presets.add(ESPHOME_F("away"));
140 if (traits.supports_preset(CLIMATE_PRESET_BOOST))
141 presets.add(ESPHOME_F("boost"));
142 if (traits.supports_preset(CLIMATE_PRESET_COMFORT))
143 presets.add(ESPHOME_F("comfort"));
144 if (traits.supports_preset(CLIMATE_PRESET_ECO))
145 presets.add(ESPHOME_F("eco"));
146 if (traits.supports_preset(CLIMATE_PRESET_SLEEP))
147 presets.add(ESPHOME_F("sleep"));
148 if (traits.supports_preset(CLIMATE_PRESET_ACTIVITY))
149 presets.add(ESPHOME_F("activity"));
150 for (const auto &preset : traits.get_supported_custom_presets())
151 presets.add(preset);
152 }
153
154 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_ACTION)) {
155 // action_topic
156 root[MQTT_ACTION_TOPIC] = this->get_action_state_topic();
157 }
158
159 if (traits.get_supports_fan_modes()) {
160 // fan_mode_command_topic
161 root[MQTT_FAN_MODE_COMMAND_TOPIC] = this->get_fan_mode_command_topic();
162 // fan_mode_state_topic
163 root[MQTT_FAN_MODE_STATE_TOPIC] = this->get_fan_mode_state_topic();
164 // fan_modes
165 JsonArray fan_modes = root[ESPHOME_F("fan_modes")].to<JsonArray>();
166 if (traits.supports_fan_mode(CLIMATE_FAN_ON))
167 fan_modes.add(ESPHOME_F("on"));
168 if (traits.supports_fan_mode(CLIMATE_FAN_OFF))
169 fan_modes.add(ESPHOME_F("off"));
170 if (traits.supports_fan_mode(CLIMATE_FAN_AUTO))
171 fan_modes.add(ESPHOME_F("auto"));
172 if (traits.supports_fan_mode(CLIMATE_FAN_LOW))
173 fan_modes.add(ESPHOME_F("low"));
174 if (traits.supports_fan_mode(CLIMATE_FAN_MEDIUM))
175 fan_modes.add(ESPHOME_F("medium"));
176 if (traits.supports_fan_mode(CLIMATE_FAN_HIGH))
177 fan_modes.add(ESPHOME_F("high"));
178 if (traits.supports_fan_mode(CLIMATE_FAN_MIDDLE))
179 fan_modes.add(ESPHOME_F("middle"));
180 if (traits.supports_fan_mode(CLIMATE_FAN_FOCUS))
181 fan_modes.add(ESPHOME_F("focus"));
182 if (traits.supports_fan_mode(CLIMATE_FAN_DIFFUSE))
183 fan_modes.add(ESPHOME_F("diffuse"));
184 if (traits.supports_fan_mode(CLIMATE_FAN_QUIET))
185 fan_modes.add(ESPHOME_F("quiet"));
186 for (const auto &fan_mode : traits.get_supported_custom_fan_modes())
187 fan_modes.add(fan_mode);
188 }
189
190 if (traits.get_supports_swing_modes()) {
191 // swing_mode_command_topic
192 root[MQTT_SWING_MODE_COMMAND_TOPIC] = this->get_swing_mode_command_topic();
193 // swing_mode_state_topic
194 root[MQTT_SWING_MODE_STATE_TOPIC] = this->get_swing_mode_state_topic();
195 // swing_modes
196 JsonArray swing_modes = root[ESPHOME_F("swing_modes")].to<JsonArray>();
197 if (traits.supports_swing_mode(CLIMATE_SWING_OFF))
198 swing_modes.add(ESPHOME_F("off"));
199 if (traits.supports_swing_mode(CLIMATE_SWING_BOTH))
200 swing_modes.add(ESPHOME_F("both"));
201 if (traits.supports_swing_mode(CLIMATE_SWING_VERTICAL))
202 swing_modes.add(ESPHOME_F("vertical"));
203 if (traits.supports_swing_mode(CLIMATE_SWING_HORIZONTAL))
204 swing_modes.add(ESPHOME_F("horizontal"));
205 }
206
207 config.state_topic = false;
208 config.command_topic = false;
209 // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
210}
212 auto traits = this->device_->get_traits();
213 this->subscribe(this->get_mode_command_topic(), [this](const std::string &topic, const std::string &payload) {
214 auto call = this->device_->make_call();
215 call.set_mode(payload);
216 call.perform();
217 });
218
219 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_TWO_POINT_TARGET_TEMPERATURE |
221 this->subscribe(this->get_target_temperature_low_command_topic(),
222 [this](const std::string &topic, const std::string &payload) {
223 auto val = parse_number<float>(payload);
224 if (!val.has_value()) {
225 ESP_LOGW(TAG, "Can't convert '%s' to number!", payload.c_str());
226 return;
227 }
228 auto call = this->device_->make_call();
230 call.perform();
231 });
232 this->subscribe(this->get_target_temperature_high_command_topic(),
233 [this](const std::string &topic, const std::string &payload) {
234 auto val = parse_number<float>(payload);
235 if (!val.has_value()) {
236 ESP_LOGW(TAG, "Can't convert '%s' to number!", payload.c_str());
237 return;
238 }
239 auto call = this->device_->make_call();
241 call.perform();
242 });
243 } else {
244 this->subscribe(this->get_target_temperature_command_topic(),
245 [this](const std::string &topic, const std::string &payload) {
246 auto val = parse_number<float>(payload);
247 if (!val.has_value()) {
248 ESP_LOGW(TAG, "Can't convert '%s' to number!", payload.c_str());
249 return;
250 }
251 auto call = this->device_->make_call();
253 call.perform();
254 });
255 }
256
257 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_TARGET_HUMIDITY)) {
258 this->subscribe(this->get_target_humidity_command_topic(),
259 [this](const std::string &topic, const std::string &payload) {
260 auto val = parse_number<float>(payload);
261 if (!val.has_value()) {
262 ESP_LOGW(TAG, "Can't convert '%s' to number!", payload.c_str());
263 return;
264 }
265 auto call = this->device_->make_call();
267 call.perform();
268 });
269 }
270
271 if (traits.get_supports_presets() || !traits.get_supported_custom_presets().empty()) {
272 this->subscribe(this->get_preset_command_topic(), [this](const std::string &topic, const std::string &payload) {
273 auto call = this->device_->make_call();
274 call.set_preset(payload);
275 call.perform();
276 });
277 }
278
279 if (traits.get_supports_fan_modes()) {
280 this->subscribe(this->get_fan_mode_command_topic(), [this](const std::string &topic, const std::string &payload) {
281 auto call = this->device_->make_call();
282 call.set_fan_mode(payload);
283 call.perform();
284 });
285 }
286
287 if (traits.get_supports_swing_modes()) {
288 this->subscribe(this->get_swing_mode_command_topic(), [this](const std::string &topic, const std::string &payload) {
289 auto call = this->device_->make_call();
290 call.set_swing_mode(payload);
291 call.perform();
292 });
293 }
294
295 this->device_->add_on_state_callback([this](Climate & /*unused*/) { this->publish_state_(); });
296}
300const EntityBase *MQTTClimateComponent::get_entity() const { return this->device_; }
301
303 auto traits = this->device_->get_traits();
304 // Reusable stack buffer for topic construction (avoids heap allocation per publish)
305 char topic_buf[MQTT_DEFAULT_TOPIC_MAX_LEN];
306 // mode
307 bool success = true;
308 if (!this->publish(this->get_mode_state_topic_to(topic_buf), climate_mode_to_mqtt_str(this->device_->mode)))
309 success = false;
310 int8_t target_accuracy = traits.get_target_temperature_accuracy_decimals();
311 int8_t current_accuracy = traits.get_current_temperature_accuracy_decimals();
312 char payload[VALUE_ACCURACY_MAX_LEN];
313 size_t len;
314 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_TEMPERATURE) &&
315 !std::isnan(this->device_->current_temperature)) {
316 len = value_accuracy_to_buf(payload, this->device_->current_temperature, current_accuracy);
317 if (!this->publish(this->get_current_temperature_state_topic_to(topic_buf), payload, len))
318 success = false;
319 }
320 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_TWO_POINT_TARGET_TEMPERATURE |
322 len = value_accuracy_to_buf(payload, this->device_->target_temperature_low, target_accuracy);
323 if (!this->publish(this->get_target_temperature_low_state_topic_to(topic_buf), payload, len))
324 success = false;
325 len = value_accuracy_to_buf(payload, this->device_->target_temperature_high, target_accuracy);
326 if (!this->publish(this->get_target_temperature_high_state_topic_to(topic_buf), payload, len))
327 success = false;
328 } else {
329 len = value_accuracy_to_buf(payload, this->device_->target_temperature, target_accuracy);
330 if (!this->publish(this->get_target_temperature_state_topic_to(topic_buf), payload, len))
331 success = false;
332 }
333
334 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_HUMIDITY) &&
335 !std::isnan(this->device_->current_humidity)) {
337 if (!this->publish(this->get_current_humidity_state_topic_to(topic_buf), payload, len))
338 success = false;
339 }
340 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_TARGET_HUMIDITY) &&
341 !std::isnan(this->device_->target_humidity)) {
342 len = value_accuracy_to_buf(payload, this->device_->target_humidity, 0);
343 if (!this->publish(this->get_target_humidity_state_topic_to(topic_buf), payload, len))
344 success = false;
345 }
346
347 if (traits.get_supports_presets() || !traits.get_supported_custom_presets().empty()) {
348 if (this->device_->has_custom_preset()) {
349 if (!this->publish(this->get_preset_state_topic_to(topic_buf), this->device_->get_custom_preset().c_str()))
350 success = false;
351 } else if (this->device_->preset.has_value()) {
352 if (!this->publish(this->get_preset_state_topic_to(topic_buf),
353 climate_preset_to_mqtt_str(this->device_->preset.value())))
354 success = false;
355 } else if (!this->publish(this->get_preset_state_topic_to(topic_buf), "")) {
356 success = false;
357 }
358 }
359
360 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_ACTION)) {
361 if (!this->publish(this->get_action_state_topic_to(topic_buf), climate_action_to_mqtt_str(this->device_->action)))
362 success = false;
363 }
364
365 if (traits.get_supports_fan_modes()) {
366 if (this->device_->has_custom_fan_mode()) {
367 if (!this->publish(this->get_fan_mode_state_topic_to(topic_buf), this->device_->get_custom_fan_mode().c_str()))
368 success = false;
369 } else if (this->device_->fan_mode.has_value()) {
370 if (!this->publish(this->get_fan_mode_state_topic_to(topic_buf),
371 climate_fan_mode_to_mqtt_str(this->device_->fan_mode.value())))
372 success = false;
373 } else if (!this->publish(this->get_fan_mode_state_topic_to(topic_buf), "")) {
374 success = false;
375 }
376 }
377
378 if (traits.get_supports_swing_modes()) {
379 if (!this->publish(this->get_swing_mode_state_topic_to(topic_buf),
380 climate_swing_mode_to_mqtt_str(this->device_->swing_mode)))
381 success = false;
382 }
383
384 return success;
385}
386
387} // namespace esphome::mqtt
388
389#endif
390#endif // USE_MQTT
BedjetMode mode
BedJet operating mode.
constexpr const char * c_str() const
Definition string_ref.h:73
ClimateCall & set_target_temperature(float target_temperature)
Set the target temperature of the climate device.
Definition climate.cpp:287
ClimateCall & set_swing_mode(ClimateSwingMode swing_mode)
Set the swing mode of the climate device.
Definition climate.cpp:266
ClimateCall & set_target_temperature_low(float target_temperature_low)
Set the low point target temperature of the climate device.
Definition climate.cpp:292
ClimateCall & set_preset(ClimatePreset preset)
Set the preset of the climate device.
Definition climate.cpp:228
ClimateCall & set_fan_mode(ClimateFanMode fan_mode)
Set the fan mode of the climate device.
Definition climate.cpp:190
ClimateCall & set_target_humidity(float target_humidity)
Set the target humidity of the climate device.
Definition climate.cpp:302
ClimateCall & set_target_temperature_high(float target_temperature_high)
Set the high point target temperature of the climate device.
Definition climate.cpp:297
ClimateCall & set_mode(ClimateMode mode)
Set the mode of the climate device.
Definition climate.cpp:171
ClimateDevice - This is the base class for all climate integrations.
Definition climate.h:186
ClimateMode mode
The active mode of the climate device.
Definition climate.h:266
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
Definition climate.h:260
ClimateTraits get_traits()
Get the traits of this climate device with all overrides applied.
Definition climate.cpp:494
float target_temperature
The target temperature of the climate device.
Definition climate.h:247
float current_humidity
The current humidity of the climate device, as reported from the integration.
Definition climate.h:243
ClimateSwingMode swing_mode
The active swing mode of the climate device.
Definition climate.h:272
float target_temperature_low
The minimum target temperature of the climate device, for climate devices with split target temperatu...
Definition climate.h:250
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 (us...
Definition climate.cpp:359
bool has_custom_preset() const
Check if a custom preset is currently active.
Definition climate.h:237
float current_temperature
The current temperature of the climate device, as reported from the integration.
Definition climate.h:240
ClimateAction action
The active state of the climate device.
Definition climate.h:269
ClimateCall make_call()
Make a climate device control call, this is used to control the climate device, see the ClimateCall d...
Definition climate.cpp:540
StringRef get_custom_preset() const
Get the active custom preset (read-only access). Returns StringRef.
Definition climate.h:278
bool has_custom_fan_mode() const
Check if a custom fan mode is currently active.
Definition climate.h:234
optional< ClimatePreset > preset
The active preset of the climate device.
Definition climate.h:263
float target_humidity
The target humidity of the climate device.
Definition climate.h:257
float target_temperature_high
The maximum target temperature of the climate device, for climate devices with split target temperatu...
Definition climate.h:252
StringRef get_custom_fan_mode() const
Get the active custom fan mode (read-only access). Returns StringRef.
Definition climate.h:275
int8_t get_target_temperature_accuracy_decimals() const
MQTTClimateComponent(climate::Climate *device)
state command command command command command command state state state MQTT_COMPONENT_CUSTOM_TOPIC(preset, command) protected bool publish_state_()
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
bool publish(const std::string &topic, const std::string &payload)
Send a MQTT message.
void subscribe(const std::string &topic, mqtt_callback_t callback, uint8_t qos=0)
Subscribe to a MQTT topic.
bool has_value() const
Definition optional.h:92
value_type const & value() const
Definition optional.h:94
ClimateSwingMode swing_mode
Definition climate.h:11
ClimateFanMode fan_mode
Definition climate.h:3
ClimatePreset preset
Definition climate.h:8
mopeka_std_values val[4]
PROGMEM_STRING_TABLE(AlarmControlPanelStateStrings, "DISARMED", "ARMED_HOME", "ARMED_AWAY", "ARMED_NIGHT", "ARMED_VACATION", "ARMED_CUSTOM_BYPASS", "PENDING", "ARMING", "DISARMING", "TRIGGERED", "UNKNOWN")
@ CLIMATE_SUPPORTS_CURRENT_HUMIDITY
@ CLIMATE_SUPPORTS_TWO_POINT_TARGET_TEMPERATURE
@ CLIMATE_SUPPORTS_CURRENT_TEMPERATURE
@ CLIMATE_REQUIRES_TWO_POINT_TARGET_TEMPERATURE
ClimatePreset
Enum for all preset modes NOTE: If adding values, update ClimatePresetMask in climate_traits....
@ CLIMATE_PRESET_COMFORT
Device is in comfort preset.
@ CLIMATE_PRESET_AWAY
Device is in away preset.
@ CLIMATE_PRESET_BOOST
Device is in boost preset.
@ CLIMATE_PRESET_ACTIVITY
Device is reacting to activity (e.g., movement sensors)
@ CLIMATE_PRESET_SLEEP
Device is prepared for sleep.
@ CLIMATE_PRESET_HOME
Device is in home preset.
@ CLIMATE_PRESET_ECO
Device is running an energy-saving preset.
ClimateSwingMode
Enum for all modes a climate swing can be in NOTE: If adding values, update ClimateSwingModeMask in c...
@ CLIMATE_SWING_OFF
The swing mode is set to Off.
@ CLIMATE_SWING_HORIZONTAL
The fan mode is set to Horizontal.
@ CLIMATE_SWING_VERTICAL
The fan mode is set to Vertical.
@ CLIMATE_SWING_BOTH
The fan mode is set to Both.
ClimateMode
Enum for all modes a climate device can be in.
@ CLIMATE_MODE_DRY
The climate device is set to dry/humidity mode.
@ CLIMATE_MODE_FAN_ONLY
The climate device only has the fan enabled, no heating or cooling is taking place.
@ CLIMATE_MODE_HEAT
The climate device is set to heat to reach the target temperature.
@ CLIMATE_MODE_COOL
The climate device is set to cool to reach the target temperature.
@ CLIMATE_MODE_HEAT_COOL
The climate device is set to heat/cool to reach the target temperature.
@ CLIMATE_MODE_AUTO
The climate device is adjusting the temperature dynamically.
ClimateAction
Enum for the current action of the climate device. Values match those of ClimateMode.
ClimateFanMode
NOTE: If adding values, update ClimateFanModeMask in climate_traits.h to use the new last value.
@ CLIMATE_FAN_MEDIUM
The fan mode is set to Medium.
@ CLIMATE_FAN_DIFFUSE
The fan mode is set to Diffuse.
@ CLIMATE_FAN_ON
The fan mode is set to On.
@ CLIMATE_FAN_AUTO
The fan mode is set to Auto.
@ CLIMATE_FAN_FOCUS
The fan mode is set to Focus.
@ CLIMATE_FAN_LOW
The fan mode is set to Low.
@ CLIMATE_FAN_MIDDLE
The fan mode is set to Middle.
@ CLIMATE_FAN_QUIET
The fan mode is set to Quiet.
@ CLIMATE_FAN_OFF
The fan mode is set to Off.
@ CLIMATE_FAN_HIGH
The fan mode is set to High.
MQTT_COMPONENT_TYPE(MQTTAlarmControlPanelComponent, "alarm_control_panel") const EntityBase *MQTTAlarmControlPanelComponent
size_t value_accuracy_to_buf(std::span< char, VALUE_ACCURACY_MAX_LEN > buf, float value, int8_t accuracy_decimals)
Format value with accuracy to buffer, returns chars written (excluding null)
Definition helpers.cpp:490
std::string size_t len
Definition helpers.h:817
optional< T > parse_number(const char *str)
Parse an unsigned decimal number from a null-terminated string.
Definition helpers.h:910
const __FlashStringHelper * ProgmemStr
Definition progmem.h:26
Simple Helper struct used for Home Assistant MQTT send_discovery().
bool command_topic
If the command topic should be included. Default to true.
bool state_topic
If the state topic should be included. Defaults to true.