I am trying to integrate a humidity sensor with an external API. I have a script (as in a Home Assistant ScriptTM - not Bash or Perl) using a template that updates an API as the humidity changes. What I want to do now is create an automation that only runs the script when the humidity changes by 5% to keep the sampling under control. An example:
If the current humidity is 45% and raises to 47% or lowers to 41% - the automation should not run. That first sampled value of 45% is essentially a bench mark. So for the next 10000 years if the humidity never deviates more that +/- 5% from the first value taken, don’t run the automation. As soon as the humidity rises to 53%, the automation should run and 53% is the new bench mark and the automation won’t run so long as the humidity doesn’t change by +/- 5%. Then the humidity jumps to 87% - that’s the new bench mark etc and so forth for the rest of time.