Automation not executed - how to troubleshoot

Hey all,

I need some assistance with troubleshooting some automations.
every now and than, i walk by a motion sensor, waiting for the light to light-up, just to be disappointed.
Than, while mumbling various curse words at the motion sensor as i walk over to check what went wrong, i see that the motion sensor worked fine, but for mysterious reason the automation went with “no action was executed”.
it looks like this:


this is just a simple automation to turn on a lite, with different brightens values depending on “time” (of day).
can anyone give some pointers as to where would be the best place to look for a solution to figure out why this (or any other misbehaving automation) happens?
ill be happy to provide other info as needed. but what I’m looking for is some tips on how to troubleshoot in general, and not specific to this automation.
cheers

If you want our help, it is much easier for us if you share the the YAML configuration of the automation.

From the image of the trace’s flow diagram you posted it looks like your trigger fired, but none of the Choose action’s condition sets passed, so none of the action sequences were executed.

understood, i am trying to figure out where to look for a reason - which condition was not met.
in this specific case the light turned on 15 s later, as the motion sensor fired up again and the automation re-triggered.
thanks for the link, i will check it out. i just love this community so much that my “GO TO” is usually here… :slight_smile:
here is the yaml

alias: entrance dining spot light with motion hue
description: ""
triggers:
  - type: motion
    device_id: 177bdf029c1ae1c2ec850cddd89acfc7
    entity_id: cdc866f11fb579a2b4e50936113e4342
    domain: binary_sensor
    trigger: device
    id: motion
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - motion
          - condition: sun
            after: sunset
            after_offset: "-00:30:00"
          - condition: time
            before: "21:00:00"
          - condition: state
            entity_id: light.entrance
            state: "off"
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              transition: 5
              brightness_pct: 70
            target:
              entity_id: light.entrance
          - wait_for_trigger:
              - type: no_motion
                device_id: 177bdf029c1ae1c2ec850cddd89acfc7
                entity_id: cdc866f11fb579a2b4e50936113e4342
                domain: binary_sensor
                trigger: device
                for:
                  hours: 0
                  minutes: 5
                  seconds: 0
            timeout:
              hours: 1
              minutes: 0
              seconds: 0
              milliseconds: 0
          - action: light.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: light.entrance
      - conditions:
          - condition: trigger
            id:
              - motion
          - condition: time
            after: "21:00:00"
          - condition: state
            entity_id: light.entrance
            state: "off"
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              transition: 15
              brightness_pct: 10
            target:
              entity_id: light.entrance
          - wait_for_trigger:
              - type: no_motion
                device_id: 177bdf029c1ae1c2ec850cddd89acfc7
                entity_id: cdc866f11fb579a2b4e50936113e4342
                domain: binary_sensor
                trigger: device
                for:
                  hours: 0
                  minutes: 5
                  seconds: 0
            timeout:
              hours: 1
              minutes: 0
              seconds: 0
              milliseconds: 0
          - action: light.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: light.entrance
      - conditions:
          - condition: trigger
            id:
              - motion
          - condition: sun
            before: sunrise
            before_offset: "-01:00:00"
          - condition: state
            entity_id: light.entrance
            state: "off"
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              transition: 15
              brightness_pct: 5
            target:
              entity_id: light.entrance
          - wait_for_trigger:
              - type: no_motion
                device_id: 177bdf029c1ae1c2ec850cddd89acfc7
                entity_id: cdc866f11fb579a2b4e50936113e4342
                domain: binary_sensor
                trigger: device
                for:
                  hours: 0
                  minutes: 5
                  seconds: 0
            timeout:
              hours: 1
              minutes: 0
              seconds: 0
              milliseconds: 0
          - action: light.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: light.entrance
mode: single

If you click on the conditions for each Option of the choose (the empty square symbol), the “Step Details” should populate with information about the conditions that passed and/or failed. However, it may not show all the conditions for a given Option because the checks stop after the first failed condition.

That part of my problem, i guess.
with my logic, and the way i’m (clearly poorly) reading the info - it looks like “it should’ve worked”, and i cant get a “clear enough” reason as to way it didnt work as i thought…
ill try figure things out with the pointers given here, and will post again next time i’ll get baffled.
stay tunned… :slight_smile:
and thanks for the help and quick replies so far.
appreciated as always
cheers

The flow diagram suggests that none of your condition blocks was met, which caused the flow to go straight to the end with no action taken.

A couple of comments:

  • it’s much easier to read and debug entity-based triggers and actions rather than device-based ones. So, for example:
triggers:
  - trigger: state
    entity_id: binary_sensor.YOUR_MOTION_SENSOR_ID
    to: 'on'
  • It’s also not a great idea to build long execution times into automations. As each of your sequences does the same thing, I’d be inclined to move the turning-off logic to a separate automation:
triggers:
  - trigger: state
    entity_id: binary_sensor.YOUR_ENTITY_ID
    to: 'off'
    for:
      minutes: 5
  - trigger: state
    entity_id: light.entrance
    to: 'on'
    for:
      hours: 1
actions:
  - action: light.turn_off
    target:
      entity_id: light.entrance
1 Like

gr8, i was just wondering about this issue myself. though the devices are Easley identified via UI mode, its unnecessary harder to understand which is which via yaml.
i will return to using entities when re-writing the automations I’m dealing with.
also understand your logic about the “off” sequence, as i use the “off” as a separated trigger in most of my automations.
thing is, in this case, i didn’t want the automation to trigger “off”, if i manually turned on the light, so it made sense to have it turned off, only if the automation turned it on itself.
you are correct of course, as i found the hard way misbehaving “too long sequences” automations, and needed to rewrite’m.

OK
so… can i get some clarification on “this”?

here is the yaml:

alias: lights and power, ete away gps, unifi 10 min - notification
description: ""
triggers:
  - entity_id:
      - person.ete
    from: home
    to: not_home
    for:
      hours: 0
      minutes: 10
      seconds: 0
    id: s23 not home unifi & gps
    trigger: state
  - event_type: mobile_app_notification_action
    event_data:
      action: turn_lights_off
    id: turn lights off
    context: {}
    enabled: true
    trigger: event
  - entity_id:
      - person.ete
    from: home
    to: not_home
    for:
      hours: 0
      minutes: 10
      seconds: 1
    id: s23 not home unifi & gps 10.1S
    trigger: state
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - s23 not home unifi & gps
          - condition: state
            entity_id: binary_sensor.light_state
            state: "off"
        sequence:
          - data:
              data:
                ttl: 0
                priority: high
              message: All lights are off
              title: Yey
            action: notify.mobile_app_s23ultra
        alias: not home for 10m and lights are off
      - conditions:
          - condition: trigger
            id:
              - s23 not home unifi & gps
          - condition: state
            entity_id: binary_sensor.light_state
            state: "on"
        sequence:
          - action: notify.mobile_app_s23ultra
            data:
              message: >-
                {% set lights_on = states.light | selectattr('state', 'eq',
                'on') | map(attribute='name') | list %} {% if lights_on | length
                > 0 %}   {{ lights_on | join(', ') }} {% else %}   No lights are
                on. {% endif %}
              data:
                actions:
                  - action: turn_lights_off
                    title: turn lights off
                ttl: 0
                priority: high
              title: You forgot some lights on
        alias: not home for 10m and lights are ON
      - conditions:
          - condition: trigger
            id:
              - turn lights off
        sequence:
          - action: light.turn_off
            metadata: {}
            data: {}
            target:
              area_id:
                - balcony
                - bathroom
                - bedroom
                - bedroom_bath
                - corridor
                - kitchen
                - living_room
                - utilities
          - delay:
              hours: 0
              minutes: 0
              seconds: 15
              milliseconds: 0
          - action: notify.mobile_app_s23ultra
            metadata: {}
            data:
              message: " {% set lights_on = states.light | selectattr('state', 'eq', 'on') |     map(attribute='name') | list %} {% if lights_on | length > 0 %}   {{     lights_on | join(', ') }} {% else %}   No lights are on. {% endif %}"
              title: the request was sent and maybe all lights are off now
              data:
                actions:
                  - action: turn_lights_off
                    title: turn lights off
                ttl: 0
                priority: high
        alias: actionable notification - Turn lights off form s23
      - conditions:
          - type: is_apparent_power
            condition: device
            device_id: 3aeb91abab2af25ff5d7ea751673ad2a
            entity_id: 93186278bf63ae724e4b1488c12aab7e
            domain: sensor
            above: 1000
          - condition: trigger
            id:
              - s23 not home unifi & gps 10.1S
        sequence:
          - action: notify.mobile_app_s23ultra
            data:
              message: >
                The power draw is
                {{states('sensor.shellypro3em_34987a46e1ac_total_apparent_power')|float}}
        alias: hot home for 10m and overall power is over 1000
mode: parallel
max: 10

what is this ZIGBEE delivery fail? should it “freeze” the entire automation, sequence?