From e4e147a56970e7f984ad819a420f1599217c1efb Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Thu, 21 Feb 2019 07:25:10 +0300 Subject: [PATCH] Only check domoticz state in broker callback (#1562) --- code/espurna/domoticz.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/espurna/domoticz.ino b/code/espurna/domoticz.ino index 223b1ab6..b6e65c8a 100644 --- a/code/espurna/domoticz.ino +++ b/code/espurna/domoticz.ino @@ -166,8 +166,10 @@ void _domoticzBrokerCallback(const unsigned char type, const char * topic, unsig if (BROKER_MSG_TYPE_STATUS != type) return; if (strcmp(MQTT_TOPIC_RELAY, topic) == 0) { - unsigned char value = atoi(payload); - domoticzSendRelay(id, value == 1); + bool status = atoi(payload) == 1; + if (_domoticzStatus(id) == status) return; + _dcz_relay_state[id] = status; + domoticzSendRelay(id, status); } } @@ -238,8 +240,6 @@ template void domoticzSend(const char * key, T nvalue) { void domoticzSendRelay(unsigned char relayID, bool status) { if (!_dcz_enabled) return; - if (_domoticzStatus(relayID) == status) return; - _dcz_relay_state[relayID] = status; char buffer[15]; snprintf_P(buffer, sizeof(buffer), PSTR("dczRelayIdx%u"), relayID); domoticzSend(buffer, status ? "1" : "0");