mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
removed publish_always, change how publish_time works
This commit is contained in:
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [1.9.4 beta]
|
## [1.9.4 beta]
|
||||||
|
|
||||||
|
There are breaking changes in this release. See `publish_time` below and make sure you set this value to 0.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Added `publish_always` forcing MQTT topics to be always sent regardless if the data hasn't changed
|
- Added `publish_always` forcing MQTT topics to be always sent regardless if the data hasn't changed
|
||||||
@@ -28,6 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- fixed version numbers of libraries in `platformio.ini`
|
- fixed version numbers of libraries in `platformio.ini`
|
||||||
- Normalized Heating modes to `off`, `manual`, `auto`, `night` and `day` to keep generic and not Home Assistant specific (like `heat`)
|
- Normalized Heating modes to `off`, `manual`, `auto`, `night` and `day` to keep generic and not Home Assistant specific (like `heat`)
|
||||||
- Keeping Thermostat day/night modes separate from off/auto/manual, and setting this for the Junkers FR50
|
- Keeping Thermostat day/night modes separate from off/auto/manual, and setting this for the Junkers FR50
|
||||||
|
- Removed `publish_always` and use `publish_time`. For automatic mode you will need to change `publish_time` to 0 which will send MQTT every time data has changed (every 10 seconds).
|
||||||
|
- Changed NTP interval from 1 hour to 12 hours
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
@@ -201,7 +205,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- publish dallas external temp sensors to MQTT (thanks @JewelZB)
|
- publish dallas external temp sensors to MQTT (thanks @JewelZB)
|
||||||
- shower timer and shower alert options available via set commands
|
- shower timer and shower alert options available via set commands
|
||||||
- added support for warm water modes Hot, Comfort and Intelligent [(issue 67)](https://github.com/proddy/EMS-ESP/issues/67)
|
- added support for warm water modes Hot, Comfort and Intelligent [(issue 67)](https://github.com/proddy/EMS-ESP/issues/67)
|
||||||
- added `set publish_time` to set how often to publish MQTT
|
- added `set publish_time` to set how often to force a publish of MQTT
|
||||||
- support for SM10 Solar Module including MQTT [(issue 77)](https://github.com/proddy/EMS-ESP/issues/77)
|
- support for SM10 Solar Module including MQTT [(issue 77)](https://github.com/proddy/EMS-ESP/issues/77)
|
||||||
- `refresh` command to force a fetch of all known data from the connected EMS devices
|
- `refresh` command to force a fetch of all known data from the connected EMS devices
|
||||||
|
|
||||||
|
|||||||
@@ -114,29 +114,14 @@
|
|||||||
<div class="row form-group">
|
<div class="row form-group">
|
||||||
<label class="col-xs-3">Publish Time<i style="margin-left: 10px;" class="glyphicon glyphicon-info-sign"
|
<label class="col-xs-3">Publish Time<i style="margin-left: 10px;" class="glyphicon glyphicon-info-sign"
|
||||||
aria-hidden="true" data-toggle="popover" data-trigger="hover" data-placement="right"
|
aria-hidden="true" data-toggle="popover" data-trigger="hover" data-placement="right"
|
||||||
data-content="How often to send MQTT topics with stats (in seconds)"></i></label>
|
data-content="How often to send MQTT topics with stats. 0 is automatic. (in seconds)"></i></label>
|
||||||
<span class="col-xs-9">
|
<span class="col-xs-9">
|
||||||
<input class="form-control input-sm" placeholder="120" value="" style="display:inline;max-width:185px"
|
<input class="form-control input-sm" placeholder="0" value="" style="display:inline;max-width:185px"
|
||||||
id="publish_time" type="text">
|
id="publish_time" type="text">
|
||||||
</span>
|
</span>
|
||||||
<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"
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ var custom_config = {
|
|||||||
"listen_mode": false,
|
"listen_mode": false,
|
||||||
"shower_timer": false,
|
"shower_timer": false,
|
||||||
"shower_alert": false,
|
"shower_alert": false,
|
||||||
"publish_time": 120,
|
"publish_time": 0,
|
||||||
"publish_always": false,
|
|
||||||
"tx_mode": 1
|
"tx_mode": 1
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -40,10 +39,6 @@ function listcustom() {
|
|||||||
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() {
|
||||||
@@ -75,11 +70,6 @@ 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);
|
||||||
|
|
||||||
|
|||||||
113
src/ems-esp.cpp
113
src/ems-esp.cpp
@@ -34,10 +34,12 @@ DS18 ds18;
|
|||||||
#define APP_URL_API "https://api.github.com/repos/proddy/EMS-ESP"
|
#define APP_URL_API "https://api.github.com/repos/proddy/EMS-ESP"
|
||||||
|
|
||||||
// timers, all values are in seconds
|
// timers, all values are in seconds
|
||||||
#define DEFAULT_PUBLISHTIME 120 // every 2 minutes publish MQTT values, including Dallas sensors
|
#define DEFAULT_PUBLISHTIME 0
|
||||||
Ticker publishValuesTimer;
|
Ticker publishValuesTimer;
|
||||||
Ticker publishSensorValuesTimer;
|
Ticker publishSensorValuesTimer;
|
||||||
|
|
||||||
|
bool _need_first_publish = true; // this ensures on boot we always send out MQTT messages
|
||||||
|
|
||||||
#define SYSTEMCHECK_TIME 30 // every 30 seconds check if EMS can be reached
|
#define SYSTEMCHECK_TIME 30 // every 30 seconds check if EMS can be reached
|
||||||
Ticker systemCheckTimer;
|
Ticker systemCheckTimer;
|
||||||
|
|
||||||
@@ -74,7 +76,6 @@ 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
|
||||||
@@ -98,9 +99,7 @@ static const command_t project_cmds[] PROGMEM = {
|
|||||||
{true, "listen_mode <on | off>", "when set to on all automatic Tx are disabled"},
|
{true, "listen_mode <on | off>", "when set to on all automatic Tx are disabled"},
|
||||||
{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=automatic)"},
|
||||||
{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=HT3"},
|
{true, "tx_mode <n>", "changes Tx logic. 1=EMS generic, 2=EMS+, 3=HT3"},
|
||||||
|
|
||||||
{false, "info", "show current captured on the devices"},
|
{false, "info", "show current captured on the devices"},
|
||||||
@@ -507,12 +506,16 @@ void showInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// send all dallas sensor values as a JSON package to MQTT
|
// send all dallas sensor values as a JSON package to MQTT
|
||||||
void publishSensorValues() {
|
void publishSensorValues(bool force) {
|
||||||
// don't send if MQTT is connected
|
// don't send if MQTT is connected
|
||||||
if (!myESP.isMQTTConnected()) {
|
if (!myESP.isMQTTConnected()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!EMSESP_Settings.dallas_sensors) {
|
||||||
|
return; // no sensors attached
|
||||||
|
}
|
||||||
|
|
||||||
StaticJsonDocument<200> doc;
|
StaticJsonDocument<200> doc;
|
||||||
JsonObject sensors = doc.to<JsonObject>();
|
JsonObject sensors = doc.to<JsonObject>();
|
||||||
|
|
||||||
@@ -530,11 +533,29 @@ void publishSensorValues() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasdata) {
|
if (!hasdata) {
|
||||||
char data[200] = {0};
|
return; // nothing to send
|
||||||
serializeJson(doc, data, sizeof(data));
|
}
|
||||||
myDebugLog("Publishing external sensor data via MQTT");
|
|
||||||
myESP.mqttPublish(TOPIC_EXTERNAL_SENSORS, data);
|
CRC32 crc;
|
||||||
|
uint32_t fchecksum;
|
||||||
|
|
||||||
|
char data[200] = {0};
|
||||||
|
serializeJson(doc, data, sizeof(data));
|
||||||
|
|
||||||
|
size_t jsonSize = measureJson(doc);
|
||||||
|
if (hasdata && (jsonSize > 2)) {
|
||||||
|
// calculate hash and send values if something has changed, to save unnecessary wifi traffic
|
||||||
|
for (uint8_t i = 0; i < (jsonSize - 1); i++) {
|
||||||
|
crc.update(data[i]);
|
||||||
|
}
|
||||||
|
fchecksum = crc.finalize();
|
||||||
|
static uint32_t previousSensorPublishCRC; // CRC check for new values
|
||||||
|
if ((previousSensorPublishCRC != fchecksum) || force) {
|
||||||
|
previousSensorPublishCRC = fchecksum;
|
||||||
|
myDebugLog("Publishing external sensor data via MQTT");
|
||||||
|
myESP.mqttPublish(TOPIC_EXTERNAL_SENSORS, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,19 +563,18 @@ void publishSensorValues() {
|
|||||||
// a json object is created for the boiler and one for the thermostat
|
// a json object is created for the boiler and one for the thermostat
|
||||||
// CRC check is done to see if there are changes in the values since the last send to avoid too much wifi traffic
|
// CRC check is done to see if there are changes in the values since the last send to avoid too much wifi traffic
|
||||||
// a check is done against the previous values and if there are changes only then they are published. Unless force=true
|
// a check is done against the previous values and if there are changes only then they are published. Unless force=true
|
||||||
void publishValues(bool force) {
|
void publishEMSValues(bool force) {
|
||||||
// don't send if MQTT is not connected
|
// don't send if MQTT is not connected
|
||||||
if (!myESP.isMQTTConnected()) {
|
if (!myESP.isMQTTConnected()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't publish is publish time is set to 0
|
if (!ems_getBusConnected()) {
|
||||||
if (EMSESP_Settings.publish_time == 0) {
|
return; // EMS bus is not connected
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// override force
|
// override force id not on automatic mode. Always send values is there is a publish_time set
|
||||||
if (EMSESP_Settings.publish_always) {
|
if (EMSESP_Settings.publish_time != 0) {
|
||||||
force = true;
|
force = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -900,17 +920,12 @@ void publishValues(bool force) {
|
|||||||
|
|
||||||
// publish external dallas sensor temperature values to MQTT
|
// publish external dallas sensor temperature values to MQTT
|
||||||
void do_publishSensorValues() {
|
void do_publishSensorValues() {
|
||||||
if ((EMSESP_Settings.dallas_sensors) && (EMSESP_Settings.publish_time)) {
|
publishSensorValues(true); // force publish
|
||||||
publishSensorValues();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// call PublishValues without forcing, so using CRC to see if we really need to publish
|
// call PublishValues without forcing, so using CRC to see if we really need to publish
|
||||||
void do_publishValues() {
|
void do_publishValues() {
|
||||||
// don't publish if we're not connected to the EMS bus
|
publishEMSValues(true); // force publish
|
||||||
if ((ems_getBusConnected()) && myESP.isMQTTConnected() && EMSESP_Settings.publish_time) {
|
|
||||||
publishValues(true); // force publish
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// callback to light up the LED, called via Ticker every second
|
// callback to light up the LED, called via Ticker every second
|
||||||
@@ -993,7 +1008,6 @@ bool LoadSaveCallback(MYESP_FSACTION_t 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);
|
||||||
@@ -1013,7 +1027,6 @@ bool LoadSaveCallback(MYESP_FSACTION_t 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;
|
||||||
@@ -1148,19 +1161,6 @@ bool SetListCallback(MYESP_FSACTION_t action, uint8_t wc, const char * setting,
|
|||||||
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);
|
||||||
@@ -1184,7 +1184,6 @@ bool SetListCallback(MYESP_FSACTION_t action, uint8_t wc, const char * setting,
|
|||||||
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;
|
||||||
@@ -1589,7 +1588,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
|||||||
if (strcmp(topic, TOPIC_BOILER_CMD_WWTEMP) == 0) {
|
if (strcmp(topic, TOPIC_BOILER_CMD_WWTEMP) == 0) {
|
||||||
uint8_t t = atoi((char *)message);
|
uint8_t t = atoi((char *)message);
|
||||||
ems_setWarmWaterTemp(t);
|
ems_setWarmWaterTemp(t);
|
||||||
publishValues(true);
|
publishEMSValues(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1599,7 +1598,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
|||||||
if (hc) {
|
if (hc) {
|
||||||
float f = strtof((char *)message, 0);
|
float f = strtof((char *)message, 0);
|
||||||
ems_setThermostatTemp(f, hc);
|
ems_setThermostatTemp(f, hc);
|
||||||
publishValues(true); // publish back immediately
|
publishEMSValues(true); // publish back immediately
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1632,7 +1631,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
|||||||
if (hc) {
|
if (hc) {
|
||||||
float f = doc["data"];
|
float f = doc["data"];
|
||||||
ems_setThermostatTemp(f, hc);
|
ems_setThermostatTemp(f, hc);
|
||||||
publishValues(true); // publish back immediately
|
publishEMSValues(true); // publish back immediately
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1862,7 +1861,6 @@ 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.dallas_sensors = 0;
|
EMSESP_Settings.dallas_sensors = 0;
|
||||||
EMSESP_Settings.led_gpio = EMSESP_LED_GPIO;
|
EMSESP_Settings.led_gpio = EMSESP_LED_GPIO;
|
||||||
EMSESP_Settings.dallas_gpio = EMSESP_DALLAS_GPIO;
|
EMSESP_Settings.dallas_gpio = EMSESP_DALLAS_GPIO;
|
||||||
@@ -1985,6 +1983,7 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set timers for MQTT publish
|
// set timers for MQTT publish
|
||||||
|
// only if publish_time is not 0 (automatic mode)
|
||||||
if (EMSESP_Settings.publish_time) {
|
if (EMSESP_Settings.publish_time) {
|
||||||
publishValuesTimer.attach(EMSESP_Settings.publish_time, do_publishValues); // post MQTT EMS values
|
publishValuesTimer.attach(EMSESP_Settings.publish_time, do_publishValues); // post MQTT EMS values
|
||||||
publishSensorValuesTimer.attach(EMSESP_Settings.publish_time, do_publishSensorValues); // post MQTT dallas sensor values
|
publishSensorValuesTimer.attach(EMSESP_Settings.publish_time, do_publishSensorValues); // post MQTT dallas sensor values
|
||||||
@@ -2007,8 +2006,7 @@ void setup() {
|
|||||||
// Main loop
|
// Main loop
|
||||||
//
|
//
|
||||||
void loop() {
|
void loop() {
|
||||||
// the main loop
|
myESP.loop(); // handle telnet, mqtt, wifi etc
|
||||||
myESP.loop();
|
|
||||||
|
|
||||||
// check Dallas sensors, using same schedule as publish_time (default 2 mins)
|
// check Dallas sensors, using same schedule as publish_time (default 2 mins)
|
||||||
// these values are published to MQTT separately via the timer publishSensorValuesTimer
|
// these values are published to MQTT separately via the timer publishSensorValuesTimer
|
||||||
@@ -2016,12 +2014,25 @@ void loop() {
|
|||||||
ds18.loop();
|
ds18.loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// publish all the values to MQTT, only if the values have changed
|
// check if we have data from the EMS bus
|
||||||
// although we don't want to publish when doing a deep scan of the thermostat
|
|
||||||
if (ems_getEmsRefreshed()) {
|
if (ems_getEmsRefreshed()) {
|
||||||
publishValues(false);
|
// if we have an EMS connect go and fetch some data and publish it (by force)
|
||||||
do_publishSensorValues();
|
if (_need_first_publish) {
|
||||||
ems_setEmsRefreshed(false); // reset
|
do_regularUpdates();
|
||||||
|
publishEMSValues(true);
|
||||||
|
publishSensorValues(true);
|
||||||
|
_need_first_publish = false; // reset flag
|
||||||
|
}
|
||||||
|
|
||||||
|
// publish all the values to MQTT
|
||||||
|
// but only if the values have changed and publish_time is on automatic mode
|
||||||
|
// always publish when we get the first results, regardless of any publish_time setting
|
||||||
|
if (EMSESP_Settings.publish_time == 0) {
|
||||||
|
publishEMSValues(false);
|
||||||
|
publishSensorValues(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ems_setEmsRefreshed(false); // reset flag
|
||||||
}
|
}
|
||||||
|
|
||||||
// do shower logic, if enabled
|
// do shower logic, if enabled
|
||||||
|
|||||||
@@ -2287,6 +2287,7 @@ void ems_printTxQueue() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic function to return various settings from the thermostat
|
* Generic function to return various settings from the thermostat
|
||||||
|
* This is called manually to fetch values which don't come from broadcast messages
|
||||||
*/
|
*/
|
||||||
void ems_getThermostatValues() {
|
void ems_getThermostatValues() {
|
||||||
if (!ems_getThermostatEnabled()) {
|
if (!ems_getThermostatEnabled()) {
|
||||||
@@ -2994,13 +2995,13 @@ void ems_setThermostatMode(uint8_t mode, uint8_t hc_num) {
|
|||||||
if (model_id == EMS_MODEL_RC20) {
|
if (model_id == EMS_MODEL_RC20) {
|
||||||
EMS_TxTelegram.type = EMS_TYPE_RC20Set;
|
EMS_TxTelegram.type = EMS_TYPE_RC20Set;
|
||||||
EMS_TxTelegram.offset = EMS_OFFSET_RC20Set_mode;
|
EMS_TxTelegram.offset = EMS_OFFSET_RC20Set_mode;
|
||||||
EMS_TxTelegram.type_validate = EMS_TxTelegram.type;
|
EMS_TxTelegram.type_validate = EMS_TYPE_RC20Set;
|
||||||
EMS_TxTelegram.comparisonPostRead = EMS_TYPE_RC20StatusMessage;
|
EMS_TxTelegram.comparisonPostRead = EMS_TYPE_RC20StatusMessage;
|
||||||
|
|
||||||
} else if (model_id == EMS_MODEL_RC30) {
|
} else if (model_id == EMS_MODEL_RC30) {
|
||||||
EMS_TxTelegram.type = EMS_TYPE_RC30Set;
|
EMS_TxTelegram.type = EMS_TYPE_RC30Set;
|
||||||
EMS_TxTelegram.offset = EMS_OFFSET_RC30Set_mode;
|
EMS_TxTelegram.offset = EMS_OFFSET_RC30Set_mode;
|
||||||
EMS_TxTelegram.type_validate = EMS_TxTelegram.type;
|
EMS_TxTelegram.type_validate = EMS_TYPE_RC30Set;
|
||||||
EMS_TxTelegram.comparisonPostRead = EMS_TYPE_RC30StatusMessage;
|
EMS_TxTelegram.comparisonPostRead = EMS_TYPE_RC30StatusMessage;
|
||||||
|
|
||||||
} else if ((model_id == EMS_MODEL_RC35) || (model_id == EMS_MODEL_ES73)) {
|
} else if ((model_id == EMS_MODEL_RC35) || (model_id == EMS_MODEL_ES73)) {
|
||||||
|
|||||||
@@ -103,8 +103,7 @@ var custom_configfile = {
|
|||||||
"listen_mode": false,
|
"listen_mode": false,
|
||||||
"shower_timer": true,
|
"shower_timer": true,
|
||||||
"shower_alert": false,
|
"shower_alert": false,
|
||||||
"publish_time": 120,
|
"publish_time": 0,
|
||||||
"publish_always": false,
|
|
||||||
"tx_mode": 1
|
"tx_mode": 1
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user