I have automations that need to refer to a variable (an input helper) almost immediately after it is updated by other automations.
Sometimes an automation referring to one of these input helpers gets the old value from it instead of the just newly updated value, even though an automation that just changed the value had finished running 0.25 seconds before.
Use case - someone manually turns off a wall light switch while walking out of the room (input helper is then updated with time of the last manual switch off). The logic kicked off by the motion sensors to turn on the lights look at this same input helper to not turn on the lights if that time was in the last 5 minutes. That logic however still sees the older value in the input helper so it turns the light back on. If I then turn that same wall switch off while walking out of the room again, the lights will not go back on because that input helper had finally changed to a time that is not more than 5 minutes from the current time.
Bottom line is, where do I store that variable such that another automation can read it within 0.25 seconds of it being changed (FYI: It is Ok if this data can be lost during an HA restart)?