Action is delayed after trigger

Hello All, I have a simple automation that’s supposed to switch on the Garage lights(controlled by TP-Link Kasa Smart switch) when my driveway camera’s(Reolink Duo 2 POE) floodlight turns on between 9PM and 5AM. It is working but the garage lights are turned on after some delay (around 10secs or so after driveway camera’s floodlight turns on) and not instantly. Here’s my YAML, kindly take a look:

Please paste your config directly in your forum post and format it correctly.

alias: garage-lights-on-off
description: ""
  - platform: device
    type: turned_on
    device_id: dcde817ed3d39e5c049c5b19d363d6c9             
    entity_id: ee33c25797485dd1ecc8ff680727b1b2
    domain: light
  - condition: time
    after: "21:00:00"
    before: "05:00:00"
      - sun
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
  - type: turn_on
    device_id: f9d41878711952e0684be93a9ab4957d
    entity_id: 63962977560dabb052691c8badc74eb0
    domain: switch
  - delay:
      hours: 0
      minutes: 2
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: f9d41878711952e0684be93a9ab4957d
    entity_id: 63962977560dabb052691c8badc74eb0
    domain: switch
mode: single

Below is the trace image:

Can you download the full trace and post it here?

can uou try it with a service call instead of

so something like this:

  - service: switch.turn_on
    data: {}
      entity_id: switch.somelight

and while you’re at it, also use state change for the trigger:

  - platform: state
      - light.driverway_camera_floodlight
    to: "on"
1 Like

Sorry for the delay in response. For some reason, “camera motion started detection” is not working. I have changed it to “Person detected on” and/or “Vehicle detected on” and it started working. Thank you for your suggestions. Here’s my config: