Merge pull request #2820 from proddy/dev

fix HA modes
This commit is contained in:
Proddy
2025-12-15 21:13:11 +01:00
committed by GitHub
6 changed files with 324 additions and 315 deletions

View File

@@ -62,10 +62,10 @@
"prettier": "^3.7.4", "prettier": "^3.7.4",
"rollup-plugin-visualizer": "^6.0.5", "rollup-plugin-visualizer": "^6.0.5",
"terser": "^5.44.1", "terser": "^5.44.1",
"typescript-eslint": "^8.49.0", "typescript-eslint": "^8.50.0",
"vite": "^7.2.7", "vite": "^7.3.0",
"vite-plugin-imagemin": "^0.6.1", "vite-plugin-imagemin": "^0.6.1",
"vite-tsconfig-paths": "^5.1.4" "vite-tsconfig-paths": "^6.0.1"
}, },
"packageManager": "pnpm@10.25.0+sha512.5e82639027af37cf832061bcc6d639c219634488e0f2baebe785028a793de7b525ffcd3f7ff574f5e9860654e098fe852ba8ac5dd5cefe1767d23a020a92f501" "packageManager": "pnpm@10.26.0+sha512.3b3f6c725ebe712506c0ab1ad4133cf86b1f4b687effce62a9b38b4d72e3954242e643190fc51fa1642949c735f403debd44f5cb0edd657abe63a8b6a7e1e402"
} }

580
interface/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -15,5 +15,5 @@
"itty-router": "^5.0.22", "itty-router": "^5.0.22",
"prettier": "^3.7.4" "prettier": "^3.7.4"
}, },
"packageManager": "pnpm@10.25.0+sha512.5e82639027af37cf832061bcc6d639c219634488e0f2baebe785028a793de7b525ffcd3f7ff574f5e9860654e098fe852ba8ac5dd5cefe1767d23a020a92f501" "packageManager": "pnpm@10.26.0+sha512.3b3f6c725ebe712506c0ab1ad4133cf86b1f4b687effce62a9b38b4d72e3954242e643190fc51fa1642949c735f403debd44f5cb0edd657abe63a8b6a7e1e402"
} }

View File

@@ -106,7 +106,7 @@ board_build.filesystem = littlefs
lib_deps = lib_deps =
bblanchon/ArduinoJson @ 7.4.2 bblanchon/ArduinoJson @ 7.4.2
ESP32Async/AsyncTCP @ 3.4.9 ESP32Async/AsyncTCP @ 3.4.9
ESP32Async/ESPAsyncWebServer @ 3.9.2 ESP32Async/ESPAsyncWebServer @ 3.9.3
https://github.com/emsesp/EMS-ESP-Modules.git @ 1.0.8 https://github.com/emsesp/EMS-ESP-Modules.git @ 1.0.8
@@ -181,7 +181,8 @@ build_flags =
${common.build_flags} ${common.build_flags}
-DBOARD_C6 -DBOARD_C6
; foundation for building and testing natively, standalone without an ESP32. ; foundation for building and testing natively, standalone without an ESP32
; use the `standalone` environment instead of `native` for testing
[env:native] [env:native]
platform = native platform = native
build_type = debug build_type = debug

View File

@@ -2086,7 +2086,6 @@ void EMSdevice::mqtt_ha_entity_config_create() {
uint16_t count = 0; uint16_t count = 0;
const char * const ** mode_options = nullptr; const char * const ** mode_options = nullptr;
// check the state of each of the device values // check the state of each of the device values
// create the discovery topic if if hasn't already been created, not a command (like reset) and is active and visible // create the discovery topic if if hasn't already been created, not a command (like reset) and is active and visible
for (auto & dv : devicevalues_) { for (auto & dv : devicevalues_) {

View File

@@ -1367,10 +1367,10 @@ bool Mqtt::publish_ha_climate_config(const DeviceValue & dv, const bool has_room
// map EMS modes to HA climate modes // map EMS modes to HA climate modes
// EMS modes: auto, manual, heat, off, night, day, nofrost, eco, comfort, cool) // EMS modes: auto, manual, heat, off, night, day, nofrost, eco, comfort, cool)
// HA supports: auto, off, cool, heat, dry, fan_only // HA supports: auto, off, cool, heat, dry, fan_only
bool found_auto = true; bool found_auto = false;
bool found_heat = true; bool found_heat = false;
bool found_off = true; bool found_off = false;
bool found_cool = true; bool found_cool = false;
if (mode_options != nullptr) { if (mode_options != nullptr) {
// scan through mode_options and add to modes // scan through mode_options and add to modes
for (uint8_t i = 0; i < Helpers::count_items(mode_options); i++) { for (uint8_t i = 0; i < Helpers::count_items(mode_options); i++) {
@@ -1385,9 +1385,16 @@ bool Mqtt::publish_ha_climate_config(const DeviceValue & dv, const bool has_room
found_cool = true; found_cool = true;
} }
} }
} else {
// add all modes if no mode_options are available, e.g. for SRC thermostats
found_auto = true; // auto
found_heat = true; // heat
found_off = true; // off
found_cool = true; // cool
} }
// only add modes if we found at least one // only add modes if we found at least one, i.e. if mode_options are available
if (found_auto || found_heat || found_off || found_cool) {
JsonArray modes = doc["modes"].to<JsonArray>(); JsonArray modes = doc["modes"].to<JsonArray>();
if (found_auto) { if (found_auto) {
modes.add("auto"); modes.add("auto");
@@ -1401,10 +1408,12 @@ bool Mqtt::publish_ha_climate_config(const DeviceValue & dv, const bool has_room
if (found_cool) { if (found_cool) {
modes.add("cool"); modes.add("cool");
} }
}
if (icon != nullptr) { if (icon != nullptr) {
doc["ic"] = icon; doc["ic"] = icon;
} }
add_ha_dev_section(doc.as<JsonObject>(), devicename, nullptr, nullptr, nullptr, false); // add dev section add_ha_dev_section(doc.as<JsonObject>(), devicename, nullptr, nullptr, nullptr, false); // add dev section
add_ha_avty_section(doc.as<JsonObject>(), topic_t, seltemp_cond, has_roomtemp ? currtemp_cond : nullptr, hc_mode_cond); // add availability section add_ha_avty_section(doc.as<JsonObject>(), topic_t, seltemp_cond, has_roomtemp ? currtemp_cond : nullptr, hc_mode_cond); // add availability section