ESPHome
2026.1.4
Loading...
Searching...
No Matches
esphome
components
mqtt
mqtt_const.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/defines.h
"
4
#include "
esphome/core/progmem.h
"
5
6
#ifdef USE_MQTT
7
8
// MQTT JSON Key Constants for Home Assistant Discovery
9
//
10
// This file defines string constants used as JSON keys in MQTT discovery payloads
11
// for Home Assistant integration. These are used exclusively with ArduinoJson as:
12
// root[MQTT_DEVICE_CLASS] = "temperature";
13
//
14
// Implementation:
15
// - ESP8266: Stores strings in PROGMEM (flash) using __FlashStringHelper* pointers.
16
// ArduinoJson recognizes this type and reads from flash memory.
17
// - Other platforms: Uses constexpr const char* for compile-time optimization.
18
// - USE_MQTT_ABBREVIATIONS: When defined, uses shortened key names to reduce message size.
19
//
20
// Adding new keys:
21
// Add a single line to MQTT_KEYS_LIST: X(MQTT_NEW_KEY, "abbr", "full_name")
22
// The X-macro will generate the appropriate constants for each platform.
23
//
24
// Note: Other MQTT_* constants (e.g., MQTT_CLIENT_CONNECTED, MQTT_LEGACY_UNIQUE_ID_GENERATOR)
25
// are C++ enums defined in mqtt_client.h and mqtt_backend*.h - unrelated to these JSON keys.
26
27
// X-macro list: MQTT_KEYS_LIST(X) calls X(name, abbr, full) for each key
28
// clang-format off
29
#define MQTT_KEYS_LIST(X) \
30
X(MQTT_ACTION_TEMPLATE, "act_tpl", "action_template") \
31
X(MQTT_ACTION_TOPIC, "act_t", "action_topic") \
32
X(MQTT_AUTOMATION_TYPE, "atype", "automation_type") \
33
X(MQTT_AUX_COMMAND_TOPIC, "aux_cmd_t", "aux_command_topic") \
34
X(MQTT_AUX_STATE_TEMPLATE, "aux_stat_tpl", "aux_state_template") \
35
X(MQTT_AUX_STATE_TOPIC, "aux_stat_t", "aux_state_topic") \
36
X(MQTT_AVAILABILITY, "avty", "availability") \
37
X(MQTT_AVAILABILITY_MODE, "avty_mode", "availability_mode") \
38
X(MQTT_AVAILABILITY_TOPIC, "avty_t", "availability_topic") \
39
X(MQTT_AWAY_MODE_COMMAND_TOPIC, "away_mode_cmd_t", "away_mode_command_topic") \
40
X(MQTT_AWAY_MODE_STATE_TEMPLATE, "away_mode_stat_tpl", "away_mode_state_template") \
41
X(MQTT_AWAY_MODE_STATE_TOPIC, "away_mode_stat_t", "away_mode_state_topic") \
42
X(MQTT_BATTERY_LEVEL_TEMPLATE, "bat_lev_tpl", "battery_level_template") \
43
X(MQTT_BATTERY_LEVEL_TOPIC, "bat_lev_t", "battery_level_topic") \
44
X(MQTT_BLUE_TEMPLATE, "b_tpl", "blue_template") \
45
X(MQTT_BRIGHTNESS_COMMAND_TOPIC, "bri_cmd_t", "brightness_command_topic") \
46
X(MQTT_BRIGHTNESS_SCALE, "bri_scl", "brightness_scale") \
47
X(MQTT_BRIGHTNESS_STATE_TOPIC, "bri_stat_t", "brightness_state_topic") \
48
X(MQTT_BRIGHTNESS_TEMPLATE, "bri_tpl", "brightness_template") \
49
X(MQTT_BRIGHTNESS_VALUE_TEMPLATE, "bri_val_tpl", "brightness_value_template") \
50
X(MQTT_CHARGING_TEMPLATE, "chrg_tpl", "charging_template") \
51
X(MQTT_CHARGING_TOPIC, "chrg_t", "charging_topic") \
52
X(MQTT_CLEANING_TEMPLATE, "cln_tpl", "cleaning_template") \
53
X(MQTT_CLEANING_TOPIC, "cln_t", "cleaning_topic") \
54
X(MQTT_CODE_ARM_REQUIRED, "cod_arm_req", "code_arm_required") \
55
X(MQTT_CODE_DISARM_REQUIRED, "cod_dis_req", "code_disarm_required") \
56
X(MQTT_COLOR_MODE, "clrm", "color_mode") \
57
X(MQTT_COLOR_MODE_STATE_TOPIC, "clrm_stat_t", "color_mode_state_topic") \
58
X(MQTT_COLOR_MODE_VALUE_TEMPLATE, "clrm_val_tpl", "color_mode_value_template") \
59
X(MQTT_COLOR_TEMP_COMMAND_TEMPLATE, "clr_temp_cmd_tpl", "color_temp_command_template") \
60
X(MQTT_COLOR_TEMP_COMMAND_TOPIC, "clr_temp_cmd_t", "color_temp_command_topic") \
61
X(MQTT_COLOR_TEMP_STATE_TOPIC, "clr_temp_stat_t", "color_temp_state_topic") \
62
X(MQTT_COLOR_TEMP_TEMPLATE, "clr_temp_tpl", "color_temp_template") \
63
X(MQTT_COLOR_TEMP_VALUE_TEMPLATE, "clr_temp_val_tpl", "color_temp_value_template") \
64
X(MQTT_COMMAND_OFF_TEMPLATE, "cmd_off_tpl", "command_off_template") \
65
X(MQTT_COMMAND_ON_TEMPLATE, "cmd_on_tpl", "command_on_template") \
66
X(MQTT_COMMAND_RETAIN, "ret", "retain") \
67
X(MQTT_COMMAND_TEMPLATE, "cmd_tpl", "command_template") \
68
X(MQTT_COMMAND_TOPIC, "cmd_t", "command_topic") \
69
X(MQTT_CONFIGURATION_URL, "cu", "configuration_url") \
70
X(MQTT_CURRENT_HUMIDITY_TEMPLATE, "curr_hum_tpl", "current_humidity_template") \
71
X(MQTT_CURRENT_HUMIDITY_TOPIC, "curr_hum_t", "current_humidity_topic") \
72
X(MQTT_CURRENT_TEMPERATURE_STEP, "precision", "precision") \
73
X(MQTT_CURRENT_TEMPERATURE_TEMPLATE, "curr_temp_tpl", "current_temperature_template") \
74
X(MQTT_CURRENT_TEMPERATURE_TOPIC, "curr_temp_t", "current_temperature_topic") \
75
X(MQTT_DEVICE, "dev", "device") \
76
X(MQTT_DEVICE_CLASS, "dev_cla", "device_class") \
77
X(MQTT_DEVICE_CONNECTIONS, "cns", "connections") \
78
X(MQTT_DEVICE_IDENTIFIERS, "ids", "identifiers") \
79
X(MQTT_DEVICE_MANUFACTURER, "mf", "manufacturer") \
80
X(MQTT_DEVICE_MODEL, "mdl", "model") \
81
X(MQTT_DEVICE_NAME, "name", "name") \
82
X(MQTT_DEVICE_SUGGESTED_AREA, "sa", "suggested_area") \
83
X(MQTT_DEVICE_SW_VERSION, "sw", "sw_version") \
84
X(MQTT_DEVICE_HW_VERSION, "hw", "hw_version") \
85
X(MQTT_DIRECTION_COMMAND_TOPIC, "dir_cmd_t", "direction_command_topic") \
86
X(MQTT_DIRECTION_STATE_TOPIC, "dir_stat_t", "direction_state_topic") \
87
X(MQTT_DOCKED_TEMPLATE, "dock_tpl", "docked_template") \
88
X(MQTT_DOCKED_TOPIC, "dock_t", "docked_topic") \
89
X(MQTT_EFFECT_COMMAND_TOPIC, "fx_cmd_t", "effect_command_topic") \
90
X(MQTT_EFFECT_LIST, "fx_list", "effect_list") \
91
X(MQTT_EFFECT_STATE_TOPIC, "fx_stat_t", "effect_state_topic") \
92
X(MQTT_EFFECT_TEMPLATE, "fx_tpl", "effect_template") \
93
X(MQTT_EFFECT_VALUE_TEMPLATE, "fx_val_tpl", "effect_value_template") \
94
X(MQTT_ENABLED_BY_DEFAULT, "en", "enabled_by_default") \
95
X(MQTT_ENTITY_CATEGORY, "ent_cat", "entity_category") \
96
X(MQTT_ERROR_TEMPLATE, "err_tpl", "error_template") \
97
X(MQTT_ERROR_TOPIC, "err_t", "error_topic") \
98
X(MQTT_EVENT_TYPE, "event_type", "event_type") \
99
X(MQTT_EVENT_TYPES, "evt_typ", "event_types") \
100
X(MQTT_EXPIRE_AFTER, "exp_aft", "expire_after") \
101
X(MQTT_FAN_MODE_COMMAND_TEMPLATE, "fan_mode_cmd_tpl", "fan_mode_command_template") \
102
X(MQTT_FAN_MODE_COMMAND_TOPIC, "fan_mode_cmd_t", "fan_mode_command_topic") \
103
X(MQTT_FAN_MODE_STATE_TEMPLATE, "fan_mode_stat_tpl", "fan_mode_state_template") \
104
X(MQTT_FAN_MODE_STATE_TOPIC, "fan_mode_stat_t", "fan_mode_state_topic") \
105
X(MQTT_FAN_SPEED_LIST, "fanspd_lst", "fan_speed_list") \
106
X(MQTT_FAN_SPEED_TEMPLATE, "fanspd_tpl", "fan_speed_template") \
107
X(MQTT_FAN_SPEED_TOPIC, "fanspd_t", "fan_speed_topic") \
108
X(MQTT_FLASH_TIME_LONG, "flsh_tlng", "flash_time_long") \
109
X(MQTT_FLASH_TIME_SHORT, "flsh_tsht", "flash_time_short") \
110
X(MQTT_FORCE_UPDATE, "frc_upd", "force_update") \
111
X(MQTT_GREEN_TEMPLATE, "g_tpl", "green_template") \
112
X(MQTT_HOLD_COMMAND_TEMPLATE, "hold_cmd_tpl", "hold_command_template") \
113
X(MQTT_HOLD_COMMAND_TOPIC, "hold_cmd_t", "hold_command_topic") \
114
X(MQTT_HOLD_STATE_TEMPLATE, "hold_stat_tpl", "hold_state_template") \
115
X(MQTT_HOLD_STATE_TOPIC, "hold_stat_t", "hold_state_topic") \
116
X(MQTT_HS_COMMAND_TOPIC, "hs_cmd_t", "hs_command_topic") \
117
X(MQTT_HS_STATE_TOPIC, "hs_stat_t", "hs_state_topic") \
118
X(MQTT_HS_VALUE_TEMPLATE, "hs_val_tpl", "hs_value_template") \
119
X(MQTT_ICON, "ic", "icon") \
120
X(MQTT_INITIAL, "init", "initial") \
121
X(MQTT_JSON_ATTRIBUTES, "json_attr", "json_attributes") \
122
X(MQTT_JSON_ATTRIBUTES_TEMPLATE, "json_attr_tpl", "json_attributes_template") \
123
X(MQTT_JSON_ATTRIBUTES_TOPIC, "json_attr_t", "json_attributes_topic") \
124
X(MQTT_LAST_RESET_TOPIC, "lrst_t", "last_reset_topic") \
125
X(MQTT_LAST_RESET_VALUE_TEMPLATE, "lrst_val_tpl", "last_reset_value_template") \
126
X(MQTT_MAX, "max", "max") \
127
X(MQTT_MAX_HUMIDITY, "max_hum", "max_humidity") \
128
X(MQTT_MAX_MIREDS, "max_mirs", "max_mireds") \
129
X(MQTT_MAX_TEMP, "max_temp", "max_temp") \
130
X(MQTT_MIN, "min", "min") \
131
X(MQTT_MIN_HUMIDITY, "min_hum", "min_humidity") \
132
X(MQTT_MIN_MIREDS, "min_mirs", "min_mireds") \
133
X(MQTT_MIN_TEMP, "min_temp", "min_temp") \
134
X(MQTT_MODE, "mode", "mode") \
135
X(MQTT_MODE_COMMAND_TEMPLATE, "mode_cmd_tpl", "mode_command_template") \
136
X(MQTT_MODE_COMMAND_TOPIC, "mode_cmd_t", "mode_command_topic") \
137
X(MQTT_MODE_STATE_TEMPLATE, "mode_stat_tpl", "mode_state_template") \
138
X(MQTT_MODE_STATE_TOPIC, "mode_stat_t", "mode_state_topic") \
139
X(MQTT_MODES, "modes", "modes") \
140
X(MQTT_NAME, "name", "name") \
141
X(MQTT_OBJECT_ID, "obj_id", "object_id") \
142
X(MQTT_OFF_DELAY, "off_dly", "off_delay") \
143
X(MQTT_ON_COMMAND_TYPE, "on_cmd_type", "on_command_type") \
144
X(MQTT_OPTIMISTIC, "opt", "optimistic") \
145
X(MQTT_OPTIONS, "ops", "options") \
146
X(MQTT_OSCILLATION_COMMAND_TEMPLATE, "osc_cmd_tpl", "oscillation_command_template") \
147
X(MQTT_OSCILLATION_COMMAND_TOPIC, "osc_cmd_t", "oscillation_command_topic") \
148
X(MQTT_OSCILLATION_STATE_TOPIC, "osc_stat_t", "oscillation_state_topic") \
149
X(MQTT_OSCILLATION_VALUE_TEMPLATE, "osc_val_tpl", "oscillation_value_template") \
150
X(MQTT_PAYLOAD, "pl", "payload") \
151
X(MQTT_PAYLOAD_ARM_AWAY, "pl_arm_away", "payload_arm_away") \
152
X(MQTT_PAYLOAD_ARM_CUSTOM_BYPASS, "pl_arm_custom_b", "payload_arm_custom_bypass") \
153
X(MQTT_PAYLOAD_ARM_HOME, "pl_arm_home", "payload_arm_home") \
154
X(MQTT_PAYLOAD_ARM_NIGHT, "pl_arm_nite", "payload_arm_night") \
155
X(MQTT_PAYLOAD_ARM_VACATION, "pl_arm_vacation", "payload_arm_vacation") \
156
X(MQTT_PAYLOAD_AVAILABLE, "pl_avail", "payload_available") \
157
X(MQTT_PAYLOAD_CLEAN_SPOT, "pl_cln_sp", "payload_clean_spot") \
158
X(MQTT_PAYLOAD_CLOSE, "pl_cls", "payload_close") \
159
X(MQTT_PAYLOAD_DISARM, "pl_disarm", "payload_disarm") \
160
X(MQTT_PAYLOAD_HIGH_SPEED, "pl_hi_spd", "payload_high_speed") \
161
X(MQTT_PAYLOAD_HOME, "pl_home", "payload_home") \
162
X(MQTT_PAYLOAD_INSTALL, "pl_inst", "payload_install") \
163
X(MQTT_PAYLOAD_LOCATE, "pl_loc", "payload_locate") \
164
X(MQTT_PAYLOAD_LOCK, "pl_lock", "payload_lock") \
165
X(MQTT_PAYLOAD_LOW_SPEED, "pl_lo_spd", "payload_low_speed") \
166
X(MQTT_PAYLOAD_MEDIUM_SPEED, "pl_med_spd", "payload_medium_speed") \
167
X(MQTT_PAYLOAD_NOT_AVAILABLE, "pl_not_avail", "payload_not_available") \
168
X(MQTT_PAYLOAD_NOT_HOME, "pl_not_home", "payload_not_home") \
169
X(MQTT_PAYLOAD_OFF, "pl_off", "payload_off") \
170
X(MQTT_PAYLOAD_OFF_SPEED, "pl_off_spd", "payload_off_speed") \
171
X(MQTT_PAYLOAD_ON, "pl_on", "payload_on") \
172
X(MQTT_PAYLOAD_OPEN, "pl_open", "payload_open") \
173
X(MQTT_PAYLOAD_OSCILLATION_OFF, "pl_osc_off", "payload_oscillation_off") \
174
X(MQTT_PAYLOAD_OSCILLATION_ON, "pl_osc_on", "payload_oscillation_on") \
175
X(MQTT_PAYLOAD_PAUSE, "pl_paus", "payload_pause") \
176
X(MQTT_PAYLOAD_RESET, "pl_rst", "payload_reset") \
177
X(MQTT_PAYLOAD_RESET_HUMIDITY, "pl_rst_hum", "payload_reset_humidity") \
178
X(MQTT_PAYLOAD_RESET_MODE, "pl_rst_mode", "payload_reset_mode") \
179
X(MQTT_PAYLOAD_RESET_PERCENTAGE, "pl_rst_pct", "payload_reset_percentage") \
180
X(MQTT_PAYLOAD_RESET_PRESET_MODE, "pl_rst_pr_mode", "payload_reset_preset_mode") \
181
X(MQTT_PAYLOAD_RETURN_TO_BASE, "pl_ret", "payload_return_to_base") \
182
X(MQTT_PAYLOAD_START, "pl_strt", "payload_start") \
183
X(MQTT_PAYLOAD_START_PAUSE, "pl_stpa", "payload_start_pause") \
184
X(MQTT_PAYLOAD_STOP, "pl_stop", "payload_stop") \
185
X(MQTT_PAYLOAD_TURN_OFF, "pl_toff", "payload_turn_off") \
186
X(MQTT_PAYLOAD_TURN_ON, "pl_ton", "payload_turn_on") \
187
X(MQTT_PAYLOAD_UNLOCK, "pl_unlk", "payload_unlock") \
188
X(MQTT_PERCENTAGE_COMMAND_TEMPLATE, "pct_cmd_tpl", "percentage_command_template") \
189
X(MQTT_PERCENTAGE_COMMAND_TOPIC, "pct_cmd_t", "percentage_command_topic") \
190
X(MQTT_PERCENTAGE_STATE_TOPIC, "pct_stat_t", "percentage_state_topic") \
191
X(MQTT_PERCENTAGE_VALUE_TEMPLATE, "pct_val_tpl", "percentage_value_template") \
192
X(MQTT_POSITION_CLOSED, "pos_clsd", "position_closed") \
193
X(MQTT_POSITION_OPEN, "pos_open", "position_open") \
194
X(MQTT_POSITION_TEMPLATE, "pos_tpl", "position_template") \
195
X(MQTT_POSITION_TOPIC, "pos_t", "position_topic") \
196
X(MQTT_POWER_COMMAND_TOPIC, "pow_cmd_t", "power_command_topic") \
197
X(MQTT_POWER_STATE_TEMPLATE, "pow_stat_tpl", "power_state_template") \
198
X(MQTT_POWER_STATE_TOPIC, "pow_stat_t", "power_state_topic") \
199
X(MQTT_PRESET_MODE_COMMAND_TEMPLATE, "pr_mode_cmd_tpl", "preset_mode_command_template") \
200
X(MQTT_PRESET_MODE_COMMAND_TOPIC, "pr_mode_cmd_t", "preset_mode_command_topic") \
201
X(MQTT_PRESET_MODE_STATE_TOPIC, "pr_mode_stat_t", "preset_mode_state_topic") \
202
X(MQTT_PRESET_MODE_VALUE_TEMPLATE, "pr_mode_val_tpl", "preset_mode_value_template") \
203
X(MQTT_PRESET_MODES, "pr_modes", "preset_modes") \
204
X(MQTT_QOS, "qos", "qos") \
205
X(MQTT_RED_TEMPLATE, "r_tpl", "red_template") \
206
X(MQTT_RETAIN, "ret", "retain") \
207
X(MQTT_RGB_COMMAND_TEMPLATE, "rgb_cmd_tpl", "rgb_command_template") \
208
X(MQTT_RGB_COMMAND_TOPIC, "rgb_cmd_t", "rgb_command_topic") \
209
X(MQTT_RGB_STATE_TOPIC, "rgb_stat_t", "rgb_state_topic") \
210
X(MQTT_RGB_VALUE_TEMPLATE, "rgb_val_tpl", "rgb_value_template") \
211
X(MQTT_RGBW_COMMAND_TEMPLATE, "rgbw_cmd_tpl", "rgbw_command_template") \
212
X(MQTT_RGBW_COMMAND_TOPIC, "rgbw_cmd_t", "rgbw_command_topic") \
213
X(MQTT_RGBW_STATE_TOPIC, "rgbw_stat_t", "rgbw_state_topic") \
214
X(MQTT_RGBW_VALUE_TEMPLATE, "rgbw_val_tpl", "rgbw_value_template") \
215
X(MQTT_RGBWW_COMMAND_TEMPLATE, "rgbww_cmd_tpl", "rgbww_command_template") \
216
X(MQTT_RGBWW_COMMAND_TOPIC, "rgbww_cmd_t", "rgbww_command_topic") \
217
X(MQTT_RGBWW_STATE_TOPIC, "rgbww_stat_t", "rgbww_state_topic") \
218
X(MQTT_RGBWW_VALUE_TEMPLATE, "rgbww_val_tpl", "rgbww_value_template") \
219
X(MQTT_SEND_COMMAND_TOPIC, "send_cmd_t", "send_command_topic") \
220
X(MQTT_SEND_IF_OFF, "send_if_off", "send_if_off") \
221
X(MQTT_SET_FAN_SPEED_TOPIC, "set_fan_spd_t", "set_fan_speed_topic") \
222
X(MQTT_SET_POSITION_TEMPLATE, "set_pos_tpl", "set_position_template") \
223
X(MQTT_SET_POSITION_TOPIC, "set_pos_t", "set_position_topic") \
224
X(MQTT_SOURCE_TYPE, "src_type", "source_type") \
225
X(MQTT_SPEED_COMMAND_TOPIC, "spd_cmd_t", "speed_command_topic") \
226
X(MQTT_SPEED_RANGE_MAX, "spd_rng_max", "speed_range_max") \
227
X(MQTT_SPEED_RANGE_MIN, "spd_rng_min", "speed_range_min") \
228
X(MQTT_SPEED_STATE_TOPIC, "spd_stat_t", "speed_state_topic") \
229
X(MQTT_SPEED_VALUE_TEMPLATE, "spd_val_tpl", "speed_value_template") \
230
X(MQTT_SPEEDS, "spds", "speeds") \
231
X(MQTT_STATE_CLASS, "stat_cla", "state_class") \
232
X(MQTT_STATE_CLOSED, "stat_clsd", "state_closed") \
233
X(MQTT_STATE_CLOSING, "stat_closing", "state_closing") \
234
X(MQTT_STATE_LOCKED, "stat_locked", "state_locked") \
235
X(MQTT_STATE_OFF, "stat_off", "state_off") \
236
X(MQTT_STATE_ON, "stat_on", "state_on") \
237
X(MQTT_STATE_OPEN, "stat_open", "state_open") \
238
X(MQTT_STATE_OPENING, "stat_opening", "state_opening") \
239
X(MQTT_STATE_STOPPED, "stat_stopped", "state_stopped") \
240
X(MQTT_STATE_TEMPLATE, "stat_tpl", "state_template") \
241
X(MQTT_STATE_TOPIC, "stat_t", "state_topic") \
242
X(MQTT_STATE_UNLOCKED, "stat_unlocked", "state_unlocked") \
243
X(MQTT_STATE_VALUE_TEMPLATE, "stat_val_tpl", "state_value_template") \
244
X(MQTT_STEP, "step", "step") \
245
X(MQTT_SUBTYPE, "stype", "subtype") \
246
X(MQTT_SUPPORTED_COLOR_MODES, "sup_clrm", "supported_color_modes") \
247
X(MQTT_SUPPORTED_FEATURES, "sup_feat", "supported_features") \
248
X(MQTT_SWING_MODE_COMMAND_TEMPLATE, "swing_mode_cmd_tpl", "swing_mode_command_template") \
249
X(MQTT_SWING_MODE_COMMAND_TOPIC, "swing_mode_cmd_t", "swing_mode_command_topic") \
250
X(MQTT_SWING_MODE_STATE_TEMPLATE, "swing_mode_stat_tpl", "swing_mode_state_template") \
251
X(MQTT_SWING_MODE_STATE_TOPIC, "swing_mode_stat_t", "swing_mode_state_topic") \
252
X(MQTT_TARGET_HUMIDITY_COMMAND_TEMPLATE, "hum_cmd_tpl", "target_humidity_command_template") \
253
X(MQTT_TARGET_HUMIDITY_COMMAND_TOPIC, "hum_cmd_t", "target_humidity_command_topic") \
254
X(MQTT_TARGET_HUMIDITY_STATE_TEMPLATE, "hum_state_tpl", "target_humidity_state_template") \
255
X(MQTT_TARGET_HUMIDITY_STATE_TOPIC, "hum_stat_t", "target_humidity_state_topic") \
256
X(MQTT_TARGET_TEMPERATURE_STEP, "temp_step", "temp_step") \
257
X(MQTT_TEMPERATURE_COMMAND_TEMPLATE, "temp_cmd_tpl", "temperature_command_template") \
258
X(MQTT_TEMPERATURE_COMMAND_TOPIC, "temp_cmd_t", "temperature_command_topic") \
259
X(MQTT_TEMPERATURE_HIGH_COMMAND_TEMPLATE, "temp_hi_cmd_tpl", "temperature_high_command_template") \
260
X(MQTT_TEMPERATURE_HIGH_COMMAND_TOPIC, "temp_hi_cmd_t", "temperature_high_command_topic") \
261
X(MQTT_TEMPERATURE_HIGH_STATE_TEMPLATE, "temp_hi_stat_tpl", "temperature_high_state_template") \
262
X(MQTT_TEMPERATURE_HIGH_STATE_TOPIC, "temp_hi_stat_t", "temperature_high_state_topic") \
263
X(MQTT_TEMPERATURE_LOW_COMMAND_TEMPLATE, "temp_lo_cmd_tpl", "temperature_low_command_template") \
264
X(MQTT_TEMPERATURE_LOW_COMMAND_TOPIC, "temp_lo_cmd_t", "temperature_low_command_topic") \
265
X(MQTT_TEMPERATURE_LOW_STATE_TEMPLATE, "temp_lo_stat_tpl", "temperature_low_state_template") \
266
X(MQTT_TEMPERATURE_LOW_STATE_TOPIC, "temp_lo_stat_t", "temperature_low_state_topic") \
267
X(MQTT_TEMPERATURE_STATE_TEMPLATE, "temp_stat_tpl", "temperature_state_template") \
268
X(MQTT_TEMPERATURE_STATE_TOPIC, "temp_stat_t", "temperature_state_topic") \
269
X(MQTT_TEMPERATURE_UNIT, "temp_unit", "temperature_unit") \
270
X(MQTT_TILT_CLOSED_VALUE, "tilt_clsd_val", "tilt_closed_value") \
271
X(MQTT_TILT_COMMAND_TEMPLATE, "tilt_cmd_tpl", "tilt_command_template") \
272
X(MQTT_TILT_COMMAND_TOPIC, "tilt_cmd_t", "tilt_command_topic") \
273
X(MQTT_TILT_INVERT_STATE, "tilt_inv_stat", "tilt_invert_state") \
274
X(MQTT_TILT_MAX, "tilt_max", "tilt_max") \
275
X(MQTT_TILT_MIN, "tilt_min", "tilt_min") \
276
X(MQTT_TILT_OPENED_VALUE, "tilt_opnd_val", "tilt_opened_value") \
277
X(MQTT_TILT_OPTIMISTIC, "tilt_opt", "tilt_optimistic") \
278
X(MQTT_TILT_STATUS_TEMPLATE, "tilt_status_tpl", "tilt_status_template") \
279
X(MQTT_TILT_STATUS_TOPIC, "tilt_status_t", "tilt_status_topic") \
280
X(MQTT_TOPIC, "t", "topic") \
281
X(MQTT_UNIQUE_ID, "uniq_id", "unique_id") \
282
X(MQTT_UNIT_OF_MEASUREMENT, "unit_of_meas", "unit_of_measurement") \
283
X(MQTT_VALUE_TEMPLATE, "val_tpl", "value_template") \
284
X(MQTT_WHITE_COMMAND_TOPIC, "whit_cmd_t", "white_command_topic") \
285
X(MQTT_WHITE_SCALE, "whit_scl", "white_scale") \
286
X(MQTT_WHITE_VALUE_COMMAND_TOPIC, "whit_val_cmd_t", "white_value_command_topic") \
287
X(MQTT_WHITE_VALUE_SCALE, "whit_val_scl", "white_value_scale") \
288
X(MQTT_WHITE_VALUE_STATE_TOPIC, "whit_val_stat_t", "white_value_state_topic") \
289
X(MQTT_WHITE_VALUE_TEMPLATE, "whit_val_tpl", "white_value_template") \
290
X(MQTT_XY_COMMAND_TOPIC, "xy_cmd_t", "xy_command_topic") \
291
X(MQTT_XY_STATE_TOPIC, "xy_stat_t", "xy_state_topic") \
292
X(MQTT_XY_VALUE_TEMPLATE, "xy_val_tpl", "xy_value_template")
293
// clang-format on
294
295
#ifdef USE_ESP8266
296
// ESP8266: Store strings in PROGMEM (flash) and expose as __FlashStringHelper* pointers.
297
// ArduinoJson recognizes this type and reads from flash memory.
298
namespace
esphome::mqtt
{
299
300
// Generate PROGMEM data arrays
301
#ifdef USE_MQTT_ABBREVIATIONS
302
#define MQTT_DATA(name, abbr, full) static const char name##_data[] PROGMEM = abbr;
303
#else
304
#define MQTT_DATA(name, abbr, full) static const char name##_data[] PROGMEM = full;
305
#endif
306
MQTT_KEYS_LIST(MQTT_DATA)
307
#undef MQTT_DATA
308
309
// Generate flash string pointers from the PROGMEM data
310
// NOLINTNEXTLINE(bugprone-macro-parentheses)
311
#define MQTT_PTR(name, abbr, full) \
312
static const __FlashStringHelper *const name = reinterpret_cast<const __FlashStringHelper *>(name##_data);
313
MQTT_KEYS_LIST(MQTT_PTR)
314
#undef MQTT_PTR
315
316
}
// namespace esphome::mqtt
317
#else
318
// Other platforms: constexpr in namespace
319
namespace
esphome::mqtt
{
320
#ifdef USE_MQTT_ABBREVIATIONS
321
// NOLINTNEXTLINE(bugprone-macro-parentheses)
322
#define MQTT_CONST(name, abbr, full) constexpr const char *name = abbr;
323
#else
324
// NOLINTNEXTLINE(bugprone-macro-parentheses)
325
#define MQTT_CONST(name, abbr, full) constexpr const char *name = full;
326
#endif
327
MQTT_KEYS_LIST(MQTT_CONST)
328
#undef MQTT_CONST
329
}
// namespace esphome::mqtt
330
#endif
331
332
#endif
// USE_MQTT
defines.h
esphome::mqtt
Definition
custom_mqtt_device.cpp:7
progmem.h
Generated by
1.12.0