diff --git a/CHANGELOG.md b/CHANGELOG.md index 828a099c7..da65a65c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ All notable changes to this project will be documented in this file. ### Changed - Support syslog updates every sleep or every second if `#define SYSLOG_UPDATE_SECOND` (#20260) -- Moved Berry animate to its own `berry_animate` lib +- Moved Berry animate to its own `berry_animate` lib (#20309) ### Fixed - Matter Contact sensor was not triggering any update (#20232) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_07_domoticz.ino b/tasmota/tasmota_xdrv_driver/xdrv_07_domoticz.ino index 2994eeafc..99e45cfce 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_07_domoticz.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_07_domoticz.ino @@ -18,10 +18,29 @@ */ #ifdef USE_DOMOTICZ +/*********************************************************************************************\ + * Domoticz support + * + * Adds commands: + * DzIdx - Set power number to Domoticz Idx allowing Domoticz to control Tasmota power + * DzKeyIdx - Set button number to Domoticz Idx allowing Tasmota button as input to Domoticz + * DzSwitchId - Set switch number to Domoticz Idx allowing Tasmota switch as input to Domoticz + * DzSensorIdx - Set sensor type to Domoticz Idx + * DzUpdateTimer 0 - Send power state at teleperiod to Domoticz (default) + * DzUpdateTimer - Send power state at interval to Domoticz + * DzSend1 , - {\"idx\":,\"nvalue\":0,\"svalue\":\"\",\"Battery\":xx,\"RSSI\":yy} + * Example: rule1 on power1#state do dzsend1 9001,%value% endon + * DzSend1 418,%var1%;%var2% or DzSend1 418,%var1%:%var2% - Notice colon as substitute to semi-colon + * DzSend2 , - USE_SHUTTER only - {\"idx\":,\"nvalue\":,\"svalue\":\"\",\"Battery\":xx,\"RSSI\":yy} + * DzSend3 , - {\"idx\":,\"nvalue\":,\"Battery\":xx,\"RSSI\":yy} + * DzSend4 , - {\"command\":\"switchlight\",\"idx\":,\"switchcmd\":\"\"} + * DzSend5 , - {\"command\":\"switchscene\",\"idx\":,\"switchcmd\":\"\"} +\*********************************************************************************************/ #define XDRV_07 7 -//#define D_PRFX_DOMOTICZ "Domoticz" +//#define USE_DOMOTICZ_DEBUG // Enable additional debug logging + #define D_PRFX_DOMOTICZ "Dz" #define D_CMND_IDX "Idx" #define D_CMND_KEYIDX "KeyIdx" @@ -218,16 +237,17 @@ bool DomoticzMqttData(void) { return true; // No valid data } -// 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)); +#ifdef USE_DOMOTICZ_DEBUG + char dom_data[XdrvMailbox.data_len +1]; + strcpy(dom_data, XdrvMailbox.data); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ "%s = %s"), XdrvMailbox.topic, RemoveControlCharacter(dom_data)); +#endif // USE_DOMOTICZ_DEBUG // 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]; - 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) { + if (strchr(topic_index, '/') == nullptr) { // Skip if topic ...floor/room + if (DomoticzIdx2Relay(atoi(topic_index)) < 0) { return true; // Idx not mine } } @@ -248,7 +268,7 @@ bool DomoticzMqttData(void) { return true; // Nvalue out of boundaries } - AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ "Topic %s, idx %d, nvalue %d"), XdrvMailbox.topic, Settings->domoticz_relay_idx[relay_index], nvalue); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ "%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);