I’m trying to do something that I’m not sure will work reliably and need advice.
I have a sensor that updates every minute.
Every time the sensor updates I want to capture the results of the sensor value in the “previous” state and in the “current” state. I’ve got that worked out using two input_texts (current_value & previous_value) and a script that gets triggered when the sensor changes that puts the input_text.current_value into the input_text.previous_value and then updates the input_text.current value with the new value of the sensor.
Then I want to trigger several automations using the change in state of the sensor as a trigger and using a comparison between the current_value & previous_value input_texts as a condition (current_value > previous value). That part is pretty straight forward so I’ve got all of that worked out.
so far so good…
The potential problem:
If the register shift moving the current_value into the previous_value then updating the current_value always takes place before the automations notice the state of the sensor changing and triggering then everything will work as expected. If the register shift gets delayed until after the trigger happens for the automations then they will not meet the conditions for the automation to run even tho, technically, they should run.
The question I have is how can I be sure that the register shift always occurs prior to the automations triggering?
EDIT:
Or am I being concerned for no reason? Will this ever be a problem?