Fix invalid response

Fix invalid response using more than 4 switches and domoticz
This commit is contained in:
Theo Arends 2018-07-12 14:24:17 +02:00
parent a489b4a44a
commit 5372cdf511
2 changed files with 11 additions and 7 deletions

View File

@ -1,4 +1,5 @@
/* 6.1.0a /* 6.1.0a
* Fix invalid response using more than 4 switches and domoticz
* Update sensor drivers to provide instant results * Update sensor drivers to provide instant results
* Add read sensor retry to DS18B20, DS18x20, DHT, SHT1X and HTU21 * Add read sensor retry to DS18B20, DS18x20, DHT, SHT1X and HTU21
* Change SHT1x driver to provide better instant results * Change SHT1x driver to provide better instant results

View File

@ -271,14 +271,17 @@ boolean DomoticzCommand()
boolean DomoticzSendKey(byte key, byte device, byte state, byte svalflg) boolean DomoticzSendKey(byte key, byte device, byte state, byte svalflg)
{ {
if ((Settings.domoticz_key_idx[device -1] || Settings.domoticz_switch_idx[device -1]) && (svalflg)) { boolean result = 0;
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"); if (device <= MAX_DOMOTICZ_IDX) {
MqttPublish(domoticz_in_topic); if ((Settings.domoticz_key_idx[device -1] || Settings.domoticz_switch_idx[device -1]) && (svalflg)) {
return 1; snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"command\":\"switchlight\",\"idx\":%d,\"switchcmd\":\"%s\"}"),
} else { (key) ? Settings.domoticz_switch_idx[device -1] : Settings.domoticz_key_idx[device -1], (state) ? (2 == state) ? "Toggle" : "On" : "Off");
return 0; MqttPublish(domoticz_in_topic);
result = 1;
}
} }
return result;
} }
/*********************************************************************************************\ /*********************************************************************************************\