Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/proddy/EMS-ESP32 into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Dec 16, 2022
2 parents 1350638 + b6de431 commit 4bd6db3
Show file tree
Hide file tree
Showing 16 changed files with 171 additions and 148 deletions.
210 changes: 105 additions & 105 deletions interface/package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@msgpack/msgpack": "^2.8.0",
"@mui/icons-material": "^5.10.16",
"@mui/material": "^5.10.17",
"@mui/icons-material": "^5.11.0",
"@mui/material": "^5.11.0",
"@table-library/react-table-library": "4.0.23",
"@types/lodash": "^4.14.191",
"@types/node": "^18.11.12",
"@types/node": "^18.11.15",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"@types/react-router-dom": "^5.3.3",
Expand Down
54 changes: 30 additions & 24 deletions interface/src/framework/mqtt/MqttSettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ const MqttSettingsForm: FC = () => {
control={<Checkbox name="mqtt_retain" checked={data.mqtt_retain} onChange={updateFormValue} />}
label={LL.MQTT_RETAIN_FLAG()}
/>

<Typography sx={{ pt: 2 }} variant="h6" color="primary">
{LL.FORMATTING()}
</Typography>
Expand Down Expand Up @@ -214,41 +215,46 @@ const MqttSettingsForm: FC = () => {
<Grid container spacing={1} direction="row" justifyContent="flex-start" alignItems="flex-start">
<Grid item>
<BlockFormControlLabel
sx={{ pb: 2 }}
sx={{ pb: 1 }}
control={<Checkbox name="ha_enabled" checked={data.ha_enabled} onChange={updateFormValue} />}
label={LL.MQTT_PUBLISH_TEXT_3()}
/>
</Grid>
{data.ha_enabled && (
<>
<Grid item>
<BlockFormControlLabel
control={
<Checkbox
name="multiple_instances"
checked={data.multiple_instances}
onChange={updateFormValue}
/>
}
label={LL.MQTT_MULTIPLE_INSTANCES()}
/>
</Grid>
<Grid item sx={{ pb: 3 }}>
<ValidatedTextField
name="discovery_prefix"
label={LL.MQTT_PUBLISH_TEXT_4()}
fullWidth
variant="outlined"
value={data.discovery_prefix}
onChange={updateFormValue}
size="small"
/>
<Grid container spacing={1} direction="row" justifyContent="flex-start" alignItems="flex-start">
<Grid item>
<ValidatedTextField
name="discovery_prefix"
label={LL.MQTT_PUBLISH_TEXT_4()}
fullWidth
variant="outlined"
value={data.discovery_prefix}
onChange={updateFormValue}
margin="normal"
/>
</Grid>
<Grid item>
<ValidatedTextField
name="multiple_instances"
label={LL.MQTT_ENTITY_FORMAT()}
value={data.multiple_instances}
fullWidth
variant="outlined"
onChange={updateFormValue}
margin="normal"
select
>
<MenuItem value="false">{LL.MQTT_ENTITY_FORMAT_0()}</MenuItem>
<MenuItem value="true">{LL.MQTT_ENTITY_FORMAT_1()}</MenuItem>
</ValidatedTextField>
</Grid>
</Grid>
</>
)}
</Grid>
)}
<Typography variant="h6" color="primary">
<Typography sx={{ pt: 2 }} variant="h6" color="primary">
{LL.MQTT_PUBLISH_INTERVALS()}&nbsp;(0=auto)
</Typography>
<Grid container spacing={1} direction="row" justifyContent="flex-start" alignItems="flex-start">
Expand Down
4 changes: 3 additions & 1 deletion interface/src/i18n/de/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ const de: Translation = {
MQTT_INT_HEARTBEAT: 'Heartbeat',
MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Standard',
MQTT_MULTIPLE_INSTANCES: 'Erlaube EMS-ESP Mehrfachinstanzen',
MQTT_ENTITY_FORMAT: 'Entity ID format',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name',
MQTT_ENTITY_FORMAT_1: 'Multiple instances, short name',
MQTT_CLEAN_SESSION: 'Setze `Clean Session`',
MQTT_RETAIN_FLAG: 'Setze `Retain flag` immer',
INACTIVE: 'Inaktiv',
Expand Down
4 changes: 3 additions & 1 deletion interface/src/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ const en: Translation = {
MQTT_INT_HEARTBEAT: 'Heartbeat',
MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Default',
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
MQTT_ENTITY_FORMAT: 'Entity ID format',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name',
MQTT_ENTITY_FORMAT_1: 'Multiple instances, short name',
MQTT_CLEAN_SESSION: 'Set Clean Session',
MQTT_RETAIN_FLAG: 'Always set Retain flag',
INACTIVE: 'Inactive',
Expand Down
4 changes: 3 additions & 1 deletion interface/src/i18n/fr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ const fr: Translation = {
MQTT_INT_HEARTBEAT: 'Battements',
MQTT_QUEUE: 'Queue MQTT',
DEFAULT: 'Défaut',
MQTT_MULTIPLE_INSTANCES: 'Activer plusieurs instances de EMS-ESP',
MQTT_ENTITY_FORMAT: 'Entity ID format',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name',
MQTT_ENTITY_FORMAT_1: 'Multiple instances, short name',
MQTT_CLEAN_SESSION: 'Flag Clean Session',
MQTT_RETAIN_FLAG: 'Toujours activer le Retain Flag',
INACTIVE: 'Inactif',
Expand Down
4 changes: 3 additions & 1 deletion interface/src/i18n/nl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ const nl: Translation = {
MQTT_INT_HEARTBEAT: 'Heartbeat',
MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Default',
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
MQTT_ENTITY_FORMAT: 'Entity ID format',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name',
MQTT_ENTITY_FORMAT_1: 'Multiple instances, short name',
MQTT_CLEAN_SESSION: 'Clean Session aan',
MQTT_RETAIN_FLAG: 'Retain flag aan',
INACTIVE: 'Inactief',
Expand Down
4 changes: 3 additions & 1 deletion interface/src/i18n/no/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ const no: Translation = {
MQTT_INT_HEARTBEAT: 'Heartbeat',
MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Standard',
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
MQTT_ENTITY_FORMAT: 'Entity ID format',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name',
MQTT_ENTITY_FORMAT_1: 'Multiple instances, short name',
MQTT_CLEAN_SESSION: 'Benytt Clean Session',
MQTT_RETAIN_FLAG: 'Alltid sett Retain flag',
INACTIVE: 'Innaktiv',
Expand Down
4 changes: 3 additions & 1 deletion interface/src/i18n/pl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ const pl: BaseTranslation = {
MQTT_INT_HEARTBEAT: 'Heartbeat',
MQTT_QUEUE: 'Kolejka MQTT',
DEFAULT: '{{Pozostałe|Domyślna|}}',
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
MQTT_ENTITY_FORMAT: 'Entity ID format',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name',
MQTT_ENTITY_FORMAT_1: 'Multiple instances, short name',
MQTT_CLEAN_SESSION: 'Ustawiaj flagę "Clean session"',
MQTT_RETAIN_FLAG: 'Ustawiaj flagę "Retain"',
INACTIVE: 'nieaktywny',
Expand Down
4 changes: 3 additions & 1 deletion interface/src/i18n/se/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ const se: Translation = {
MQTT_INT_HEARTBEAT: 'Heartbeat',
MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Standard',
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
MQTT_ENTITY_FORMAT: 'Entity ID format',
MQTT_ENTITY_FORMAT_0: 'Single instance, long name',
MQTT_ENTITY_FORMAT_1: 'Multiple instances, short name',
MQTT_CLEAN_SESSION: 'Använd "Clean Session"-flaggan',
MQTT_RETAIN_FLAG: 'Använd "Always Retain"-flaggan',
INACTIVE: 'Inaktiv',
Expand Down
5 changes: 2 additions & 3 deletions lib/framework/MqttSettingsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,8 @@ StateUpdateResult MqttSettings::update(JsonObject & root, MqttSettings & setting
newSettings.keepAlive = root["keep_alive"] | FACTORY_MQTT_KEEP_ALIVE;
newSettings.cleanSession = root["clean_session"] | FACTORY_MQTT_CLEAN_SESSION;
newSettings.multiple_instances = root["multiple_instances"] | FACTORY_MQTT_MULTIPLE_INSTANCES;

newSettings.mqtt_qos = root["mqtt_qos"] | EMSESP_DEFAULT_MQTT_QOS;
newSettings.mqtt_retain = root["mqtt_retain"] | EMSESP_DEFAULT_MQTT_RETAIN;
newSettings.mqtt_qos = root["mqtt_qos"] | EMSESP_DEFAULT_MQTT_QOS;
newSettings.mqtt_retain = root["mqtt_retain"] | EMSESP_DEFAULT_MQTT_RETAIN;

newSettings.publish_time_boiler = root["publish_time_boiler"] | EMSESP_DEFAULT_PUBLISH_TIME;
newSettings.publish_time_thermostat = root["publish_time_thermostat"] | EMSESP_DEFAULT_PUBLISH_TIME;
Expand Down
2 changes: 1 addition & 1 deletion lib/framework/MqttSettingsService.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static String generateClientId() {
#endif

#ifndef FACTORY_MQTT_MULTIPLE_INSTANCES
#define FACTORY_MQTT_MULTIPLE_INSTANCES false
#define FACTORY_MQTT_MULTIPLE_INSTANCES true
#endif

class MqttSettings {
Expand Down
2 changes: 1 addition & 1 deletion mock-api/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ mqtt_settings = {
client_id: 'ems-esp',
keep_alive: 60,
clean_session: true,
multiple_instances: false,
multiple_instances: true,
publish_time_boiler: 10,
publish_time_thermostat: 10,
publish_time_solar: 10,
Expand Down
9 changes: 6 additions & 3 deletions src/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ void Mqtt::publish_ha_sensor_config(DeviceValue & dv, const std::string & model,
publish_ha_sensor_config(dv.type,
dv.tag,
dv.get_fullname().c_str(),
(dv.fullname ? dv.fullname[0] : nullptr), // EN name
dv.device_type,
dv.short_name,
dv.uom,
Expand All @@ -952,7 +953,7 @@ void Mqtt::publish_system_ha_sensor_config(uint8_t type, const char * name, cons
JsonArray ids = dev_json.createNestedArray("ids");
ids.add("ems-esp");

publish_ha_sensor_config(type, DeviceValueTAG::TAG_HEARTBEAT, name, EMSdevice::DeviceType::SYSTEM, entity, uom, false, false, nullptr, 0, 0, 0, dev_json);
publish_ha_sensor_config(type, DeviceValueTAG::TAG_HEARTBEAT, name, name, EMSdevice::DeviceType::SYSTEM, entity, uom, false, false, nullptr, 0, 0, 0, dev_json);
}

// MQTT discovery configs
Expand All @@ -961,6 +962,7 @@ void Mqtt::publish_system_ha_sensor_config(uint8_t type, const char * name, cons
void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdevice::DeviceValueType
uint8_t tag, // EMSdevice::DeviceValueTAG
const char * const fullname, // fullname, already translated
const char * const en_name, // original name
const uint8_t device_type, // EMSdevice::DeviceType
const char * const entity, // same as shortname
const uint8_t uom, // EMSdevice::DeviceValueUOM (0=NONE)
Expand Down Expand Up @@ -990,10 +992,11 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
// build unique identifier which will be used in the topic, also used as object_id
char uniq_id[70];
if (Mqtt::multiple_instances()) {
// prefix base name to each uniq_id
// 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 {
snprintf(uniq_id, sizeof(uniq_id), "%s_%s", device_name, entity_with_tag);
// old v3.4 style
snprintf(uniq_id, sizeof(uniq_id), "%s_%s", device_name, en_name);
}

// build a config topic that will be prefix onto a HA type (e.g. number, switch)
Expand Down
1 change: 1 addition & 0 deletions src/mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class Mqtt {
static void publish_ha_sensor_config(uint8_t type,
uint8_t tag,
const char * const fullname,
const char * const en_name,
const uint8_t device_type,
const char * const entity,
const uint8_t uom,
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define EMSESP_APP_VERSION "3.5.0b11"
#define EMSESP_APP_VERSION "3.5.0b12"

#if CONFIG_IDF_TARGET_ESP32C3
#define EMSESP_PLATFORM "ESP32-C3";
Expand Down

0 comments on commit 4bd6db3

Please sign in to comment.