I got a humidity sensor running, that is sending me a notification if the humidity i over 70%, and another one when it comes back under 70%.
But i got the problem that for some reason I have to restart my zigbee2mqtt docker container, because it simply stops sending data to HA. To fix this, I’m restarting the zigbee2mqtt container once per hour.
What happens is, that I’m getting the notification for the humidity every time the container restarts, even the value is still under <70%.
Is it possible to make a condition, that HA won’t send a notification, if the current state, like <70% humidity, was already there before the container restarted?
Using that it will only trigger if the sensor goes from exactly 70 to exactly 69. So if it starts at 71 it won’t trigger, and if it ends at 68 it won’t trigger. I’d suggest instead a number state trigger using the above: and below: options. This is similar to what you were doing before, but maybe you need to do it as a numberic state trigger. Actually, now that I’m looking closer at your code snippet, that looks like a sensor configuration. Are you doing this from an automation? If so, you might need to check your YAML (or use the GUI to construct the trigger for the automation), as it doesn’t look like what I’d expect to see in an automation.
It likely happens because the state briefly changes to “unavailable” when the docker container is restarted.
So in the condition of the automation, use a template:
{{ trigger.from_state.state not in ['unavailable','unknown'] }}
will stop the automation triggering if the previous state was either unknown or unavailable.