From eae17e155714bef8ead3b5b30f22c742b66a5d0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Fri, 9 Mar 2018 19:22:15 +0100 Subject: [PATCH] Fix MQTT query request --- code/espurna/relay.ino | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index 406f7670..5cb7b0b9 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -660,13 +660,20 @@ void relayMQTT() { } void relayStatusWrap(unsigned char id, unsigned char value, bool is_group_topic) { - // Action to perform - if (value == 0) { - relayStatus(id, false, mqttForward(), !is_group_topic); - } else if (value == 1) { - relayStatus(id, true, mqttForward(), !is_group_topic); - } else if (value == 2) { - relayToggle(id, true, true); + switch (value) { + case 0: + relayStatus(id, false, mqttForward(), !is_group_topic); + break; + case 1: + relayStatus(id, true, mqttForward(), !is_group_topic); + break; + case 2: + relayToggle(id, true, true); + break; + default: + _relays[id].report = true; + relayMQTT(id); + break; } }