Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/emsesp/EMS-ESP32 into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Dec 17, 2022
2 parents a529879 + 88c98ef commit 94b75dd
Show file tree
Hide file tree
Showing 20 changed files with 92 additions and 76 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] and also renamed the HA Entity IDs. For example what was previously `sensor.boiler_actual_boiler_temperature` is now using the shortname form `sensor.boiler_boiltemp` as opposed to the English description. Unfortunately this does means any HA dashboards, automation scripts and integrations (e.g. Grafana) need to be adjusted accordingly.
- 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
4 changes: 2 additions & 2 deletions interface/src/framework/mqtt/MqttSettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ const MqttSettingsForm: FC = () => {
margin="normal"
select
>
<MenuItem value="false">{LL.MQTT_ENTITY_FORMAT_0()}</MenuItem>
<MenuItem value="true">{LL.MQTT_ENTITY_FORMAT_1()}</MenuItem>
<MenuItem value={false as any}>{LL.MQTT_ENTITY_FORMAT_0()}</MenuItem>
<MenuItem value={true as any}>{LL.MQTT_ENTITY_FORMAT_1()}</MenuItem>
</ValidatedTextField>
</Grid>
</Grid>
Expand Down
8 changes: 4 additions & 4 deletions interface/src/i18n/de/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const de: Translation = {
TEMPERATURE: 'Temperatur',
PHY_TYPE: 'Eth PHY Typ',
DISABLED: 'deaktiviert',
TX_MODE: 'Tx Mode',
TX_MODE: 'Tx Modus',
HARDWARE: 'Hardware',
EMS_BUS: '{{BUS|EMS BUS}}',
GENERAL_OPTIONS: 'Allgemeine Optionen',
Expand Down Expand Up @@ -249,9 +249,9 @@ const de: Translation = {
MQTT_INT_HEARTBEAT: 'Heartbeat',
MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Standard',
MQTT_ENTITY_FORMAT: 'Entity ID format',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name',
MQTT_ENTITY_FORMAT_1: 'Multiple instances, short name',
MQTT_ENTITY_FORMAT: 'Entitäts-ID Format',
MQTT_ENTITY_FORMAT_0: 'Einzelinstanz, Langname (veraltet)',
MQTT_ENTITY_FORMAT_1: 'Mehrfachinstanzen, MQTT-Namen',
MQTT_CLEAN_SESSION: 'Setze `Clean Session`',
MQTT_RETAIN_FLAG: 'Setze `Retain flag` immer',
INACTIVE: 'Inaktiv',
Expand Down
2 changes: 1 addition & 1 deletion interface/src/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const en: Translation = {
MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Default',
MQTT_ENTITY_FORMAT: 'Entity ID format',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name (depreciated)',
MQTT_ENTITY_FORMAT_1: 'Multiple instances, short name',
MQTT_CLEAN_SESSION: 'Set Clean Session',
MQTT_RETAIN_FLAG: 'Always set Retain flag',
Expand Down
2 changes: 1 addition & 1 deletion interface/src/i18n/fr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const fr: Translation = {
MQTT_QUEUE: 'Queue MQTT',
DEFAULT: 'Défaut',
MQTT_ENTITY_FORMAT: 'Entity ID format',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name (depreciated)',
MQTT_ENTITY_FORMAT_1: 'Multiple instances, short name',
MQTT_CLEAN_SESSION: 'Flag Clean Session',
MQTT_RETAIN_FLAG: 'Toujours activer le Retain Flag',
Expand Down
2 changes: 1 addition & 1 deletion interface/src/i18n/nl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const nl: Translation = {
MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Default',
MQTT_ENTITY_FORMAT: 'Entity ID format',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name (depreciated)',
MQTT_ENTITY_FORMAT_1: 'Multiple instances, short name',
MQTT_CLEAN_SESSION: 'Clean Session aan',
MQTT_RETAIN_FLAG: 'Retain flag aan',
Expand Down
2 changes: 1 addition & 1 deletion interface/src/i18n/no/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const no: Translation = {
MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Standard',
MQTT_ENTITY_FORMAT: 'Entity ID format',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name (depreciated)',
MQTT_ENTITY_FORMAT_1: 'Multiple instances, short name',
MQTT_CLEAN_SESSION: 'Benytt Clean Session',
MQTT_RETAIN_FLAG: 'Alltid sett Retain flag',
Expand Down
2 changes: 1 addition & 1 deletion interface/src/i18n/pl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const pl: BaseTranslation = {
MQTT_QUEUE: 'Kolejka MQTT',
DEFAULT: '{{Pozostałe|Domyślna|}}',
MQTT_ENTITY_FORMAT: 'Entity ID format',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name (depreciated)',
MQTT_ENTITY_FORMAT_1: 'Multiple instances, short name',
MQTT_CLEAN_SESSION: 'Ustawiaj flagę "Clean session"',
MQTT_RETAIN_FLAG: 'Ustawiaj flagę "Retain"',
Expand Down
2 changes: 1 addition & 1 deletion interface/src/i18n/se/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const se: Translation = {
MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Standard',
MQTT_ENTITY_FORMAT: 'Entity ID format',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name (depreciated)',
MQTT_ENTITY_FORMAT_1: 'Multiple instances, short name',
MQTT_CLEAN_SESSION: 'Använd "Clean Session"-flaggan',
MQTT_RETAIN_FLAG: 'Använd "Always Retain"-flaggan',
Expand Down
16 changes: 7 additions & 9 deletions lib/framework/MqttSettingsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ StateUpdateResult MqttSettings::update(JsonObject & root, MqttSettings & setting
changed = true;
}

if (newSettings.multiple_instances != settings.multiple_instances) {
changed = true;
}

// if both settings are stored from older version, HA has priority
if (newSettings.ha_enabled && newSettings.publish_single) {
newSettings.publish_single = false;
Expand Down Expand Up @@ -258,44 +262,38 @@ StateUpdateResult MqttSettings::update(JsonObject & root, MqttSettings & setting

if (newSettings.publish_time_boiler != settings.publish_time_boiler) {
emsesp::EMSESP::mqtt_.set_publish_time_boiler(newSettings.publish_time_boiler);
changed = true;
}

if (newSettings.publish_time_thermostat != settings.publish_time_thermostat) {
emsesp::EMSESP::mqtt_.set_publish_time_thermostat(newSettings.publish_time_thermostat);
changed = true;
}

if (newSettings.publish_time_solar != settings.publish_time_solar) {
emsesp::EMSESP::mqtt_.set_publish_time_solar(newSettings.publish_time_solar);
changed = true;
}

if (newSettings.publish_time_mixer != settings.publish_time_mixer) {
emsesp::EMSESP::mqtt_.set_publish_time_mixer(newSettings.publish_time_mixer);
changed = true;
}

if (newSettings.publish_time_other != settings.publish_time_other) {
emsesp::EMSESP::mqtt_.set_publish_time_other(newSettings.publish_time_other);
changed = true;
}

if (newSettings.publish_time_sensor != settings.publish_time_sensor) {
emsesp::EMSESP::mqtt_.set_publish_time_sensor(newSettings.publish_time_sensor);
changed = true;
}

if (newSettings.publish_time_heartbeat != settings.publish_time_heartbeat) {
emsesp::EMSESP::mqtt_.set_publish_time_heartbeat(newSettings.publish_time_heartbeat);
changed = true;
}

// save the new settings
settings = newSettings;

if (changed) {
emsesp::EMSESP::mqtt_.reset_mqtt();
}

settings = newSettings;

return StateUpdateResult::CHANGED;
}
9 changes: 5 additions & 4 deletions src/analogsensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,15 @@ void AnalogSensor::publish_values(const bool force) {
}
config["val_tpl"] = str;

char uniq_s[70];
if (Mqtt::multiple_instances()) {
snprintf(str, sizeof(str), "%s_analogsensor_%d", Mqtt::basename().c_str(), sensor.gpio());
snprintf(uniq_s, sizeof(uniq_s), "%s_analogsensor_%d", Mqtt::basename().c_str(), sensor.gpio());
} else {
snprintf(str, sizeof(str), "analogsensor_%d", sensor.gpio());
snprintf(uniq_s, sizeof(uniq_s), "analogsensor_%d", sensor.gpio());
}

config["object_id"] = str;
config["uniq_id"] = str; // same as object_id
config["object_id"] = uniq_s;
config["uniq_id"] = uniq_s; // same as object_id

snprintf(str, sizeof(str), "%s", sensor.name().c_str());
config["name"] = str;
Expand Down
9 changes: 5 additions & 4 deletions src/dallassensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,14 +518,15 @@ void DallasSensor::publish_values(const bool force) {
}
config["val_tpl"] = str;

char uniq_s[70];
if (Mqtt::multiple_instances()) {
snprintf(str, sizeof(str), "%s_dallassensor_%s", Mqtt::basename().c_str(), sensor.id().c_str());
snprintf(uniq_s, sizeof(uniq_s), "%s_dallassensor_%s", Mqtt::basename().c_str(), sensor.id().c_str());
} else {
snprintf(str, sizeof(str), "dallassensor_%s", sensor.id().c_str());
snprintf(uniq_s, sizeof(uniq_s), "dallassensor_%s", sensor.id().c_str());
}

config["object_id"] = str;
config["uniq_id"] = str; // same as object_id
config["object_id"] = uniq_s;
config["uniq_id"] = uniq_s; // same as object_id

snprintf(str, sizeof(str), "%s", sensor.name().c_str());
config["name"] = str;
Expand Down
4 changes: 4 additions & 0 deletions src/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,10 @@ std::string Helpers::toUpper(std::string const & s) {

// replace char in char string
void Helpers::replace_char(char * str, char find, char replace) {
if (str == nullptr) {
return;
}

int i = 0;

while (str[i] != '\0') {
Expand Down
2 changes: 1 addition & 1 deletion src/locale_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ MAKE_PSTR(tag_boiler_data_ww_mqtt, "ww")
MAKE_PSTR(tag_device_data_ww_mqtt, "")

// Home Assistant - this is special and has no translations
MAKE_PSTR_LIST(climate, "HA climate config creation")
MAKE_PSTR_LIST(climate, "")

// syslog
MAKE_PSTR_LIST(list_syslog_level, "off", "emerg", "alert", "crit", "error", "warn", "notice", "info", "debug", "trace", "all")
Expand Down
Loading

0 comments on commit 94b75dd

Please sign in to comment.