diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 7fc766964..1205dd030 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -915,10 +915,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