mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
Merge branch 'dev' of https://github.com/emsesp/EMS-ESP32 into dev2
This commit is contained in:
16
src/mqtt.cpp
16
src/mqtt.cpp
@@ -919,10 +919,20 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
||||
// for enums, add options
|
||||
if (type == DeviceValueType::ENUM) {
|
||||
JsonArray option_list = doc.createNestedArray("ops"); // options
|
||||
for (uint8_t i = 0; i < options_size; i++) {
|
||||
option_list.add(Helpers::translated_word(options[i]));
|
||||
if (EMSESP::system_.enum_format() == ENUM_FORMAT_INDEX) {
|
||||
// use index numbers
|
||||
for (uint8_t i = 0; i < options_size; i++) {
|
||||
option_list.add(i);
|
||||
}
|
||||
snprintf(sample_val, sizeof(sample_val), "0");
|
||||
} else {
|
||||
// use strings
|
||||
for (uint8_t i = 0; i < options_size; i++) {
|
||||
option_list.add(Helpers::translated_word(options[i]));
|
||||
}
|
||||
snprintf(sample_val, sizeof(sample_val), "'%s'", Helpers::translated_word(options[0]));
|
||||
}
|
||||
snprintf(sample_val, sizeof(sample_val), "'%s'", Helpers::translated_word(options[0]));
|
||||
|
||||
} else if (type != DeviceValueType::STRING && type != DeviceValueType::BOOL) {
|
||||
// Must be Numeric....
|
||||
doc["mode"] = "box"; // auto, slider or box
|
||||
|
||||
Reference in New Issue
Block a user