Fix support for Domoticz floor/room topics

Fix support for Domoticz floor/room topics. Regression from v12.0.1 (#20299)
This commit is contained in:
Theo Arends 2023-12-23 16:13:13 +01:00
parent b4f1aafc4c
commit a6a8214ea7
3 changed files with 14 additions and 9 deletions

View File

@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file.
- CVE-2021-36603 Cross Site Scripting (XSS) vulnerability (#12221)
- ESP32 piezo ceramic buzzer doesn't buzz (#20118)
- Syslog server warning caused by lack of <PRI> field and hostname starting with 'z' (#14689)
- Support for Domoticz floor/room topics. Regression from v12.0.1 (#20299)
### Removed

View File

@ -121,6 +121,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
- Support for CST816S touch interface [#20213](https://github.com/arendst/Tasmota/issues/20213)
- Support for Sonoff Basic R4 Magic Switch [#20247](https://github.com/arendst/Tasmota/issues/20247)
- NeoPool hydrolysis FL1 and Redox flag [#20258](https://github.com/arendst/Tasmota/issues/20258)
- Matter support for password for remote Tasmota devices [#20296](https://github.com/arendst/Tasmota/issues/20296)
### Breaking Changed
- Refactoring of Berry `animate` module for WS2812 Leds [#20236](https://github.com/arendst/Tasmota/issues/20236)
@ -131,6 +132,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
### Fixed
- CVE-2021-36603 Cross Site Scripting (XSS) vulnerability [#12221](https://github.com/arendst/Tasmota/issues/12221)
- Syslog server warning caused by lack of <PRI> field and hostname starting with 'z' [#14689](https://github.com/arendst/Tasmota/issues/14689)
- Support for Domoticz floor/room topics. Regression from v12.0.1 [#20299](https://github.com/arendst/Tasmota/issues/20299)
- ESP32 piezo ceramic buzzer doesn't buzz [#20118](https://github.com/arendst/Tasmota/issues/20118)
- Matter Contact sensor was not triggering any update [#20232](https://github.com/arendst/Tasmota/issues/20232)

View File

@ -218,14 +218,18 @@ bool DomoticzMqttData(void) {
return true; // No valid data
}
int32_t relay_index = -1;
// char dom_data[XdrvMailbox.data_len +1];
// strcpy(dom_data, XdrvMailbox.data);
// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ "Topic '%s', Data '%s'"), XdrvMailbox.topic, RemoveControlCharacter(dom_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];
relay_index = DomoticzIdx2Relay(atoi(topic_index));
if (relay_index < 0) {
return true; // Idx not mine
int32_t top_index = atoi(topic_index); // 0 if no number (in case of domoticz/out/floor/room)
if (top_index > 0) {
if (DomoticzIdx2Relay(top_index) < 0) {
return true; // Idx not mine
}
}
}
@ -235,18 +239,16 @@ bool DomoticzMqttData(void) {
if (!domoticz) {
return true; // To much or invalid data
}
int32_t relay_index = DomoticzIdx2Relay(domoticz.getUInt(PSTR("idx"), 0));
if (relay_index < 0) {
relay_index = DomoticzIdx2Relay(domoticz.getUInt(PSTR("idx"), 0));
if (relay_index < 0) {
return true; // Idx not mine
}
return true; // Idx not mine
}
int32_t nvalue = domoticz.getInt(PSTR("nvalue"), -1);
if ((nvalue < 0) || (nvalue > 16)) {
return true; // Nvalue out of boundaries
}
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ "idx %d, nvalue %d"), Settings->domoticz_relay_idx[relay_index], nvalue);
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ "Topic %s, idx %d, nvalue %d"), XdrvMailbox.topic, Settings->domoticz_relay_idx[relay_index], nvalue);
bool iscolordimmer = (strcmp_P(domoticz.getStr(PSTR("dtype")), PSTR("Color Switch")) == 0);
bool isShutter = (strcmp_P(domoticz.getStr(PSTR("dtype")), PSTR("Light/Switch")) == 0) && (strncmp_P(domoticz.getStr(PSTR("switchType")),PSTR("Blinds"), 6) == 0);