reduce MQTT chatter

This commit is contained in:
proddy
2019-02-05 09:15:44 +01:00
parent 0cf9581932
commit 268e56fb48
2 changed files with 8 additions and 8 deletions

View File

@@ -895,7 +895,6 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
} else if (message[0] == '0') { } else if (message[0] == '0') {
ems_setWarmWaterActivated(false); ems_setWarmWaterActivated(false);
} }
publishValues(true); // publish back immediately
} }
// shower timer // shower timer
@@ -1149,11 +1148,11 @@ void loop() {
ds18.loop(); ds18.loop();
} }
// publish the values to MQTT, regardless if the values haven't changed // publish the values to MQTT, only if the values have changed
// we don't want to publish when doing a deep scan of the thermostat // although we don't want to publish when doing a deep scan of the thermostat
if (ems_getEmsRefreshed() && (scanThermostat_count == 0)) { if (ems_getEmsRefreshed() && (scanThermostat_count == 0)) {
publishValues(true); publishValues(false);
ems_setEmsRefreshed(false); ems_setEmsRefreshed(false); // reset
} }
// do shower logic, if enabled // do shower logic, if enabled

View File

@@ -524,6 +524,7 @@ void _createValidate() {
// safety check: only do a validate after a write and when we have a type to validate // safety check: only do a validate after a write and when we have a type to validate
if ((EMS_TxTelegram.action != EMS_TX_TELEGRAM_WRITE) || (EMS_TxTelegram.type_validate == EMS_ID_NONE)) { if ((EMS_TxTelegram.action != EMS_TX_TELEGRAM_WRITE) || (EMS_TxTelegram.type_validate == EMS_ID_NONE)) {
EMS_TxQueue.shift(); // remove from queue
return; return;
} }
@@ -582,7 +583,7 @@ void ems_parseTelegram(uint8_t * telegram, uint8_t length) {
EMS_Sys_Status.emsTxPkgs++; EMS_Sys_Status.emsTxPkgs++;
// got a success 01. Send a validate to check the value of the last write // got a success 01. Send a validate to check the value of the last write
emsaurt_tx_poll(); // send a poll to free the EMS bus emsaurt_tx_poll(); // send a poll to free the EMS bus
_createValidate(); // create a validate Tx request _createValidate(); // create a validate Tx request (if needed)
} else if (value == EMS_TX_ERROR) { } else if (value == EMS_TX_ERROR) {
// last write failed (04), delete it from queue and dont bother to retry // last write failed (04), delete it from queue and dont bother to retry
if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_VERBOSE) { if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_VERBOSE) {
@@ -767,9 +768,9 @@ void _processType(uint8_t * telegram, uint8_t length) {
// release the lock on the TxQueue // release the lock on the TxQueue
EMS_Sys_Status.emsTxStatus = EMS_TX_STATUS_IDLE; EMS_Sys_Status.emsTxStatus = EMS_TX_STATUS_IDLE;
// at this point we can assume Txstatus is EMS_TX_STATUS_WAIT // at this point we can assume Txstatus is EMS_TX_STATUS_WAIT so we just sent a read/write/validate
// for READ, WRITE or VALIDATE the dest (telegram[1]) is always us, so check for this // for READ, WRITE or VALIDATE the dest (telegram[1]) is always us, so check for this
// if not we probably didn't get any response so remove the last Tx from the queue and process the telegram // and if not we probably didn't get any response so remove the last Tx from the queue and process the telegram anyway
if ((telegram[1] & 0x7F) != EMS_ID_ME) { if ((telegram[1] & 0x7F) != EMS_ID_ME) {
_removeTxQueue(); _removeTxQueue();
_ems_processTelegram(telegram, length); _ems_processTelegram(telegram, length);