diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md
index 5ce4cec3a..94b073686 100644
--- a/CHANGELOG_LATEST.md
+++ b/CHANGELOG_LATEST.md
@@ -15,6 +15,7 @@
- heatpump dhw stop temperatures [#1624](https://github.com/emsesp/EMS-ESP32/issues/1624)
- reset history [#1695](https://github.com/emsesp/EMS-ESP32/issues/1695)
- heatpump entities `fan` and `shutdown` [#1690](https://github.com/emsesp/EMS-ESP32/discussions/1690)
+- mqtt HA-mode 3 for v3.6 compatible HA entities, set on update v3.6->v3.7
## Fixed
@@ -28,3 +29,4 @@
- store digital out states to nvs
- Refresh UI - moving settings to one location [#1665](https://github.com/emsesp/EMS-ESP32/issues/1665)
- rename DeviceValueTypes, add UINT32 for custom entities
+- dynamic register dhw circuits for thermostat
diff --git a/interface/src/framework/mqtt/MqttSettings.tsx b/interface/src/framework/mqtt/MqttSettings.tsx
index 90ad3f61d..7ecc33ee7 100644
--- a/interface/src/framework/mqtt/MqttSettings.tsx
+++ b/interface/src/framework/mqtt/MqttSettings.tsx
@@ -374,6 +374,7 @@ const MqttSettings: FC = () => {
select
>
+
diff --git a/src/mqtt.cpp b/src/mqtt.cpp
index dfdea6953..aa37d5453 100644
--- a/src/mqtt.cpp
+++ b/src/mqtt.cpp
@@ -847,6 +847,20 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
} else if (Mqtt::entity_format() == entityFormat::SINGLE_SHORT) {
// shortname, no mqtt base. This is the default version.
snprintf(uniq_id, sizeof(uniq_id), "%s_%s", device_name, entity_with_tag);
+ } else if (Mqtt::entity_format() == entityFormat::SINGLE_OLD) {
+ // shortname, remap to 3.6.
+ if (has_tag && (device_type == EMSdevice::DeviceType::BOILER || device_type == EMSdevice::DeviceType::THERMOSTAT) && tag == DeviceValue::DeviceValueTAG::TAG_DHW1) {
+ snprintf(uniq_id, sizeof(uniq_id), "%s_ww%s", device_name, entity);
+ if (strcmp(entity, "nrgdhw") == 0) { // special case for tp1de #1714
+ strcpy(uniq_id, "boiler_nrgww");
+ }
+ } else if (has_tag && device_type == EMSdevice::DeviceType::WATER && tag >= DeviceValue::DeviceValueTAG::TAG_DHW3) {
+ snprintf(uniq_id, sizeof(uniq_id), "solar_wwc%d_%s", tag - DeviceValue::DeviceValueTAG::TAG_DHW1 + 1, entity);
+ } else if (has_tag && device_type == EMSdevice::DeviceType::WATER && tag >= DeviceValue::DeviceValueTAG::TAG_DHW1) {
+ snprintf(uniq_id, sizeof(uniq_id), "mixer_wwc%d_%s", tag - DeviceValue::DeviceValueTAG::TAG_DHW1 + 1, entity);
+ } else {
+ snprintf(uniq_id, sizeof(uniq_id), "%s_%s", device_name, entity_with_tag);
+ }
} else {
// entity_format is 0, the old v3.4 style
// take en_name and replace all spaces
@@ -854,7 +868,13 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
strlcpy(uniq_s, en_name, sizeof(uniq_s));
Helpers::replace_char(uniq_s, ' ', '_');
Helpers::replace_char(uniq_s, '+', '2'); //changes 'eco+_switch_off' to 'eco2_switch_off' (HA ignores '+')
- if (has_tag) {
+ if (has_tag && (device_type == EMSdevice::DeviceType::BOILER || device_type == EMSdevice::DeviceType::THERMOSTAT) && tag == DeviceValue::DeviceValueTAG::TAG_DHW1) {
+ snprintf(uniq_id, sizeof(uniq_id), "%s_%s", device_name, Helpers::toLower(uniq_s).c_str());
+ } else if (has_tag && device_type == EMSdevice::DeviceType::WATER && tag >= DeviceValue::DeviceValueTAG::TAG_DHW3) {
+ snprintf(uniq_id, sizeof(uniq_id), "solar_wwc%d_%s", tag - DeviceValue::DeviceValueTAG::TAG_DHW1 + 1, Helpers::toLower(uniq_s).c_str());
+ } else if (has_tag && device_type == EMSdevice::DeviceType::WATER && tag >= DeviceValue::DeviceValueTAG::TAG_DHW1) {
+ snprintf(uniq_id, sizeof(uniq_id), "mixer_wwc%d_%s", tag - DeviceValue::DeviceValueTAG::TAG_DHW1 + 1, Helpers::toLower(uniq_s).c_str());
+ } else if (has_tag) {
snprintf(uniq_id, sizeof(uniq_id), "%s_%s_%s", device_name, DeviceValue::DeviceValueTAG_s[tag][0], Helpers::toLower(uniq_s).c_str());
} else {
snprintf(uniq_id, sizeof(uniq_id), "%s_%s", device_name, Helpers::toLower(uniq_s).c_str());
diff --git a/src/mqtt.h b/src/mqtt.h
index a50b23ff9..dca935d8c 100644
--- a/src/mqtt.h
+++ b/src/mqtt.h
@@ -36,7 +36,7 @@ using mqtt_sub_function_p = std::function;
class Mqtt {
public:
enum discoveryType : uint8_t { HOMEASSISTANT, DOMOTICZ, DOMOTICZ_LATEST };
- enum entityFormat : uint8_t { SINGLE_LONG, SINGLE_SHORT, MULTI_SHORT };
+ enum entityFormat : uint8_t { SINGLE_LONG, SINGLE_SHORT, MULTI_SHORT, SINGLE_OLD };
void loop();
void start();
diff --git a/src/system.cpp b/src/system.cpp
index 743ab1a47..3279adfee 100644
--- a/src/system.cpp
+++ b/src/system.cpp
@@ -1120,7 +1120,7 @@ bool System::check_upgrade(bool factory_settings) {
missing_version = (settingsVersion.empty() || (settingsVersion.length() < 5));
if (missing_version) {
LOG_WARNING("No version information found (%s)", settingsVersion.c_str());
- settingsVersion = "3.6.4"; // this was the last stable version
+ settingsVersion = "3.5.0"; // this was the last stable version without version info
}
}
@@ -1154,6 +1154,13 @@ bool System::check_upgrade(bool factory_settings) {
mqttSettings.entity_format = 0; // use old Entity ID format from v3.4
return StateUpdateResult::CHANGED;
});
+ } else if (settings_version.major()== 3 && settings_version.minor() <= 6) {
+ LOG_INFO("Setting MQTT Entity ID format to v3.6 format");
+ EMSESP::esp8266React.getMqttSettingsService()->update([&](MqttSettings & mqttSettings) {
+ mqttSettings.entity_format = 3; // use old Entity ID format from v3.6
+ return StateUpdateResult::CHANGED;
+ });
+
}
// Network Settings Wifi tx_power is now using the value * 4.
diff --git a/src/version.h b/src/version.h
index 702d461f9..b2172a0a9 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1 +1 @@
-#define EMSESP_APP_VERSION "3.7.0-dev.4"
+#define EMSESP_APP_VERSION "3.7.0-dev.5"