Trigger only from a given state to another one

In HA automations there is an option to trigger an automation if a state change from a state to another one. E.g. a sensor has 4 states: One,Two, Three, Four and I wan’t to trigger an automation when the sensor goes to Four from Two, but do not trigger when it goes Four from One or Three. It is possible whith a normal HA automation with filling the “From:” and “To:” fields in the triiger.
But how can I do this in Node-Red?
(And also wondering how can I make a template sensor to change only when another Sensor goes to a state from a given previous state, but this is not related to this subtopic…)

You can use a Trigger State Node.

You can set conditions based on both the current state and the previous state - if all conditions are true it’s routed to one output, if any are false it routes to another (which can be ignored, if you don’t want to do anything with it).

1 Like

Thanks a lot. And how stupid I am, I used the Trigger state before :frowning:
Thank you again! :slight_smile:

No problem, you might want to consider marking it as the answer to help others in future.

1 Like