Once only notifications

I am looking for some logic help. I want to be notified when a variable (BatterySoC) reaches a certain value. But I only want to be notified once. So set a flag and test it before being notified. The problem is that it has to be reset at some time. The problem I have is that even when it is set under certain conditions I still keep getting notified for some reason, maybe because the flag gets reset.
So I’m looking to your collective experience to come up with a better way.
Might this be better done in Homey Script?

Here is an example of the flow I developed.

I think this should do, Peter.

When…
-logic value X changed
And…
-logic value X is less than 500
-logic [powerfromgridnotified] is No
Then…
-send notification power is imported from grid (less than 500W)
-set logic [powerfromgridnotified] to Yes
Else…
-set logic [powerfromgridnotified] to No

This should send a notification when value X is below 500,
and when the logic switch [powerfromgridnotified] is set to No.
It also sets the logic switch to Yes.

Now, when value X changed, and it’s is again below 500, it won’t send a notif, while [powerfromgridnotified] is Yes.

Only when value X changed to greater than 500, it sets the logic switch [powerfromgridnotified] to No.

During the day the power will rise several times above 500 and will fall below 500 as clouds go by. So you have to set Setpowerfromgrid to no at midnight in a second flow.

Thanks guys