mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
add multiple_sessions
This commit is contained in:
@@ -162,6 +162,10 @@ const MqttSettingsForm: FC = () => {
|
||||
</ValidatedTextField>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<BlockFormControlLabel
|
||||
control={<Checkbox name="multiple_instances" checked={data.multiple_instances} onChange={updateFormValue} />}
|
||||
label={LL.MQTT_MULTIPLE_INSTANCES()}
|
||||
/>
|
||||
<BlockFormControlLabel
|
||||
control={<Checkbox name="clean_session" checked={data.clean_session} onChange={updateFormValue} />}
|
||||
label={LL.MQTT_CLEAN_SESSION()}
|
||||
|
||||
@@ -247,6 +247,7 @@ const de: Translation = {
|
||||
MQTT_INT_MIXER: 'Mischermodule',
|
||||
MQTT_QUEUE: 'MQTT Queue',
|
||||
DEFAULT: 'Standard',
|
||||
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
|
||||
MQTT_CLEAN_SESSION: 'Setze `Clean Session`',
|
||||
MQTT_RETAIN_FLAG: 'Setze `Retain flag` immer',
|
||||
INACTIVE: 'Inaktiv',
|
||||
|
||||
@@ -247,6 +247,7 @@ const en: Translation = {
|
||||
MQTT_INT_MIXER: 'Mixer Modules',
|
||||
MQTT_QUEUE: 'MQTT Queue',
|
||||
DEFAULT: 'Default',
|
||||
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
|
||||
MQTT_CLEAN_SESSION: 'Set Clean Session',
|
||||
MQTT_RETAIN_FLAG: 'Always set Retain flag',
|
||||
INACTIVE: 'Inactive',
|
||||
|
||||
@@ -247,6 +247,7 @@ const nl: Translation = {
|
||||
MQTT_INT_MIXER: 'Mixer Modules',
|
||||
MQTT_QUEUE: 'MQTT Queue',
|
||||
DEFAULT: 'Default',
|
||||
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
|
||||
MQTT_CLEAN_SESSION: 'Clean Session aan',
|
||||
MQTT_RETAIN_FLAG: 'Retain flag aan',
|
||||
INACTIVE: 'Inactief',
|
||||
|
||||
@@ -247,6 +247,7 @@ const no: Translation = {
|
||||
MQTT_INT_MIXER: 'Blandeventil',
|
||||
MQTT_QUEUE: 'MQTT Queue',
|
||||
DEFAULT: 'Standard',
|
||||
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
|
||||
MQTT_CLEAN_SESSION: 'Benytt Clean Session',
|
||||
MQTT_RETAIN_FLAG: 'Alltid sett Retain flag',
|
||||
INACTIVE: 'Innaktiv',
|
||||
|
||||
@@ -247,6 +247,7 @@ const pl: BaseTranslation = {
|
||||
MQTT_INT_MIXER: 'Mieszacze',
|
||||
MQTT_QUEUE: 'Kolejka MQTT',
|
||||
DEFAULT: '{{Pozostałe|Domyślna|}}',
|
||||
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
|
||||
MQTT_CLEAN_SESSION: 'Ustawiaj flagę "Clean session"',
|
||||
MQTT_RETAIN_FLAG: 'Ustawiaj flagę "Retain"',
|
||||
INACTIVE: 'nieaktywny',
|
||||
|
||||
@@ -247,6 +247,7 @@ const se: Translation = {
|
||||
MQTT_INT_MIXER: 'Blandarventiler',
|
||||
MQTT_QUEUE: 'MQTT Queue',
|
||||
DEFAULT: 'Standard',
|
||||
MQTT_MULTIPLE_INSTANCES: 'Enable Multiple Instances of EMS-ESP',
|
||||
MQTT_CLEAN_SESSION: 'Använd "Clean Session"-flaggan',
|
||||
MQTT_RETAIN_FLAG: 'Använd "Always Retain"-flaggan',
|
||||
INACTIVE: 'Inaktiv',
|
||||
|
||||
@@ -29,6 +29,7 @@ export interface MqttSettings {
|
||||
client_id: string;
|
||||
keep_alive: number;
|
||||
clean_session: boolean;
|
||||
multiple_instances: boolean;
|
||||
publish_time_boiler: number;
|
||||
publish_time_thermostat: number;
|
||||
publish_time_solar: number;
|
||||
|
||||
@@ -145,15 +145,16 @@ void MqttSettingsService::configureMqtt() {
|
||||
}
|
||||
|
||||
void MqttSettings::read(MqttSettings & settings, JsonObject & root) {
|
||||
root["enabled"] = settings.enabled;
|
||||
root["host"] = settings.host;
|
||||
root["port"] = settings.port;
|
||||
root["base"] = settings.base;
|
||||
root["username"] = settings.username;
|
||||
root["password"] = settings.password;
|
||||
root["client_id"] = settings.clientId;
|
||||
root["keep_alive"] = settings.keepAlive;
|
||||
root["clean_session"] = settings.cleanSession;
|
||||
root["enabled"] = settings.enabled;
|
||||
root["host"] = settings.host;
|
||||
root["port"] = settings.port;
|
||||
root["base"] = settings.base;
|
||||
root["username"] = settings.username;
|
||||
root["password"] = settings.password;
|
||||
root["client_id"] = settings.clientId;
|
||||
root["keep_alive"] = settings.keepAlive;
|
||||
root["clean_session"] = settings.cleanSession;
|
||||
root["multiple_instances"] = settings.multiple_instances;
|
||||
|
||||
// added by proddy for EMS-ESP
|
||||
root["publish_time_boiler"] = settings.publish_time_boiler;
|
||||
@@ -176,17 +177,19 @@ StateUpdateResult MqttSettings::update(JsonObject & root, MqttSettings & setting
|
||||
MqttSettings newSettings = {};
|
||||
bool changed = false;
|
||||
|
||||
newSettings.enabled = root["enabled"] | FACTORY_MQTT_ENABLED;
|
||||
newSettings.host = root["host"] | FACTORY_MQTT_HOST;
|
||||
newSettings.port = root["port"] | FACTORY_MQTT_PORT;
|
||||
newSettings.base = root["base"] | FACTORY_MQTT_BASE;
|
||||
newSettings.username = root["username"] | FACTORY_MQTT_USERNAME;
|
||||
newSettings.password = root["password"] | FACTORY_MQTT_PASSWORD;
|
||||
newSettings.clientId = root["client_id"] | FACTORY_MQTT_CLIENT_ID;
|
||||
newSettings.keepAlive = root["keep_alive"] | FACTORY_MQTT_KEEP_ALIVE;
|
||||
newSettings.cleanSession = root["clean_session"] | FACTORY_MQTT_CLEAN_SESSION;
|
||||
newSettings.mqtt_qos = root["mqtt_qos"] | EMSESP_DEFAULT_MQTT_QOS;
|
||||
newSettings.mqtt_retain = root["mqtt_retain"] | EMSESP_DEFAULT_MQTT_RETAIN;
|
||||
newSettings.enabled = root["enabled"] | FACTORY_MQTT_ENABLED;
|
||||
newSettings.host = root["host"] | FACTORY_MQTT_HOST;
|
||||
newSettings.port = root["port"] | FACTORY_MQTT_PORT;
|
||||
newSettings.base = root["base"] | FACTORY_MQTT_BASE;
|
||||
newSettings.username = root["username"] | FACTORY_MQTT_USERNAME;
|
||||
newSettings.password = root["password"] | FACTORY_MQTT_PASSWORD;
|
||||
newSettings.clientId = root["client_id"] | FACTORY_MQTT_CLIENT_ID;
|
||||
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.publish_time_boiler = root["publish_time_boiler"] | EMSESP_DEFAULT_PUBLISH_TIME;
|
||||
newSettings.publish_time_thermostat = root["publish_time_thermostat"] | EMSESP_DEFAULT_PUBLISH_TIME;
|
||||
|
||||
@@ -57,6 +57,10 @@ static String generateClientId() {
|
||||
#define FACTORY_MQTT_MAX_TOPIC_LENGTH 128
|
||||
#endif
|
||||
|
||||
#ifndef FACTORY_MQTT_MULTIPLE_INSTANCES
|
||||
#define FACTORY_MQTT_MULTIPLE_INSTANCES false
|
||||
#endif
|
||||
|
||||
class MqttSettings {
|
||||
public:
|
||||
// host and port - if enabled
|
||||
@@ -75,6 +79,9 @@ class MqttSettings {
|
||||
uint16_t keepAlive;
|
||||
bool cleanSession;
|
||||
|
||||
// multiple instances
|
||||
bool multiple_instances;
|
||||
|
||||
// proddy EMS-ESP specific
|
||||
String base;
|
||||
uint16_t publish_time_boiler;
|
||||
|
||||
@@ -81,6 +81,7 @@ class DummySettings {
|
||||
String username = "";
|
||||
uint16_t keepAlive = 60;
|
||||
bool cleanSession = false;
|
||||
bool multiple_instances = false;
|
||||
|
||||
uint16_t publish_time_boiler = 10;
|
||||
uint16_t publish_time_thermostat = 10;
|
||||
|
||||
@@ -219,6 +219,7 @@ mqtt_settings = {
|
||||
client_id: 'ems-esp',
|
||||
keep_alive: 60,
|
||||
clean_session: true,
|
||||
multiple_instances: false,
|
||||
publish_time_boiler: 10,
|
||||
publish_time_thermostat: 10,
|
||||
publish_time_solar: 10,
|
||||
|
||||
@@ -1153,6 +1153,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
||||
node["client id"] = settings.clientId;
|
||||
node["keep alive"] = settings.keepAlive;
|
||||
node["clean session"] = settings.cleanSession;
|
||||
node["multiple instances"] = settings.multiple_instances;
|
||||
node["base"] = settings.base;
|
||||
node["discovery prefix"] = settings.discovery_prefix;
|
||||
node["nested format"] = settings.nested_format;
|
||||
|
||||
Reference in New Issue
Block a user