mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
mqtt HA uses only json, disable single
This commit is contained in:
@@ -183,6 +183,7 @@ const MqttSettingsForm: FC = () => {
|
|||||||
control={<Checkbox name="send_response" checked={data.send_response} onChange={updateFormValue} />}
|
control={<Checkbox name="send_response" checked={data.send_response} onChange={updateFormValue} />}
|
||||||
label="Publish command output to a 'response' topic"
|
label="Publish command output to a 'response' topic"
|
||||||
/>
|
/>
|
||||||
|
{!data.ha_enabled && (
|
||||||
<Grid container spacing={1} direction="row" justifyContent="flex-start" alignItems="flex-start">
|
<Grid container spacing={1} direction="row" justifyContent="flex-start" alignItems="flex-start">
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<BlockFormControlLabel
|
<BlockFormControlLabel
|
||||||
@@ -201,6 +202,8 @@ const MqttSettingsForm: FC = () => {
|
|||||||
</Grid>
|
</Grid>
|
||||||
)}
|
)}
|
||||||
</Grid>
|
</Grid>
|
||||||
|
)}
|
||||||
|
{!data.publish_single && (
|
||||||
<Grid container spacing={1} direction="row" justifyContent="flex-start" alignItems="flex-start">
|
<Grid container spacing={1} direction="row" justifyContent="flex-start" alignItems="flex-start">
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<BlockFormControlLabel
|
<BlockFormControlLabel
|
||||||
@@ -222,6 +225,7 @@ const MqttSettingsForm: FC = () => {
|
|||||||
</Grid>
|
</Grid>
|
||||||
)}
|
)}
|
||||||
</Grid>
|
</Grid>
|
||||||
|
)}
|
||||||
<Typography sx={{ pt: 2 }} variant="h6" color="primary">
|
<Typography sx={{ pt: 2 }} variant="h6" color="primary">
|
||||||
Publish Intervals (in seconds, 0=automatic)
|
Publish Intervals (in seconds, 0=automatic)
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|||||||
@@ -228,7 +228,15 @@ StateUpdateResult MqttSettings::update(JsonObject & root, MqttSettings & setting
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if both settings are stored from older version, HA has priority
|
||||||
|
if (newSettings.ha_enabled && newSettings.publish_single) {
|
||||||
|
newSettings.publish_single = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (newSettings.publish_single != settings.publish_single) {
|
if (newSettings.publish_single != settings.publish_single) {
|
||||||
|
if (newSettings.publish_single) {
|
||||||
|
newSettings.ha_enabled = false;
|
||||||
|
}
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,6 +250,9 @@ StateUpdateResult MqttSettings::update(JsonObject & root, MqttSettings & setting
|
|||||||
|
|
||||||
if (newSettings.ha_enabled != settings.ha_enabled) {
|
if (newSettings.ha_enabled != settings.ha_enabled) {
|
||||||
emsesp::EMSESP::mqtt_.ha_enabled(newSettings.ha_enabled);
|
emsesp::EMSESP::mqtt_.ha_enabled(newSettings.ha_enabled);
|
||||||
|
if (newSettings.ha_enabled) {
|
||||||
|
newSettings.publish_single = false;
|
||||||
|
}
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -961,6 +961,7 @@ bool System::command_settings(const char * value, const int8_t id, JsonObject &
|
|||||||
node["publish_time_other"] = settings.publish_time_other;
|
node["publish_time_other"] = settings.publish_time_other;
|
||||||
node["publish_time_sensor"] = settings.publish_time_sensor;
|
node["publish_time_sensor"] = settings.publish_time_sensor;
|
||||||
node["publish_single"] = settings.publish_single;
|
node["publish_single"] = settings.publish_single;
|
||||||
|
node["publish_2_command"] = settings.publish_single2cmd;
|
||||||
node["send_response"] = settings.send_response;
|
node["send_response"] = settings.send_response;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user