Google Calendar activate switch with automation doesn't work

Hi all,

I can’t figure it out, I’m trying to get an automation that will switch on and off a smart plug (Zigbee) based on an event in Google Calendar. I have run this integration already.
This is what I have so far:

- id: '1695978832657'
  alias: Opladen mover accu
  description: ''
  trigger:
  - platform: calendar
    event: start
    offset: -0:05:0
    entity_id: calendar.homeassistant_event_calendar
  - platform: calendar
    event: end
    offset: 0:05:0
    entity_id: calendar.homeassistant_event_calendar
  condition: []
  action:
  - service: switch.toggle
    data: {}
    target:
      device_id: switch.stekker_oplader_mover_accu_switch
  mode: single

I have looked the internet and this community but no luck.

Who can help me out, whats missing?

Thanks
Bas

Change this option:

device_id:

to this:

entity_id:

You may wish to consider using this version that explicitly turns on the switch when the calendar event starts and turns it off when the calendar event ends.

- id: '1695978832657'
  alias: Opladen mover accu
  description: ''
  trigger:
  - id: 'on'
    platform: calendar
    event: start
    offset: -0:05:0
    entity_id: calendar.homeassistant_event_calendar
  - id: 'off'
    platform: calendar
    event: end
    offset: 0:05:0
    entity_id: calendar.homeassistant_event_calendar
  condition: []
  action:
  - service: 'switch.turn_{{ trigger.id }}'
    data: {}
    target:
      entity_id: switch.stekker_oplader_mover_accu_switch
  mode: single

@123
YES!
Thank you very much. This is the solution I was looking for!

1 Like