mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
HA mqtt compatible setting
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
- heatpump dhw stop temperatures [#1624](https://github.com/emsesp/EMS-ESP32/issues/1624)
|
- heatpump dhw stop temperatures [#1624](https://github.com/emsesp/EMS-ESP32/issues/1624)
|
||||||
- reset history [#1695](https://github.com/emsesp/EMS-ESP32/issues/1695)
|
- 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)
|
- 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
|
## Fixed
|
||||||
|
|
||||||
@@ -28,3 +29,4 @@
|
|||||||
- store digital out states to nvs
|
- store digital out states to nvs
|
||||||
- Refresh UI - moving settings to one location [#1665](https://github.com/emsesp/EMS-ESP32/issues/1665)
|
- Refresh UI - moving settings to one location [#1665](https://github.com/emsesp/EMS-ESP32/issues/1665)
|
||||||
- rename DeviceValueTypes, add UINT32 for custom entities
|
- rename DeviceValueTypes, add UINT32 for custom entities
|
||||||
|
- dynamic register dhw circuits for thermostat
|
||||||
|
|||||||
@@ -374,6 +374,7 @@ const MqttSettings: FC = () => {
|
|||||||
select
|
select
|
||||||
>
|
>
|
||||||
<MenuItem value={0}>{LL.MQTT_ENTITY_FORMAT_0()}</MenuItem>
|
<MenuItem value={0}>{LL.MQTT_ENTITY_FORMAT_0()}</MenuItem>
|
||||||
|
<MenuItem value={3}>{LL.MQTT_ENTITY_FORMAT_1()} (v3.6)</MenuItem>
|
||||||
<MenuItem value={1}>{LL.MQTT_ENTITY_FORMAT_1()}</MenuItem>
|
<MenuItem value={1}>{LL.MQTT_ENTITY_FORMAT_1()}</MenuItem>
|
||||||
<MenuItem value={2}>{LL.MQTT_ENTITY_FORMAT_2()}</MenuItem>
|
<MenuItem value={2}>{LL.MQTT_ENTITY_FORMAT_2()}</MenuItem>
|
||||||
</TextField>
|
</TextField>
|
||||||
|
|||||||
22
src/mqtt.cpp
22
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) {
|
} else if (Mqtt::entity_format() == entityFormat::SINGLE_SHORT) {
|
||||||
// shortname, no mqtt base. This is the default version.
|
// shortname, no mqtt base. This is the default version.
|
||||||
snprintf(uniq_id, sizeof(uniq_id), "%s_%s", device_name, entity_with_tag);
|
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 {
|
} else {
|
||||||
// entity_format is 0, the old v3.4 style
|
// entity_format is 0, the old v3.4 style
|
||||||
// take en_name and replace all spaces
|
// 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));
|
strlcpy(uniq_s, en_name, sizeof(uniq_s));
|
||||||
Helpers::replace_char(uniq_s, ' ', '_');
|
Helpers::replace_char(uniq_s, ' ', '_');
|
||||||
Helpers::replace_char(uniq_s, '+', '2'); //changes 'eco+_switch_off' to 'eco2_switch_off' (HA ignores '+')
|
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());
|
snprintf(uniq_id, sizeof(uniq_id), "%s_%s_%s", device_name, DeviceValue::DeviceValueTAG_s[tag][0], Helpers::toLower(uniq_s).c_str());
|
||||||
} else {
|
} else {
|
||||||
snprintf(uniq_id, sizeof(uniq_id), "%s_%s", device_name, Helpers::toLower(uniq_s).c_str());
|
snprintf(uniq_id, sizeof(uniq_id), "%s_%s", device_name, Helpers::toLower(uniq_s).c_str());
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ using mqtt_sub_function_p = std::function<bool(const char * message)>;
|
|||||||
class Mqtt {
|
class Mqtt {
|
||||||
public:
|
public:
|
||||||
enum discoveryType : uint8_t { HOMEASSISTANT, DOMOTICZ, DOMOTICZ_LATEST };
|
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 loop();
|
||||||
void start();
|
void start();
|
||||||
|
|||||||
@@ -1120,7 +1120,7 @@ bool System::check_upgrade(bool factory_settings) {
|
|||||||
missing_version = (settingsVersion.empty() || (settingsVersion.length() < 5));
|
missing_version = (settingsVersion.empty() || (settingsVersion.length() < 5));
|
||||||
if (missing_version) {
|
if (missing_version) {
|
||||||
LOG_WARNING("No version information found (%s)", settingsVersion.c_str());
|
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
|
mqttSettings.entity_format = 0; // use old Entity ID format from v3.4
|
||||||
return StateUpdateResult::CHANGED;
|
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.
|
// Network Settings Wifi tx_power is now using the value * 4.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "3.7.0-dev.4"
|
#define EMSESP_APP_VERSION "3.7.0-dev.5"
|
||||||
|
|||||||
Reference in New Issue
Block a user