The correct way of telling when the sun has risen/set

I started using Node-Red yesterday, and I’ve set up a simple flow to let me know when the sun has risen. In Home Assistant is as simple as this.

In Node-Red I did this


And this is the contents of “sun above horizon”

But now I keep getting these notifications every two minutes.

Shouldn’t just let me know when the sun has risen?

What if I want to turn off a light when the sun has risen? Will it send an “OFF” command every two minutes?

What I’m I doing wrong here?

The trigger node fires whenever the sun entity updates—this includes state and attribute changes. So, attributes like elevation or azimuth updating every couple of minutes are what’s causing your flow to trigger.

If you only care about the state change, switch to the simpler “events: state” node, which has the option “Ignore state change events when: Current state equals previous state.”

You can achieve the same with the “trigger: state” node by adding a condition:
This entity → previous state → is not → above_horizon.

yes, this seemed to do the trick.

Thanks

What Kermit said. Here’s a view of what that events: state node looks like