mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 02:36:35 +00:00
Add domoticz idx check
Add domoticz idx check while staying backwards compatible (#15677)
This commit is contained in:
parent
6397f9b4ae
commit
e5765a1cd6
@ -202,11 +202,28 @@ bool DomoticzMqttData(void) {
|
||||
return false; // Process unchanged data
|
||||
}
|
||||
|
||||
// topic is domoticz/out so try to analyse
|
||||
// topic is domoticz/out so check if valid data could be available
|
||||
if (XdrvMailbox.data_len < 20) {
|
||||
return true; // No valid data
|
||||
}
|
||||
|
||||
// Quick check if this is mine using topic domoticz/out/{$idx}
|
||||
if (strlen(XdrvMailbox.topic) > strlen(DOMOTICZ_OUT_TOPIC)) {
|
||||
char* topic_index = &XdrvMailbox.topic[strlen(DOMOTICZ_OUT_TOPIC) +1];
|
||||
uint32_t idx = atoi(topic_index);
|
||||
uint8_t maxdev = (TasmotaGlobal.devices_present > MAX_DOMOTICZ_IDX) ? MAX_DOMOTICZ_IDX : TasmotaGlobal.devices_present;
|
||||
bool not_found = true;
|
||||
for (uint32_t i = 0; i < maxdev; i++) {
|
||||
if (idx == Settings->domoticz_relay_idx[i]) {
|
||||
not_found = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (not_found) {
|
||||
return true; // Idx not mine
|
||||
}
|
||||
}
|
||||
|
||||
String domoticz_data = XdrvMailbox.data; // Copy the string into a new buffer that will be modified
|
||||
JsonParser parser((char*)domoticz_data.c_str());
|
||||
JsonParserObject domoticz = parser.getRootObject();
|
||||
|
Loading…
x
Reference in New Issue
Block a user