Skip to content

Commit

Permalink
minor cleanup and testing
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Dec 17, 2022
1 parent 147be12 commit 4b7bbb3
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 50 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG_LATEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## **IMPORTANT! BREAKING CHANGES**

- When upgrading to v3.5 for the first time from v3.4 on a BBQKees Gateway board you will need to use the [EMS-EPS Flasher](https://github.com/emsesp/EMS-ESP-Flasher/releases) to correctly re-partition the flash. Make sure you backup the settings and customizations from the WebUI (System->Upload/Download) and restore after the upgrade.
- Since 3.5.0b11 we have added support for multiple EMS-ESPs [#759] as an optional setting in MQTT. When this is enabled, which is now the default, all MQTT Discovery Entity IDs will include the base name and the shortname of the EMS-ESP device entity. For example what was previously `sensor.boiler_actual_boiler_temperature` will become `sensor.ems-esp_boiler_boiltemp`. If you still want to use the old format and retain the history and script compatibility in Home Assistant then set this back to the old format.
- Support for multiple EMS-ESPs [#759] has been added as an optional setting for MQTT. When enabled, which is now the default, all MQTT Discovery Entity IDs will include the MQTT base name and the shortname of the EMS-ESP device entity. For example what was previously `sensor.boiler_actual_boiler_temperature` will now become `sensor.ems_esp_boiler_boiltemp`. If you still want to use the old format and retain the history and script compatibility in Home Assistant then set this back to the old format.

## Added

Expand Down
64 changes: 32 additions & 32 deletions interface/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@mui/material": "^5.11.0",
"@table-library/react-table-library": "4.0.23",
"@types/lodash": "^4.14.191",
"@types/node": "^18.11.15",
"@types/node": "^18.11.16",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"@types/react-router-dom": "^5.3.3",
Expand All @@ -27,7 +27,7 @@
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-icons": "^4.7.1",
"react-router-dom": "^6.4.5",
"react-router-dom": "^6.5.0",
"react-scripts": "5.0.1",
"sockette": "^2.0.6",
"typesafe-i18n": "^5.17.1",
Expand Down
23 changes: 8 additions & 15 deletions src/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,28 +989,21 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
snprintf(entity_with_tag, sizeof(entity_with_tag), "%s", entity);
}

// build unique identifier which will be used in the topic, also used as object_id
// and becomes the Entity ID in HA
// build unique identifier also used as object_id and becomes the Entity ID in HA
char uniq_id[70];
if (Mqtt::multiple_instances()) {
// prefix base name to each uniq_id and use the shortname
snprintf(uniq_id, sizeof(uniq_id), "%s_%s_%s", mqtt_basename_.c_str(), device_name, entity_with_tag);
} else {
// old v3.4 style
// if there is no en_name take the shortname
if (en_name == nullptr || strlen(en_name) == 0) {
strlcpy(uniq_id, entity, sizeof(uniq_id));
// take en_name and replace all spaces and lowercase it
char uniq_s[40];
strlcpy(uniq_s, en_name, sizeof(uniq_s));
Helpers::replace_char(uniq_s, ' ', '_');
if (EMSdevice::tag_to_string(tag).empty()) {
snprintf(uniq_id, sizeof(uniq_id), "%s_%s", device_name, Helpers::toLower(uniq_s).c_str());
} else {
// old v3.4 style
// take en_name and replace all spaces and lowercase it
char uniq_s[40];
strlcpy(uniq_s, en_name, sizeof(uniq_s));
Helpers::replace_char(uniq_s, ' ', '_');
if (EMSdevice::tag_to_string(tag).empty()) {
snprintf(uniq_id, sizeof(uniq_id), "%s_%s", device_name, Helpers::toLower(uniq_s).c_str());
} else {
snprintf(uniq_id, sizeof(uniq_id), "%s_%s_%s", device_name, EMSdevice::tag_to_string(tag).c_str(), Helpers::toLower(uniq_s).c_str());
}
snprintf(uniq_id, sizeof(uniq_id), "%s_%s_%s", device_name, EMSdevice::tag_to_string(tag).c_str(), Helpers::toLower(uniq_s).c_str());
}
}

Expand Down

0 comments on commit 4b7bbb3

Please sign in to comment.