I’ve got a node-red job that polls the REST API for my propane tank level sensor every hour. Let’s say the propane company comes out at 7:30 and refills the tank. The tank was at say 52% and now it’s at 79%. I want to get a notification that the tank was refilled.
In order to do this I need to trigger when the previous state was below 60 and the new state is above 75
Put your tank’s REST sensor into a Trend binary sensor and run the automation, if the trend sensor’s state changes from off to on (ascending REST sensor value).
Not a bad idea, except the sensor value will change slightly depending on the outside air temp. As the day warms up the pressure inside the tank will increase, slightly changing the value of the sensor to read fuller throughout the day. This is why it has to be large scale change from below 60 to above 75. In a typical day the reading may be 68 in the morning and 70 in the afternoon. In a trend sensor that’s a false trigger.
This is probably the best I’ve seen so far. I ended up taking the easy way out. I modified my node-red flow to record the value the entity before updating it. Then it compares the two and if the criteria fits, it fires an event over to HomeAssistant and then I’ve got an automation that triggers on the event. No extra helpers needed.
Although I do like your idea of a tank min number helper. That could be useful in other logic as well. I may end up going with your solution after all.