Which automation did that?

It’d be amazing if automations / scripts could be part of the Context in the Logbook. Ie we know which user / Alexa turned a light on but we don’t have the context of which automation did it. This would be super useful generally, but for debugging also. Thanks!

There is a thread with a template that generates a reverse chronological list of automations on the times they last triggered
Given you know when the action you observed happened this should narrow it down for you.

I’ll see if I can fing a link …


Please give Phil & Taras a like for this.

But for a short-cut : -

{% for state in states.automation | selectattr('attributes.last_triggered') | sort(attribute='attributes.last_triggered', reverse=true) -%}
  {{ state.attributes.last_triggered.timestamp() | timestamp_local }} : {{ state.name }}
{% endfor %}

Note: this is just used as a debugging tool

2 Likes

I understood the request in that way that you could see in the logbook which automation caused a switch turning on as you can see which person turned something on or off.

You can add a service call (logbook.log) to all your automations. It can report to logbook not only the name of the automation that just ran but also what triggered it.

I provided an example here:

2 Likes