add multiple_sessions

This commit is contained in:
proddy
2022-12-05 20:35:04 +01:00
parent ccc9e6dcfb
commit fd04f8be5a
13 changed files with 44 additions and 20 deletions

View File

@@ -162,6 +162,10 @@ const MqttSettingsForm: FC = () => {
</ValidatedTextField> </ValidatedTextField>
</Grid> </Grid>
</Grid> </Grid>
<BlockFormControlLabel
control={<Checkbox name="multiple_instances" checked={data.multiple_instances} onChange={updateFormValue} />}
label={LL.MQTT_MULTIPLE_INSTANCES()}
/>
<BlockFormControlLabel <BlockFormControlLabel
control={<Checkbox name="clean_session" checked={data.clean_session} onChange={updateFormValue} />} control={<Checkbox name="clean_session" checked={data.clean_session} onChange={updateFormValue} />}
label={LL.MQTT_CLEAN_SESSION()} label={LL.MQTT_CLEAN_SESSION()}

View File

@@ -247,6 +247,7 @@ const de: Translation = {
MQTT_INT_MIXER: 'Mischermodule', MQTT_INT_MIXER: 'Mischermodule',
MQTT_QUEUE: 'MQTT Queue', MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Standard', DEFAULT: 'Standard',
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
MQTT_CLEAN_SESSION: 'Setze `Clean Session`', MQTT_CLEAN_SESSION: 'Setze `Clean Session`',
MQTT_RETAIN_FLAG: 'Setze `Retain flag` immer', MQTT_RETAIN_FLAG: 'Setze `Retain flag` immer',
INACTIVE: 'Inaktiv', INACTIVE: 'Inaktiv',

View File

@@ -247,6 +247,7 @@ const en: Translation = {
MQTT_INT_MIXER: 'Mixer Modules', MQTT_INT_MIXER: 'Mixer Modules',
MQTT_QUEUE: 'MQTT Queue', MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Default', DEFAULT: 'Default',
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
MQTT_CLEAN_SESSION: 'Set Clean Session', MQTT_CLEAN_SESSION: 'Set Clean Session',
MQTT_RETAIN_FLAG: 'Always set Retain flag', MQTT_RETAIN_FLAG: 'Always set Retain flag',
INACTIVE: 'Inactive', INACTIVE: 'Inactive',

View File

@@ -247,6 +247,7 @@ const nl: Translation = {
MQTT_INT_MIXER: 'Mixer Modules', MQTT_INT_MIXER: 'Mixer Modules',
MQTT_QUEUE: 'MQTT Queue', MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Default', DEFAULT: 'Default',
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
MQTT_CLEAN_SESSION: 'Clean Session aan', MQTT_CLEAN_SESSION: 'Clean Session aan',
MQTT_RETAIN_FLAG: 'Retain flag aan', MQTT_RETAIN_FLAG: 'Retain flag aan',
INACTIVE: 'Inactief', INACTIVE: 'Inactief',

View File

@@ -247,6 +247,7 @@ const no: Translation = {
MQTT_INT_MIXER: 'Blandeventil', MQTT_INT_MIXER: 'Blandeventil',
MQTT_QUEUE: 'MQTT Queue', MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Standard', DEFAULT: 'Standard',
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
MQTT_CLEAN_SESSION: 'Benytt Clean Session', MQTT_CLEAN_SESSION: 'Benytt Clean Session',
MQTT_RETAIN_FLAG: 'Alltid sett Retain flag', MQTT_RETAIN_FLAG: 'Alltid sett Retain flag',
INACTIVE: 'Innaktiv', INACTIVE: 'Innaktiv',

View File

@@ -247,6 +247,7 @@ const pl: BaseTranslation = {
MQTT_INT_MIXER: 'Mieszacze', MQTT_INT_MIXER: 'Mieszacze',
MQTT_QUEUE: 'Kolejka MQTT', MQTT_QUEUE: 'Kolejka MQTT',
DEFAULT: '{{Pozostałe|Domyślna|}}', DEFAULT: '{{Pozostałe|Domyślna|}}',
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
MQTT_CLEAN_SESSION: 'Ustawiaj flagę "Clean session"', MQTT_CLEAN_SESSION: 'Ustawiaj flagę "Clean session"',
MQTT_RETAIN_FLAG: 'Ustawiaj flagę "Retain"', MQTT_RETAIN_FLAG: 'Ustawiaj flagę "Retain"',
INACTIVE: 'nieaktywny', INACTIVE: 'nieaktywny',

View File

@@ -247,6 +247,7 @@ const se: Translation = {
MQTT_INT_MIXER: 'Blandarventiler', MQTT_INT_MIXER: 'Blandarventiler',
MQTT_QUEUE: 'MQTT Queue', MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Standard', DEFAULT: 'Standard',
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
MQTT_CLEAN_SESSION: 'Använd "Clean Session"-flaggan', MQTT_CLEAN_SESSION: 'Använd "Clean Session"-flaggan',
MQTT_RETAIN_FLAG: 'Använd "Always Retain"-flaggan', MQTT_RETAIN_FLAG: 'Använd "Always Retain"-flaggan',
INACTIVE: 'Inaktiv', INACTIVE: 'Inaktiv',

View File

@@ -29,6 +29,7 @@ export interface MqttSettings {
client_id: string; client_id: string;
keep_alive: number; keep_alive: number;
clean_session: boolean; clean_session: boolean;
multiple_instances: boolean;
publish_time_boiler: number; publish_time_boiler: number;
publish_time_thermostat: number; publish_time_thermostat: number;
publish_time_solar: number; publish_time_solar: number;

View File

@@ -145,15 +145,16 @@ void MqttSettingsService::configureMqtt() {
} }
void MqttSettings::read(MqttSettings & settings, JsonObject & root) { void MqttSettings::read(MqttSettings & settings, JsonObject & root) {
root["enabled"] = settings.enabled; root["enabled"] = settings.enabled;
root["host"] = settings.host; root["host"] = settings.host;
root["port"] = settings.port; root["port"] = settings.port;
root["base"] = settings.base; root["base"] = settings.base;
root["username"] = settings.username; root["username"] = settings.username;
root["password"] = settings.password; root["password"] = settings.password;
root["client_id"] = settings.clientId; root["client_id"] = settings.clientId;
root["keep_alive"] = settings.keepAlive; root["keep_alive"] = settings.keepAlive;
root["clean_session"] = settings.cleanSession; root["clean_session"] = settings.cleanSession;
root["multiple_instances"] = settings.multiple_instances;
// added by proddy for EMS-ESP // added by proddy for EMS-ESP
root["publish_time_boiler"] = settings.publish_time_boiler; root["publish_time_boiler"] = settings.publish_time_boiler;
@@ -176,17 +177,19 @@ StateUpdateResult MqttSettings::update(JsonObject & root, MqttSettings & setting
MqttSettings newSettings = {}; MqttSettings newSettings = {};
bool changed = false; bool changed = false;
newSettings.enabled = root["enabled"] | FACTORY_MQTT_ENABLED; newSettings.enabled = root["enabled"] | FACTORY_MQTT_ENABLED;
newSettings.host = root["host"] | FACTORY_MQTT_HOST; newSettings.host = root["host"] | FACTORY_MQTT_HOST;
newSettings.port = root["port"] | FACTORY_MQTT_PORT; newSettings.port = root["port"] | FACTORY_MQTT_PORT;
newSettings.base = root["base"] | FACTORY_MQTT_BASE; newSettings.base = root["base"] | FACTORY_MQTT_BASE;
newSettings.username = root["username"] | FACTORY_MQTT_USERNAME; newSettings.username = root["username"] | FACTORY_MQTT_USERNAME;
newSettings.password = root["password"] | FACTORY_MQTT_PASSWORD; newSettings.password = root["password"] | FACTORY_MQTT_PASSWORD;
newSettings.clientId = root["client_id"] | FACTORY_MQTT_CLIENT_ID; newSettings.clientId = root["client_id"] | FACTORY_MQTT_CLIENT_ID;
newSettings.keepAlive = root["keep_alive"] | FACTORY_MQTT_KEEP_ALIVE; newSettings.keepAlive = root["keep_alive"] | FACTORY_MQTT_KEEP_ALIVE;
newSettings.cleanSession = root["clean_session"] | FACTORY_MQTT_CLEAN_SESSION; newSettings.cleanSession = root["clean_session"] | FACTORY_MQTT_CLEAN_SESSION;
newSettings.mqtt_qos = root["mqtt_qos"] | EMSESP_DEFAULT_MQTT_QOS; newSettings.multiple_instances = root["multiple_instances"] | FACTORY_MQTT_MULTIPLE_INSTANCES;
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_boiler = root["publish_time_boiler"] | EMSESP_DEFAULT_PUBLISH_TIME;
newSettings.publish_time_thermostat = root["publish_time_thermostat"] | EMSESP_DEFAULT_PUBLISH_TIME; newSettings.publish_time_thermostat = root["publish_time_thermostat"] | EMSESP_DEFAULT_PUBLISH_TIME;

View File

@@ -57,6 +57,10 @@ static String generateClientId() {
#define FACTORY_MQTT_MAX_TOPIC_LENGTH 128 #define FACTORY_MQTT_MAX_TOPIC_LENGTH 128
#endif #endif
#ifndef FACTORY_MQTT_MULTIPLE_INSTANCES
#define FACTORY_MQTT_MULTIPLE_INSTANCES false
#endif
class MqttSettings { class MqttSettings {
public: public:
// host and port - if enabled // host and port - if enabled
@@ -75,6 +79,9 @@ class MqttSettings {
uint16_t keepAlive; uint16_t keepAlive;
bool cleanSession; bool cleanSession;
// multiple instances
bool multiple_instances;
// proddy EMS-ESP specific // proddy EMS-ESP specific
String base; String base;
uint16_t publish_time_boiler; uint16_t publish_time_boiler;

View File

@@ -81,6 +81,7 @@ class DummySettings {
String username = ""; String username = "";
uint16_t keepAlive = 60; uint16_t keepAlive = 60;
bool cleanSession = false; bool cleanSession = false;
bool multiple_instances = false;
uint16_t publish_time_boiler = 10; uint16_t publish_time_boiler = 10;
uint16_t publish_time_thermostat = 10; uint16_t publish_time_thermostat = 10;

View File

@@ -219,6 +219,7 @@ mqtt_settings = {
client_id: 'ems-esp', client_id: 'ems-esp',
keep_alive: 60, keep_alive: 60,
clean_session: true, clean_session: true,
multiple_instances: false,
publish_time_boiler: 10, publish_time_boiler: 10,
publish_time_thermostat: 10, publish_time_thermostat: 10,
publish_time_solar: 10, publish_time_solar: 10,

View File

@@ -1153,6 +1153,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
node["client id"] = settings.clientId; node["client id"] = settings.clientId;
node["keep alive"] = settings.keepAlive; node["keep alive"] = settings.keepAlive;
node["clean session"] = settings.cleanSession; node["clean session"] = settings.cleanSession;
node["multiple instances"] = settings.multiple_instances;
node["base"] = settings.base; node["base"] = settings.base;
node["discovery prefix"] = settings.discovery_prefix; node["discovery prefix"] = settings.discovery_prefix;
node["nested format"] = settings.nested_format; node["nested format"] = settings.nested_format;