Skip to content

Commit

Permalink
Fix support for Domoticz floor/room topics
Browse files Browse the repository at this point in the history
Fix support for Domoticz floor/room topics. Regression from v12.0.1 (arendst#20299)
  • Loading branch information
arendst authored and hawa-lc4 committed Dec 30, 2023
1 parent 02ceb9c commit 923f9d1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Expand Up @@ -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)
Expand All @@ -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)

Expand Down
20 changes: 11 additions & 9 deletions tasmota/tasmota_xdrv_driver/xdrv_07_domoticz.ino
Expand Up @@ -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
}
}
}

Expand All @@ -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);
Expand Down

0 comments on commit 923f9d1

Please sign in to comment.