Google calendar activated switch (syntax newbe)

When I test my switch it works and I can flick the trigger to test it in the gui and my tp link light switches off, but the google calendar trigger in my automation is not working, if i look in the 'History on home assistant I can see tte state of my calendar changing from off to on and back again. i have set it to toggle every half an hour.
My ultimate goal is to have a light in a meeting room that indicates if it is booked or not. please be kind this is my first automation. where have I gone wrong?

  • action:
    • service: switch.turn_off
      alias: TP-LINK-4
      condition: []
      id: ‘15******************3’
      trigger:
    • entity_id: calendar.g**************com
      state: ‘off’
      platform: state

thanks in advance

Your trigger needs to have a “to” instead of “state”. Here’s an example:

trigger:
  platform: state  
  entity_id: calendar.g*************com
  to: 'off'
  from: 'on'
action:
  service: switch.turn_off
  entity_id: __________

Here is documentation on the state trigger:

Thank you, I will try it now :slight_smile:

It worked, thank you again.