is there a way I can find out the datetimes that a particular automation ran ? I don’t need the whole trace, just the time it was triggered. The trace view in the automation only seems to go back (say) 5 runs, where I would need to know whether an automation ran or not within a particular time period, further back than the last 5 runs, but no more than 48 hours ago.
all automations have a last_triggered
attribute. You can only get the last triggered time in templates (or anywhere for the most part). You can use the SQL sensor to search for that attribute in the database during a specific time as long as you’re recording that entity (the automation entity) in recorder during the specified timespan.
This example searches the database for a state from x ago. You’d have to modify it to give you the last_triggered attribute.
Sorry, I don’t have any examples that get attributes, I’d have to look at the database tables.
Thanks.
I’m trying to track down why a light got left on when an entity state changed that should have turned it off.
The history of the light shows an automation turning it on, but no turn off automation, suggesting it never fired.
However, the entity (motion sensor) controlling whether or not the turn off automation should have fired, clearly shows a state change that should have triggered the off automation.
Usually that means the motion controller when unavailable monetarily.
Literally after posting my reply, i figured out what was happening.
I over simplified my description, which turned out to be the cause of the issue.
I actually have a PIR sensor AND a mmWave sensor in that room.
For speed, the PIR turns on the light, and the mmWave turns it off.
So the ‘off’ automation waits for the mmWave occupancy to clear.
However, some how this morning, ONLY the PIR got triggered, so the mmWave stayed ‘clear’, thus never triggering the off automation.
This confused me initially because this has never happened before. Now I know this is possible, I’ll look and coding around that scenario, pehaps using a sensor group instead.
Here’s one way. You can adjust to,your needs.
type: custom:auto-entities
show_empty: false
card:
type: entities
title: Last 50 Automations
show_header_toggle: false
filter:
include:
- last_triggered: <24h ago
options:
secondary_info: last-triggered
exclude:
- not:
domain: automation
sort:
method: last_triggered
reverse: true
count: 50
That’s not doing what he’s asking. That’s just showing what automations fired in the last 24 hours. He’s trying to get the time an automation fired between a timeframe, but the automation fired several times after that timeframe changing the last-triggered value.
Yes that will be both more reliable and easier to maintain. Replace a sensor and all you need to do is modify the group. With all=false if any sensor trips it immediately sets ‘on’ and will stay that way until the last sensor turns ‘off’ just make sure your blind windows for all sensors I the group don’t overlap in a way to keep the sensor on all the time.
I have three PIR sensors cover my bedroom this way. Had to extend the blind window of one to match the other two for stability sake