diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index 481b0a7da..9c872e25e 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -1,4 +1,5 @@ /* 6.1.0a + * Fix invalid response using more than 4 switches and domoticz * Update sensor drivers to provide instant results * Add read sensor retry to DS18B20, DS18x20, DHT, SHT1X and HTU21 * Change SHT1x driver to provide better instant results diff --git a/sonoff/xdrv_07_domoticz.ino b/sonoff/xdrv_07_domoticz.ino index f2b972326..f29def2ce 100644 --- a/sonoff/xdrv_07_domoticz.ino +++ b/sonoff/xdrv_07_domoticz.ino @@ -271,14 +271,17 @@ boolean DomoticzCommand() boolean DomoticzSendKey(byte key, byte device, byte state, byte svalflg) { - if ((Settings.domoticz_key_idx[device -1] || Settings.domoticz_switch_idx[device -1]) && (svalflg)) { - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"command\":\"switchlight\",\"idx\":%d,\"switchcmd\":\"%s\"}"), - (key) ? Settings.domoticz_switch_idx[device -1] : Settings.domoticz_key_idx[device -1], (state) ? (2 == state) ? "Toggle" : "On" : "Off"); - MqttPublish(domoticz_in_topic); - return 1; - } else { - return 0; + boolean result = 0; + + if (device <= MAX_DOMOTICZ_IDX) { + if ((Settings.domoticz_key_idx[device -1] || Settings.domoticz_switch_idx[device -1]) && (svalflg)) { + snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"command\":\"switchlight\",\"idx\":%d,\"switchcmd\":\"%s\"}"), + (key) ? Settings.domoticz_switch_idx[device -1] : Settings.domoticz_key_idx[device -1], (state) ? (2 == state) ? "Toggle" : "On" : "Off"); + MqttPublish(domoticz_in_topic); + result = 1; + } } + return result; } /*********************************************************************************************\