#Time since event sensor triggered in automation

1 messages · Page 1 of 1 (latest)

elder ember
#

I have to replace ring motion input_boolean with an event. In my automation I check if it has been 5 minutes since last motion. This was easy when it was a input Boolean since I can use for: 5mins on the state trigger or condition, but I cant do this anymore since I can’t set the value it should be for an event as it’s set to the date. Is there something similar I can do without having to rewrite the automation?

I feel like the answer should be on this page: https://www.home-assistant.io/integrations/event/

Home Assistant

Instructions on how to use event entities in Home Assistant.

sharp galleon
#

Why do you need to replace the input_boolean with an event?

elder ember
#

Ring is deprecating it: This stops working in version 2025.4.0. Please address before upgrading.

sharp galleon
#

You could make an automation change the input_boolean when motion is detected, and have it turn back off after a 5 minute delay. Or even better, create a trigger-based binary template sensor in YAML with auto_off set to 5 minutes.
https://www.home-assistant.io/integrations/template/#auto_off

Home Assistant

Instructions on how to integrate Template Sensors into Home Assistant.

#

In an automation, you can’t check how long ago an event occurred because that information is not available in the hass object.

#

If there was an event entity available you could check when it last changed (which would be its state)

elder ember
#

@sharp galleon thanks for the quick reply and helpful recommendations. I was hoping to not have to redo my integrations by replacing my conditions and triggers with something simple. Given that the event entity's value itself is a timestamp, I am surprised there isn't a condition or trigger type that lets you check how long it has been since the event triggered.

sharp galleon
#

Yes, if you are looking at an event entity rather than an event, you can just use a state condition with the for option

#

An event entity and an event are two different things

#

In other words, simply replace your input Boolean in your condition with your event entity.

elder ember
#

Aah, it almost worked but state is required for condition. I might have to write a template that reads the value and compares it to the current time.

sharp galleon
#

Hmm. That’s unfortunate.

You could use this for the template. This uses the last_changed property instead of the state, but either will work.

{{ states.event.my_motion_event.last_changed | as_datetime < now() - timedelta(minutes=5) }}
elder ember
#

Sorry I missed this reply, but I came up with something similar! {{ (now() - (states.event.garage_motion.state | as_datetime)) < timedelta(minutes=5) }} I think I like using last_changed as you are doing better. Will adopt that!