Automation did not fire ? -- can't find out why

So… I have a light left on overnight (again!)… last time this happened, I did some digging and found an error in my logs showing the device did not respond.

Todays issue is different… different light, no errors in the logs.
The light is turned on and off by a mmwave sensor, and this is its log book entry:

image

You can see that occupancy was last detected at 23:09:37 and cleared at 23:26:06 yesterday, and wasn’t detected again until 08:56:41 this morning.

This is the lights log book:

image

You can see that the light was turned on exactly at 23:09:37 as occupancy was detected, but thats the last entry for the day. So nothing happened (no automation fired) 17 minutes later at 23:26:06 to turn the light off.

This is the automation:

alias: Office - Motion Lights Off v2
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.tuya_plug_office_pc_only_active_power
    below: 5
    id: power
  - platform: state
    entity_id:
      - binary_sensor.tuya_mmwave_office_occupancy
    to: "off"
    id: occupancy
  - platform: state
    entity_id:
      - sensor.tuya_mmwave_office_illuminance
    id: illuminance
    for:
      hours: 0
      minutes: 0
      seconds: 2
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - illuminance
          - condition: template
            value_template: >-
              {{states('sensor.tuya_mmwave_office_illuminance')|int(0) >
              (states('input_number.office_illuminance_threshold')|int(0)+30)}}
        sequence:
          - service: light.turn_off
            data: {}
            target:
              entity_id: light.tuya_rgb_bulb_office_light
      - conditions:
          - condition: trigger
            id:
              - power
              - occupancy
        sequence:
          - wait_for_trigger:
              - platform: state
                entity_id:
                  - binary_sensor.tuya_mmwave_office_occupancy
                to: "off"
            timeout:
              hours: 0
              minutes: 2
              seconds: 1
              milliseconds: 0
            continue_on_timeout: true
          - if:
              - condition: state
                entity_id: binary_sensor.tuya_mmwave_office_occupancy
                state: "off"
            then:
              - service: light.turn_off
                data: {}
                target:
                  entity_id: light.tuya_rgb_bulb_office_light
mode: restart

So given this trigger:

  - platform: state
    entity_id:
      - binary_sensor.tuya_mmwave_office_occupancy
    to: "off"
    id: occupancy

Why is there no trace of the automation running in the logbook ?

Could we see the whole of the Office - Motion Lights Off v2 automation, please.

What does the trace from the automation show?

There is no automation run…so no trace thats the point.
As far as I understood, as long as the automation isn’t stopped by a condition, there should be a footprint of it running.

@templeton_nash - The whole of it is posted above the trigger part in my original post.

Traces and logbook entries are different things. If there’s no trace for when motion stopped, then what does the trace for the previous run show?

Unfortunately my trace history doesn’t go back far enough so I can’t see what happened.

To explain… the automation runs regularly because of the illuminance trigger, but rarely actions anything because the illumnance hasnt changed enough for the light to turn off.

So the trace history of (5 previous?) runs gets quickly overwritten.

Are there any errors reported in the Log (not Logbook) that are related to this automation?

In addition, look at the value of this automation’s current attribute (in Developer Tools > States). Is it zero?

No errors relating to the automation in the log, and current is 0, so its not the ‘stuck’ issue as far as I can tell.
Its a shame you can’t keep traces for a specified period, rather than just the last handful.

You can increase/decrease the number of stored traces on a per automation basis using the stored_traces option.

OK, good to hear that’s not the problem in this case.

Are there any issues if I put that up to something ridiculous like 1000 ?

if I can catch it again, I’d like to see if I can find the offending trace.

Never had a need to try it so I can’t provide you with an authoritative answer. At best it’ll just consume more disk space, at worst the UI will struggle with stepping through so many traces. :man_shrugging:t3:

So typically, I get home to test the automation and I cant get it to fail. I’ll post back here if anything meaningful comes out of the next few days.