Check what automations/scripts are running

I have some automations/scripts that are hung up and remain running. When I go to restart HA, I get the warning that it will interrupt running automations/scripts. Is there a way I can check to see what automations/scripts are running? These are obvislouly ones that I don’t have programmed well and are stuck in a running state and I need to fix them.

Thanks.

  1. Go to Developer Tools > States
  2. Type the word current in the Attributes column
  3. If an automation is currently in the process of executing its actions, the value of its current attribute will be greater than 0.

Most automations take very little time to execute their actions. If it does spend a lot of time then it can be because its actions include a delay statement or a wait_template or a wait_for_trigger or repeat.


EDIT

You can also copy-paste the following template into the Template Editor and it will list the names of the automations (if any) that are currently executing their actions.

{{ states.automation | selectattr('attributes.current', '>', 0)
  | map(attribute='name') | join('\n') }}
2 Likes

Or for a third option you can install the custom cards, auto-entities and fold-entity-row and use this card config:

Screenshot 2024-01-17 at 13-40-44 Administration – Home Assistant

entities:
  - card:
      head:
        label: Disabled Automations
        type: section
      padding: 0
      type: custom:fold-entity-row
    filter:
      exclude:
        - state: 'on'
        - state: unavailable
      include:
        - domain: automation
    sort:
      ignore_case: true
      method: name
    type: custom:auto-entities
  - card:
      head:
        label: Missing Automations
        type: section
      padding: 0
      type: custom:fold-entity-row
    filter:
      exclude:
        - attributes:
            current: '= 0'
        - attributes:
            current: '= 1'
      include:
        - domain: automation
    show_empty: true
    sort:
      ignore_case: true
      method: name
    type: custom:auto-entities
  - card:
      head:
        label: Running Automations
        type: section
      padding: 0
      type: custom:fold-entity-row
    filter:
      exclude:
        - state: unavailable
        - attributes:
            current: '= 0'
      include:
        - domain: automation
    show_empty: true
    sort:
      ignore_case: true
      method: name
    type: custom:auto-entities
  - card:
      head:
        label: Running Scripts
        type: section
      padding: 0
      type: custom:fold-entity-row
    filter:
      exclude:
        - state: 'off'
      include:
        - domain: script
    show_empty: true
    sort:
      ignore_case: true
      method: name
    type: custom:auto-entities
show_header_toggle: false
title: Autofilled Lists
type: entities
3 Likes

This template is exactly what I need but I get a message “UndefinedError: homeassistant.util.read_only_dict.ReadOnlyDict object “ has no attribute ‘current’. I get this even when I know I have a running automation.

You have at least one automation whose state is unavailable. This kind of automation doesn’t have a current attribute and causes the template to fail.

This version selects automations that have a current attribute before checking if its value is greater than zero.

{{ states.automation 
  | selectattr('attributes.current', 'defined')
  | selectattr('attributes.current', '>', 0)
  | map(attribute='name') | join('\n') }}
4 Likes

That’s was it! Thank you.