mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
publish_always option. https://github.com/proddy/EMS-ESP/issues/224
This commit is contained in:
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- Added `publish_always` forcing MQTT topics to be always sent regardless if the data hasn't changed
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -122,6 +122,21 @@
|
|||||||
<br>
|
<br>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row form-group">
|
||||||
|
<label class="col-xs-3">Publish Always<i style="margin-left: 10px;" class="glyphicon glyphicon-info-sign"
|
||||||
|
aria-hidden="true" data-toggle="popover" data-trigger="hover" data-placement="right"
|
||||||
|
data-content="Always send MQTT topics, regardless if the payload hasn't changed"></i></label>
|
||||||
|
<span class="col-xs-9">
|
||||||
|
<form>
|
||||||
|
<label class="radio-inline">
|
||||||
|
<input type="radio" value="1" name="publish_always">Enabled</label>
|
||||||
|
<label class="radio-inline">
|
||||||
|
<input type="radio" value="0" name="publish_always" checked>Disabled</label>
|
||||||
|
</form>
|
||||||
|
</span>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row form-group">
|
<div class="row form-group">
|
||||||
<label class="col-xs-3">Tx mode<i style="margin-left: 10px;"
|
<label class="col-xs-3">Tx mode<i style="margin-left: 10px;"
|
||||||
class="glyphicon glyphicon-exclamation-sign text-danger" aria-hidden="true" data-toggle="popover"
|
class="glyphicon glyphicon-exclamation-sign text-danger" aria-hidden="true" data-toggle="popover"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ var custom_config = {
|
|||||||
"shower_timer": false,
|
"shower_timer": false,
|
||||||
"shower_alert": false,
|
"shower_alert": false,
|
||||||
"publish_time": 120,
|
"publish_time": 120,
|
||||||
|
"publish_always": false,
|
||||||
"tx_mode": 1
|
"tx_mode": 1
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -23,18 +24,26 @@ function listcustom() {
|
|||||||
if (custom_config.settings.led) {
|
if (custom_config.settings.led) {
|
||||||
$("input[name=\"led\"][value=\"1\"]").prop("checked", true);
|
$("input[name=\"led\"][value=\"1\"]").prop("checked", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (custom_config.settings.dallas_parasite) {
|
if (custom_config.settings.dallas_parasite) {
|
||||||
$("input[name=\"dallas_parasite\"][value=\"1\"]").prop("checked", true);
|
$("input[name=\"dallas_parasite\"][value=\"1\"]").prop("checked", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (custom_config.settings.listen_mode) {
|
if (custom_config.settings.listen_mode) {
|
||||||
$("input[name=\"listen_mode\"][value=\"1\"]").prop("checked", true);
|
$("input[name=\"listen_mode\"][value=\"1\"]").prop("checked", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (custom_config.settings.shower_timer) {
|
if (custom_config.settings.shower_timer) {
|
||||||
$("input[name=\"shower_timer\"][value=\"1\"]").prop("checked", true);
|
$("input[name=\"shower_timer\"][value=\"1\"]").prop("checked", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (custom_config.settings.shower_alert) {
|
if (custom_config.settings.shower_alert) {
|
||||||
$("input[name=\"shower_alert\"][value=\"1\"]").prop("checked", true);
|
$("input[name=\"shower_alert\"][value=\"1\"]").prop("checked", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (custom_config.settings.publish_always) {
|
||||||
|
$("input[name=\"publish_always\"][value=\"1\"]").prop("checked", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function savecustom() {
|
function savecustom() {
|
||||||
@@ -66,6 +75,11 @@ function savecustom() {
|
|||||||
custom_config.settings.led = true;
|
custom_config.settings.led = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
custom_config.settings.publish_always = false;
|
||||||
|
if (parseInt($("input[name=\"publish_always\"]:checked").val()) === 1) {
|
||||||
|
custom_config.settings.publish_always = true;
|
||||||
|
}
|
||||||
|
|
||||||
custom_config.settings.publish_time = parseInt(document.getElementById("publish_time").value);
|
custom_config.settings.publish_time = parseInt(document.getElementById("publish_time").value);
|
||||||
custom_config.settings.tx_mode = parseInt(document.getElementById("tx_mode").value);
|
custom_config.settings.tx_mode = parseInt(document.getElementById("tx_mode").value);
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ typedef struct {
|
|||||||
bool led; // LED on/off
|
bool led; // LED on/off
|
||||||
bool listen_mode; // stop automatic Tx on/off
|
bool listen_mode; // stop automatic Tx on/off
|
||||||
uint16_t publish_time; // frequency of MQTT publish in seconds
|
uint16_t publish_time; // frequency of MQTT publish in seconds
|
||||||
|
bool publish_always; // true if publish MQTT regardless if data has changed
|
||||||
uint8_t led_gpio; // pin for LED
|
uint8_t led_gpio; // pin for LED
|
||||||
uint8_t dallas_gpio; // pin for attaching external dallas temperature sensors
|
uint8_t dallas_gpio; // pin for attaching external dallas temperature sensors
|
||||||
bool dallas_parasite; // on/off is using parasite
|
bool dallas_parasite; // on/off is using parasite
|
||||||
@@ -113,6 +114,8 @@ static const command_t project_cmds[] PROGMEM = {
|
|||||||
{true, "shower_timer <on | off>", "send MQTT notification on all shower durations"},
|
{true, "shower_timer <on | off>", "send MQTT notification on all shower durations"},
|
||||||
{true, "shower_alert <on | off>", "stop hot water to send 3 cold burst warnings after max shower time is exceeded"},
|
{true, "shower_alert <on | off>", "stop hot water to send 3 cold burst warnings after max shower time is exceeded"},
|
||||||
{true, "publish_time <seconds>", "set frequency for publishing data to MQTT (0=off)"},
|
{true, "publish_time <seconds>", "set frequency for publishing data to MQTT (0=off)"},
|
||||||
|
{true, "publish_always <on | off>", "set to on to skip payload comparison since last publish"},
|
||||||
|
|
||||||
{true, "tx_mode <n>", "changes Tx logic. 1=ems generic, 2=ems+, 3=Junkers HT3"},
|
{true, "tx_mode <n>", "changes Tx logic. 1=ems generic, 2=ems+, 3=Junkers HT3"},
|
||||||
|
|
||||||
{false, "info", "show current captured on the devices"},
|
{false, "info", "show current captured on the devices"},
|
||||||
@@ -527,6 +530,11 @@ void publishValues(bool force) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// override force
|
||||||
|
if (EMSESP_Settings.publish_always) {
|
||||||
|
force = true;
|
||||||
|
}
|
||||||
|
|
||||||
char s[20] = {0}; // for formatting strings
|
char s[20] = {0}; // for formatting strings
|
||||||
StaticJsonDocument<MQTT_MAX_PAYLOAD_SIZE> doc;
|
StaticJsonDocument<MQTT_MAX_PAYLOAD_SIZE> doc;
|
||||||
char data[MQTT_MAX_PAYLOAD_SIZE] = {0};
|
char data[MQTT_MAX_PAYLOAD_SIZE] = {0};
|
||||||
@@ -1026,6 +1034,7 @@ bool LoadSaveCallback(MYESP_FSACTION action, JsonObject settings) {
|
|||||||
EMSESP_Settings.shower_timer = settings["shower_timer"];
|
EMSESP_Settings.shower_timer = settings["shower_timer"];
|
||||||
EMSESP_Settings.shower_alert = settings["shower_alert"];
|
EMSESP_Settings.shower_alert = settings["shower_alert"];
|
||||||
EMSESP_Settings.publish_time = settings["publish_time"] | DEFAULT_PUBLISHTIME;
|
EMSESP_Settings.publish_time = settings["publish_time"] | DEFAULT_PUBLISHTIME;
|
||||||
|
EMSESP_Settings.publish_always = settings["publish_always"];
|
||||||
|
|
||||||
EMSESP_Settings.listen_mode = settings["listen_mode"];
|
EMSESP_Settings.listen_mode = settings["listen_mode"];
|
||||||
ems_setTxDisabled(EMSESP_Settings.listen_mode);
|
ems_setTxDisabled(EMSESP_Settings.listen_mode);
|
||||||
@@ -1045,6 +1054,7 @@ bool LoadSaveCallback(MYESP_FSACTION action, JsonObject settings) {
|
|||||||
settings["shower_timer"] = EMSESP_Settings.shower_timer;
|
settings["shower_timer"] = EMSESP_Settings.shower_timer;
|
||||||
settings["shower_alert"] = EMSESP_Settings.shower_alert;
|
settings["shower_alert"] = EMSESP_Settings.shower_alert;
|
||||||
settings["publish_time"] = EMSESP_Settings.publish_time;
|
settings["publish_time"] = EMSESP_Settings.publish_time;
|
||||||
|
settings["publish_always"] = EMSESP_Settings.publish_always;
|
||||||
settings["tx_mode"] = EMSESP_Settings.tx_mode;
|
settings["tx_mode"] = EMSESP_Settings.tx_mode;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1179,6 +1189,19 @@ bool SetListCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, co
|
|||||||
ok = true;
|
ok = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// publish_always
|
||||||
|
if ((strcmp(setting, "publish_always") == 0) && (wc == 2)) {
|
||||||
|
if (strcmp(value, "on") == 0) {
|
||||||
|
EMSESP_Settings.publish_always = true;
|
||||||
|
ok = true;
|
||||||
|
} else if (strcmp(value, "off") == 0) {
|
||||||
|
EMSESP_Settings.publish_always = false;
|
||||||
|
ok = true;
|
||||||
|
} else {
|
||||||
|
myDebug_P(PSTR("Error. Usage: set publish_always <on | off>"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// tx_mode
|
// tx_mode
|
||||||
if ((strcmp(setting, "tx_mode") == 0) && (wc == 2)) {
|
if ((strcmp(setting, "tx_mode") == 0) && (wc == 2)) {
|
||||||
uint8_t mode = atoi(value);
|
uint8_t mode = atoi(value);
|
||||||
@@ -1202,6 +1225,7 @@ bool SetListCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, co
|
|||||||
myDebug_P(PSTR(" shower_timer=%s"), EMSESP_Settings.shower_timer ? "on" : "off");
|
myDebug_P(PSTR(" shower_timer=%s"), EMSESP_Settings.shower_timer ? "on" : "off");
|
||||||
myDebug_P(PSTR(" shower_alert=%s"), EMSESP_Settings.shower_alert ? "on" : "off");
|
myDebug_P(PSTR(" shower_alert=%s"), EMSESP_Settings.shower_alert ? "on" : "off");
|
||||||
myDebug_P(PSTR(" publish_time=%d"), EMSESP_Settings.publish_time);
|
myDebug_P(PSTR(" publish_time=%d"), EMSESP_Settings.publish_time);
|
||||||
|
myDebug_P(PSTR(" publish_always=%s"), EMSESP_Settings.publish_always ? "on" : "off");
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
@@ -1878,6 +1902,7 @@ void initEMSESP() {
|
|||||||
EMSESP_Settings.led = true; // LED is on by default
|
EMSESP_Settings.led = true; // LED is on by default
|
||||||
EMSESP_Settings.listen_mode = false;
|
EMSESP_Settings.listen_mode = false;
|
||||||
EMSESP_Settings.publish_time = DEFAULT_PUBLISHTIME;
|
EMSESP_Settings.publish_time = DEFAULT_PUBLISHTIME;
|
||||||
|
EMSESP_Settings.publish_always = false;
|
||||||
EMSESP_Settings.timestamp = millis();
|
EMSESP_Settings.timestamp = millis();
|
||||||
EMSESP_Settings.dallas_sensors = 0;
|
EMSESP_Settings.dallas_sensors = 0;
|
||||||
EMSESP_Settings.led_gpio = EMSESP_LED_GPIO;
|
EMSESP_Settings.led_gpio = EMSESP_LED_GPIO;
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define APP_VERSION "1.9.4b0"
|
#define APP_VERSION "1.9.4b1"
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ var custom_configfile = {
|
|||||||
"shower_timer": true,
|
"shower_timer": true,
|
||||||
"shower_alert": false,
|
"shower_alert": false,
|
||||||
"publish_time": 120,
|
"publish_time": 120,
|
||||||
|
"publish_always": false,
|
||||||
"tx_mode": 1
|
"tx_mode": 1
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user