Why does automation not get triggered

Hello, I have created an automation that should turn on the light if the shutters closes and the Game PC is on.
When I manually start the automation the light turns on when the requirements meets.
However the automation itself does not work when the Game PC is on and the shutters state changes from open to close.

Here is the Yaml code

alias: "Light: Office spotlight - turn on when shutter closes and Game PC is on"
description: ""
triggers:
  - trigger: state
    entity_id:
      - cover.shutter_office
    from: open
    to: closed
conditions:
  - condition: state
    state: "on"
    entity_id: switch.stef_pc
actions:
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: light.office_spotlight
mode: single

The related logbook entries only shows the manual trigger I did yesterday but nothing else:

February 17, 2025

office.spotlight turned on triggered by automation Light: Office spotlight - turn on when shutter closes and Game PC is on triggered

7:27:26 PM - Yesterday

number_of_lights_on changed to 5 triggered by automation Light: Office spotlight - turn on when shutter closes and Game PC is on triggered

7:27:26 PM - Yesterday

Office lights turned on triggered by automation Light: Office spotlight - turn on when shutter closes and Game PC is on triggered

7:27:26 PM - Yesterday

Does it work if you remove the condition?

Does the Logbook show when cover.shutter_office changed state?

Yes the Logbook does show the changed state. although yesterday after I posted this topic I updated the HA OS.
But this morning I closed the shutter and checked the Logbook and it does show.

Shutter Office was closed

8:47:02 AM - 10 seconds ago

Shutter Office is closing triggered by action Cover: Close

I forgot to mention that I also have a similat automation that it should turn on the light when the Game PC is turned on and when the shutters are already in a closed state. And that automation does work.
Here is the Yaml code for that one.

alias: "Light: Office spotlight - turn on when Game PC turned on and shutter is closed"
description: ""
triggers:
  - trigger: state
    entity_id:
      - switch.stef_pc
    to: "on"
conditions:
  - condition: state
    entity_id: cover.shutter_office
    state: closed
actions:
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: light.office_spotlight
mode: single

And I know just see the difference.
Let me try to remove the From state and see if that works.

Edit: That does seem to do the trick !
Ok, so I am happy that the automation is now working, but I also want to know why it didn’t work with that From state set.
Does it not see the begin state of the entity ?

I suspect your cover state goes open » closing » closed (docs), which won’t trigger your original automation.

2 Likes

Ah thank you, that makes sense indeed. :+1: