Send Task value only if it's different from the previous one - Help with Rules
Posted: 22 Jun 2023, 08:27
Hi.
As requested on Github (https://github.com/letscontrolit/ESPEasy/issues/4709) I would like to have the possibility to tell to ESPEasy to send via MQTT the "new" value only if it's different from the previous one, in my case Temperature and Humidity values from a sensor.
For now it's not (yet) supported so I would like to try to have it via Rules (as suggested into Github Issue).
This is the Rule now I set:
On the log I can see this:
but I don't have any MQTT output.
I have tried different Rules but when I have it working it looks like the "taskrun" will always send both fields (Temperature and Humidity), I did not found a way to let's send via MQTT only the new values for Temperature and Humidity (separately) when one or both changes.
The only really working is the Rules having two different TASK (two different DUMMY device) like that:
Can you help me with Rules having only one "Dummy" Device?
Thanks.
As requested on Github (https://github.com/letscontrolit/ESPEasy/issues/4709) I would like to have the possibility to tell to ESPEasy to send via MQTT the "new" value only if it's different from the previous one, in my case Temperature and Humidity values from a sensor.
For now it's not (yet) supported so I would like to try to have it via Rules (as suggested into Github Issue).
This is the Rule now I set:
Code: Select all
on sht41#Temperature do
if [var#1]!=%eventvalue1%
let,1,%eventvalue1%
TaskValueSet,sht41new,Temperature,%eventvalue1%
taskrun,sht41new#Temperature
endif
endon
on sht41#Humidity do
if [var#2]!=%eventvalue1%
let,2,%eventvalue1%
TaskValueSet,sht41new,Humidity,%eventvalue1%
taskrun,sht41new#Humidity
endif
Endon
Code: Select all
1715779: sht41: Temperature: 27.37
1715782: sht41: Humidity: 56.72
1715797: EVENT: sht41#Temperature=27.37
1715808: ACT : let,1,27.37
1715814: ACT : TaskValueSet,sht41new,Temperature,27.37
1715822: ACT : taskrun,sht41new#Temperature
1715834: EVENT: sht41#Humidity=56.72
1715848: ACT : let,2,56.72
1715853: ACT : TaskValueSet,sht41new,Humidity,56.72
1715861: ACT : taskrun,sht41new#Humidity
I have tried different Rules but when I have it working it looks like the "taskrun" will always send both fields (Temperature and Humidity), I did not found a way to let's send via MQTT only the new values for Temperature and Humidity (separately) when one or both changes.
The only really working is the Rules having two different TASK (two different DUMMY device) like that:
Code: Select all
on sht41#Temperature do
if [var#1]!=%eventvalue1%
let,1,%eventvalue1%
TaskValueSet,sht41temp,Temperature,%eventvalue1%
taskrun,sht41temp
endif
endon
on sht41#Humidity do
if [var#2]!=%eventvalue1%
let,2,%eventvalue1%
TaskValueSet,sht41hum,Humidity,%eventvalue1%
taskrun,sht41hum
endif
endon
Thanks.