ESPHome 2026.10.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.1f;
119 // current_temp_step
120 root[MQTT_CURRENT_TEMPERATURE_STEP] = roundf(traits.get_visual_current_temperature_step() * 10) * 0.1f;
121 root[MQTT_TEMPERATURE_UNIT] = traits.get_temperature_unit() == TemperatureUnit::FAHRENHEIT ? "F" : "C";
122
123 // min_humidity
124 root[MQTT_MIN_HUMIDITY] = traits.get_visual_min_humidity();
125 // max_humidity
126 root[MQTT_MAX_HUMIDITY] = traits.get_visual_max_humidity();
127
128 if (traits.get_supports_presets() || !traits.get_supported_custom_presets().empty()) {
129 // preset_mode_command_topic
130 root[MQTT_PRESET_MODE_COMMAND_TOPIC] = this->get_preset_command_topic();
131 // preset_mode_state_topic
132 root[MQTT_PRESET_MODE_STATE_TOPIC] = this->get_preset_state_topic();
133 // presets
134 JsonArray presets = root[ESPHOME_F("preset_modes")].to<JsonArray>();
135 if (traits.supports_preset(CLIMATE_PRESET_HOME))
136 presets.add(ESPHOME_F("home"));
137 if (traits.supports_preset(CLIMATE_PRESET_AWAY))
138 presets.add(ESPHOME_F("away"));
139 if (traits.supports_preset(CLIMATE_PRESET_BOOST))
140 presets.add(ESPHOME_F("boost"));
141 if (traits.supports_preset(CLIMATE_PRESET_COMFORT))
142 presets.add(ESPHOME_F("comfort"));
143 if (traits.supports_preset(CLIMATE_PRESET_ECO))
144 presets.add(ESPHOME_F("eco"));
145 if (traits.supports_preset(CLIMATE_PRESET_SLEEP))
146 presets.add(ESPHOME_F("sleep"));
147 if (traits.supports_preset(CLIMATE_PRESET_ACTIVITY))
148 presets.add(ESPHOME_F("activity"));
149 for (const auto &preset : traits.get_supported_custom_presets())
150 presets.add(preset);
151 }
152
153 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_ACTION)) {
154 // action_topic
155 root[MQTT_ACTION_TOPIC] = this->get_action_state_topic();
156 }
157
158 if (traits.get_supports_fan_modes()) {
159 // fan_mode_command_topic
160 root[MQTT_FAN_MODE_COMMAND_TOPIC] = this->get_fan_mode_command_topic();
161 // fan_mode_state_topic
162 root[MQTT_FAN_MODE_STATE_TOPIC] = this->get_fan_mode_state_topic();
163 // fan_modes
164 JsonArray fan_modes = root[ESPHOME_F("fan_modes")].to<JsonArray>();
165 if (traits.supports_fan_mode(CLIMATE_FAN_ON))
166 fan_modes.add(ESPHOME_F("on"));
167 if (traits.supports_fan_mode(CLIMATE_FAN_OFF))
168 fan_modes.add(ESPHOME_F("off"));
169 if (traits.supports_fan_mode(CLIMATE_FAN_AUTO))
170 fan_modes.add(ESPHOME_F("auto"));
171 if (traits.supports_fan_mode(CLIMATE_FAN_LOW))
172 fan_modes.add(ESPHOME_F("low"));
173 if (traits.supports_fan_mode(CLIMATE_FAN_MEDIUM))
174 fan_modes.add(ESPHOME_F("medium"));
175 if (traits.supports_fan_mode(CLIMATE_FAN_HIGH))
176 fan_modes.add(ESPHOME_F("high"));
177 if (traits.supports_fan_mode(CLIMATE_FAN_MIDDLE))
178 fan_modes.add(ESPHOME_F("middle"));
179 if (traits.supports_fan_mode(CLIMATE_FAN_FOCUS))
180 fan_modes.add(ESPHOME_F("focus"));
181 if (traits.supports_fan_mode(CLIMATE_FAN_DIFFUSE))
182 fan_modes.add(ESPHOME_F("diffuse"));
183 if (traits.supports_fan_mode(CLIMATE_FAN_QUIET))
184 fan_modes.add(ESPHOME_F("quiet"));
185 for (const auto &fan_mode : traits.get_supported_custom_fan_modes())
186 fan_modes.add(fan_mode);
187 }
188
189 if (traits.get_supports_swing_modes()) {
190 // swing_mode_command_topic
191 root[MQTT_SWING_MODE_COMMAND_TOPIC] = this->get_swing_mode_command_topic();
192 // swing_mode_state_topic
193 root[MQTT_SWING_MODE_STATE_TOPIC] = this->get_swing_mode_state_topic();
194 // swing_modes
195 JsonArray swing_modes = root[ESPHOME_F("swing_modes")].to<JsonArray>();
196 if (traits.supports_swing_mode(CLIMATE_SWING_OFF))
197 swing_modes.add(ESPHOME_F("off"));
198 if (traits.supports_swing_mode(CLIMATE_SWING_BOTH))
199 swing_modes.add(ESPHOME_F("both"));
200 if (traits.supports_swing_mode(CLIMATE_SWING_VERTICAL))
201 swing_modes.add(ESPHOME_F("vertical"));
202 if (traits.supports_swing_mode(CLIMATE_SWING_HORIZONTAL))
203 swing_modes.add(ESPHOME_F("horizontal"));
204 }
205
206 config.state_topic = false;
207 config.command_topic = false;
208 // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
209}
211 auto traits = this->device_->get_traits();
212 this->subscribe(this->get_mode_command_topic(), [this](const std::string &topic, const std::string &payload) {
213 auto call = this->device_->make_call();
214 call.set_mode(payload);
215 call.perform();
216 });
217
218 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_TWO_POINT_TARGET_TEMPERATURE |
220 this->subscribe(this->get_target_temperature_low_command_topic(),
221 [this](const std::string &topic, const std::string &payload) {
222 auto val = parse_number<float>(payload);
223 if (!val.has_value()) {
224 ESP_LOGW(TAG, "Can't convert '%s' to number!", payload.c_str());
225 return;
226 }
227 auto call = this->device_->make_call();
229 call.perform();
230 });
231 this->subscribe(this->get_target_temperature_high_command_topic(),
232 [this](const std::string &topic, const std::string &payload) {
233 auto val = parse_number<float>(payload);
234 if (!val.has_value()) {
235 ESP_LOGW(TAG, "Can't convert '%s' to number!", payload.c_str());
236 return;
237 }
238 auto call = this->device_->make_call();
240 call.perform();
241 });
242 } else {
243 this->subscribe(this->get_target_temperature_command_topic(),
244 [this](const std::string &topic, const std::string &payload) {
245 auto val = parse_number<float>(payload);
246 if (!val.has_value()) {
247 ESP_LOGW(TAG, "Can't convert '%s' to number!", payload.c_str());
248 return;
249 }
250 auto call = this->device_->make_call();
252 call.perform();
253 });
254 }
255
256 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_TARGET_HUMIDITY)) {
257 this->subscribe(this->get_target_humidity_command_topic(),
258 [this](const std::string &topic, const std::string &payload) {
259 auto val = parse_number<float>(payload);
260 if (!val.has_value()) {
261 ESP_LOGW(TAG, "Can't convert '%s' to number!", payload.c_str());
262 return;
263 }
264 auto call = this->device_->make_call();
266 call.perform();
267 });
268 }
269
270 if (traits.get_supports_presets() || !traits.get_supported_custom_presets().empty()) {
271 this->subscribe(this->get_preset_command_topic(), [this](const std::string &topic, const std::string &payload) {
272 auto call = this->device_->make_call();
273 call.set_preset(payload);
274 call.perform();
275 });
276 }
277
278 if (traits.get_supports_fan_modes()) {
279 this->subscribe(this->get_fan_mode_command_topic(), [this](const std::string &topic, const std::string &payload) {
280 auto call = this->device_->make_call();
281 call.set_fan_mode(payload);
282 call.perform();
283 });
284 }
285
286 if (traits.get_supports_swing_modes()) {
287 this->subscribe(this->get_swing_mode_command_topic(), [this](const std::string &topic, const std::string &payload) {
288 auto call = this->device_->make_call();
289 call.set_swing_mode(payload);
290 call.perform();
291 });
292 }
293
294 this->device_->add_on_state_callback([this](Climate & /*unused*/) { this->publish_state_(); });
295}
299const EntityBase *MQTTClimateComponent::get_entity() const { return this->device_; }
300
302 auto traits = this->device_->get_traits();
303 // Reusable stack buffer for topic construction (avoids heap allocation per publish)
304 char topic_buf[MQTT_DEFAULT_TOPIC_MAX_LEN];
305 // mode
306 bool success = true;
307 if (!this->publish(this->get_mode_state_topic_to(topic_buf), climate_mode_to_mqtt_str(this->device_->mode)))
308 success = false;
309 int8_t target_accuracy = traits.get_target_temperature_accuracy_decimals();
310 int8_t current_accuracy = traits.get_current_temperature_accuracy_decimals();
311 char payload[VALUE_ACCURACY_MAX_LEN];
312 size_t len;
313 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_TEMPERATURE) &&
314 !std::isnan(this->device_->current_temperature)) {
315 len = value_accuracy_to_buf(payload, this->device_->current_temperature, current_accuracy);
316 if (!this->publish(this->get_current_temperature_state_topic_to(topic_buf), payload, len))
317 success = false;
318 }
319 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_TWO_POINT_TARGET_TEMPERATURE |
321 len = value_accuracy_to_buf(payload, this->device_->target_temperature_low, target_accuracy);
322 if (!this->publish(this->get_target_temperature_low_state_topic_to(topic_buf), payload, len))
323 success = false;
324 len = value_accuracy_to_buf(payload, this->device_->target_temperature_high, target_accuracy);
325 if (!this->publish(this->get_target_temperature_high_state_topic_to(topic_buf), payload, len))
326 success = false;
327 } else {
328 len = value_accuracy_to_buf(payload, this->device_->target_temperature, target_accuracy);
329 if (!this->publish(this->get_target_temperature_state_topic_to(topic_buf), payload, len))
330 success = false;
331 }
332
333 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_HUMIDITY) &&
334 !std::isnan(this->device_->current_humidity)) {
336 if (!this->publish(this->get_current_humidity_state_topic_to(topic_buf), payload, len))
337 success = false;
338 }
339 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_TARGET_HUMIDITY) &&
340 !std::isnan(this->device_->target_humidity)) {
341 len = value_accuracy_to_buf(payload, this->device_->target_humidity, 0);
342 if (!this->publish(this->get_target_humidity_state_topic_to(topic_buf), payload, len))
343 success = false;
344 }
345
346 if (traits.get_supports_presets() || !traits.get_supported_custom_presets().empty()) {
347 if (this->device_->has_custom_preset()) {
348 if (!this->publish(this->get_preset_state_topic_to(topic_buf), this->device_->get_custom_preset().c_str()))
349 success = false;
350 } else if (this->device_->preset.has_value()) {
351 if (!this->publish(this->get_preset_state_topic_to(topic_buf),
352 climate_preset_to_mqtt_str(this->device_->preset.value())))
353 success = false;
354 } else if (!this->publish(this->get_preset_state_topic_to(topic_buf), "")) {
355 success = false;
356 }
357 }
358
359 if (traits.has_feature_flags(climate::CLIMATE_SUPPORTS_ACTION)) {
360 if (!this->publish(this->get_action_state_topic_to(topic_buf), climate_action_to_mqtt_str(this->device_->action)))
361 success = false;
362 }
363
364 if (traits.get_supports_fan_modes()) {
365 if (this->device_->has_custom_fan_mode()) {
366 if (!this->publish(this->get_fan_mode_state_topic_to(topic_buf), this->device_->get_custom_fan_mode().c_str()))
367 success = false;
368 } else if (this->device_->fan_mode.has_value()) {
369 if (!this->publish(this->get_fan_mode_state_topic_to(topic_buf),
370 climate_fan_mode_to_mqtt_str(this->device_->fan_mode.value())))
371 success = false;
372 } else if (!this->publish(this->get_fan_mode_state_topic_to(topic_buf), "")) {
373 success = false;
374 }
375 }
376
377 if (traits.get_supports_swing_modes()) {
378 if (!this->publish(this->get_swing_mode_state_topic_to(topic_buf),
379 climate_swing_mode_to_mqtt_str(this->device_->swing_mode)))
380 success = false;
381 }
382
383 return success;
384}
385
386} // namespace esphome::mqtt
387
388#endif
389#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:187
ClimateMode mode
The active mode of the climate device.
Definition climate.h:304
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
Definition climate.h:298
ClimateTraits get_traits()
Get the traits of this climate device with all overrides applied.
Definition climate.cpp:486
float target_temperature
The target temperature of the climate device.
Definition climate.h:285
float current_humidity
The current humidity of the climate device, as reported from the integration.
Definition climate.h:281
ClimateSwingMode swing_mode
The active swing mode of the climate device.
Definition climate.h:310
float target_temperature_low
The minimum target temperature of the climate device, for climate devices with split target temperatu...
Definition climate.h:288
void add_on_state_callback(F &&callback)
Add a callback for the climate device state, each time the state of the climate device is updated (us...
Definition climate.h:196
bool has_custom_preset() const
Check if a custom preset is currently active.
Definition climate.h:275
float current_temperature
The current temperature of the climate device, as reported from the integration.
Definition climate.h:278
ClimateAction action
The active state of the climate device.
Definition climate.h:307
ClimateCall make_call()
Make a climate device control call, this is used to control the climate device, see the ClimateCall d...
Definition climate.cpp:514
StringRef get_custom_preset() const
Get the active custom preset (read-only access). Returns StringRef.
Definition climate.h:316
bool has_custom_fan_mode() const
Check if a custom fan mode is currently active.
Definition climate.h:272
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
StringRef get_custom_fan_mode() const
Get the active custom fan mode (read-only access). Returns StringRef.
Definition climate.h:313
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.
ClimateSwingMode swing_mode
Definition climate.h:11
ClimateFanMode fan_mode
Definition climate.h:3
ClimatePreset preset
Definition climate.h:8
mopeka_std_values val[3]
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:558
const void size_t len
Definition hal.h:64
optional< T > parse_number(const char *str)
Parse an unsigned decimal number from a null-terminated string.
Definition helpers.h:1179
const __FlashStringHelper * ProgmemStr
Definition progmem.h:27
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.