diff --git a/tasmota/xdrv_07_domoticz.ino b/tasmota/xdrv_07_domoticz.ino index 0342e6d89..b469ef1d5 100644 --- a/tasmota/xdrv_07_domoticz.ino +++ b/tasmota/xdrv_07_domoticz.ino @@ -360,7 +360,7 @@ bool DomoticzSendKey(uint8_t key, uint8_t device, uint8_t state, uint8_t svalflg \*********************************************************************************************/ void DomoticzSendData(uint32_t sensor_idx, uint32_t idx, char *data) { - char payload[128]; + char payload[128]; // {"idx":26700,"nvalue":0,"svalue":"22330.1;10234.4;22000.5;10243.4;1006;3000","Battery":100,"RSSI":10} if (DZ_AIRQUALITY == sensor_idx) { snprintf_P(payload, sizeof(payload), PSTR("{\"idx\":%d,\"nvalue\":%s,\"Battery\":%d,\"RSSI\":%d}"), idx, data, DomoticzBatteryQuality(), DomoticzRssiQuality()); @@ -506,6 +506,7 @@ void CmndDomoticzUpdateTimer(void) { void CmndDomoticzSend(void) { // DzSend1 , - {\"idx\":,\"nvalue\":0,\"svalue\":\"\",\"Battery\":xx,\"RSSI\":yy} + // 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\":\"\"} @@ -517,6 +518,7 @@ void CmndDomoticzSend(void) { char *data; uint32_t index = strtoul(strtok_r(XdrvMailbox.data, ",", &data), nullptr, 10); if ((index > 0) && (data != nullptr)) { + ReplaceChar(data,':',';'); // As a workaround for command backlog inter-command separator if (XdrvMailbox.index > 3) { uint32_t state = strtoul(data, nullptr, 10); // 0, 1 or 2 DomoticzSendSwitch(XdrvMailbox.index -4, index, state); diff --git a/tasmota/xsns_90_hrg15.ino b/tasmota/xsns_90_hrg15.ino index dadbfd75d..0743d8902 100644 --- a/tasmota/xsns_90_hrg15.ino +++ b/tasmota/xsns_90_hrg15.ino @@ -24,7 +24,9 @@ * https://rainsensors.com/rg-9-15-protocol/ * * Rule for Domoticz Rain sensor index 418: - * on tele-rg-15#flowrate do var1 %value% endon on tele-rg-15#event do dzsend1 418,%var1%;%value% endon + * on tele-rg-15#flowrate do var1 %value% endon + * on tele-rg-15#event do backlog var2 %value%; mult1 100; event sendrain endon + * on event#sendrain do dzsend1 418,%var1%;%var2% endon \*********************************************************************************************/ #define XSNS_90 90 @@ -84,7 +86,7 @@ bool Rg15ReadLine(char* buffer) { return true; } -float Rg15Parse(char* buffer, const char* item) { +bool Rg15Parse(char* buffer, const char* item, float* result) { char* start = strstr(buffer, item); if (start != nullptr) { char* end = strstr(start, " mm"); // Metric (mm or mmph) @@ -94,12 +96,12 @@ float Rg15Parse(char* buffer, const char* item) { if (end != nullptr) { char tmp = end[0]; end[0] = '\0'; - float result = CharToFloat(start + strlen(item)); + *result = CharToFloat(start + strlen(item)); end[0] = tmp; - return result; + return true; } } - return 0.0f; + return false; } bool Rg15Process(char* buffer) { @@ -108,10 +110,10 @@ bool Rg15Process(char* buffer) { // Acc 0.001 in, EventAcc 0.002 in, TotalAcc 0.003 in, RInt 0.004 iph // Acc 0.001 mm, EventAcc 0.002 mm, TotalAcc 0.003 mm, RInt 0.004 mmph, XTBTips 0, XTBAcc 0.01 mm, XTBEventAcc 0.02 mm, XTBTotalAcc 0.03 mm if (buffer[0] == 'A' && buffer[1] == 'c' && buffer[2] == 'c') { - Rg15.acc = Rg15Parse(buffer, "Acc"); - Rg15.event = Rg15Parse(buffer, "EventAcc"); - Rg15.total = Rg15Parse(buffer, "TotalAcc"); - Rg15.rate = Rg15Parse(buffer, "RInt"); + Rg15Parse(buffer, "Acc", &Rg15.acc); + Rg15Parse(buffer, "EventAcc", &Rg15.event); + Rg15Parse(buffer, "TotalAcc", &Rg15.total); + Rg15Parse(buffer, "RInt", &Rg15.rate); if (Rg15.acc > 0.0f) { Rg15.time = RG15_EVENT_TIMEOUT; // We have some data, so the rain event is on-going