Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Q: rules - trigger on changed values? #4372
Using Tasmota 6.3.0.
I want to send Current, Voltage and Power every minute from a Sonoff POW to an external system using the WEBSEND command using rules.
From my understanding:
So far, this works well - see my rule code below.
QUESTION 1: a trigger like "Energy#Power" is triggered every around 2 seconds on my device. My code therefore would permanently update three variables every two seconds. This MIGHT be a performance problem for our small gadget, so I would need some trigger functionality like "one-shot value change". Like one-shot which only fires if there is a trigger change, but in my case "fire if the trigger fires AND the value is different than the one before".
QUESTION 2: I wand to once define the variables at boot time using the sensor values. While this worked well for a power state using "on Power1#Boot do var1 %value% endon", I can't find such a possibility for the Sonoff POW. I'd need something like "on Energy#PowerBoot do var1 %value% endon" to get access to the "Power" sensor of "Energy" at boot time. Is there a way to achieve this?
If there are no solutions in Tasmota that I missed, these would be my feature requests:
Any help appreciated. Great system, thanks a lot to the author(s) and contributors!
Oh thanks, that example helped. I didn't read it before as it was labeled and implemented quite specific:
Perhaps it would be helpful for others to add a more generic example to the Wiki:
Reacting on a sensor value only on changed values:
Note: %var1% should be initialized or it will initially be compared to an undefined value, ie:
Please, try this. Hope this solves your requirements.
Your solution has two weaknesses:
A way to initialize variables with Energy sensor values like Current at boot time, so guaranteed to be there before any other regular rule triggers, still doesn't seem to be possible, am I right?
Your first statement is right. Can be solved with the following example.
And the triggers of the rules are being evaluated in the same order they were written. So, no issue there.