Automation dont trigger

I have a simple sensor trigger a light turn on and wait for Clear from the sensor (from any state) and then wait 30 seconds and then turn the light of, it works almost al the time,BUT sometimes it reports sensor Clear on logbook but nothing more happens? the turn off almost never work when I go to bed for some reason??
Battery of sensor is 78%

Latest HA with all upgrades, Rpi 4 on SSD.
Light is a HUE 850Lumen color using ZHA.
Sensor is Aqara Motion Sensor P1 also ZHA.
No groups used
2 dependencies but they all work fine, they ar for turning the light on.
Time window and LUX treshoold.

its about 4 meters from the Skyconnect stick one floor up in a wooden house.

Also moved from a RPi 3 to a Rpi 4 and an SSD, still same behavior.

It has failed on other times and same in logbook, it says sensor cleared but nothing more.
In my opinion it should say failed to trigger HUExx to turn of using xx. ?

Where do I start?
I saw someone recommend changing battery. but 3V and 78% should be ok.

Ok I mixed up the problems that I have with this automation, thers two probbems

  1. it dont turn off the light (this question im typing about now)
  2. dont turn on but ill work on that later.

I posted a “better” answer below.

Could you please format your automation correctly for the forum.

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

Soo in Trace timeline I dont get a name for the light to turn off ,its just ended.
The sensor never reports Cleared?
The runtime is 3 hours…

But if I check the loggbook its says that the sensor reports Cleared but it dont show up in Trace Timeline?


Triggered by the state of binary_sensor.lumi_lumi_motion_ac02_motion at 27 December 2023 at 03:02:08
Test Test if 2 conditions matches
Turn on <unknown entity>
(light.signify_netherlands_b_v_ltw001_light) turned on
Wait for 1 trigger
3 hours later
Turn off <unknown entity>
Finished at 27 December 2023 at 06:16:34 (runtime: 11666.03 seconds)

Logbook

Sensor hall uppe Motion cleared (no motion detected)
03:07:01 - 5 hours ago

It’s impossible to help without seeing the (correctly formatted) automation and full trace.

Full trace

The automation.

alias: Tändahalluppedimmad
description: Tänder hallampan uppe
trigger:
  - platform: state
    entity_id:
      - binary_sensor.lumi_lumi_motion_ac02_motion
    to: "on"
    from: "off"
condition:
  - condition: and
    conditions:
      - condition: time
        after: "23:00:00"
        before: "07:00:00"
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
          - sat
          - sun
      - type: is_illuminance
        condition: device
        device_id: 3c4196d2872e94d34e5e5579d2519535
        entity_id: 7941b612e0415d5bc8e390bcb73af969
        domain: sensor
        below: 55
action:
  - type: turn_on
    device_id: 5a05ba843b88a1cd7d5604e06656045b
    entity_id: eb08f13a9d712e80c5a184fc3a961e25
    domain: light
    brightness_pct: 50
  - wait_for_trigger:
      - platform: state
        entity_id:
          - binary_sensor.sensorhalluppe_motion
        from: null
        to: "off"
        for:
          hours: 0
          minutes: 0
          seconds: 30
  - type: turn_off
    device_id: 5a05ba843b88a1cd7d5604e06656045b
    entity_id: eb08f13a9d712e80c5a184fc3a961e25
    domain: light
mode: single

Is something wrong? this isnt ezy understanding how to even ask a question?
Also for clarification I dont do anything in yaml since I dont know how to, just visual editor.

Start by NOT using device actions, and instead stick to state and numeric state. Because the fact that the trace timeline says it turned off something unknown, suggests that one of those devices may not exist anymore - perhaps it was factory reset and re-added or something. In any case device_id doesn’t help anyone when it comes to debugging because we have no idea what the device is.

Tnx for respons, Device should work, its there…
turned off something unknown is alos in my other automations and they rarley fail, perhaps one in hundred, the problem Is that that the automation dont continue even if the sensor reports motion cleared.

Also its a single mode action so it hangs and whont let the light turn on again since it is stuk in the last run, maybee changing mode might help…
Ill test some other mode else Ill redo it all over again.

Definitely something wrong there then, there is nothing in that automation that should prevent the automation from running again. It waits for 30 seconds. Whether it errors and stops running, or completes its run is irrelevant, nothing should stop it running again after 30 seconds.

ahh i think i am having the same problem with automations that has a timer set within the condition. I just posted about it. I am on core 2024.1

Since I have the same automation on the stars lights I made this one the same isch, that meaning I added a group for the lights and then it didnt hang like it did before, strange but its considered fixed for me, if thers something in the update to ZHA or the Core I dont, atleast its working now, also imported the :bulb: Sensor Light Version: 5.9 Blueprint and gona play with that next week, tnx all.