Light automation with Local Calendar

Hi to all!

Objective: Automate a water cooler, based on a local calendar. It should turn on on friday 11 am and turn off on monday 4 am.

note: I don’t want HA to keep checking the "state"of the event every 15 min; but the automation to be triggered when the event status changes from OFF/ON and ON/OFF.

I’ve created a calendar with 1 event (very simple one, Filtro_ON from friday 11am to Monday 4am.).
Used this code, taken from link

automation:
  - alias: Light based on calendar
    trigger:
      - platform: calendar
        event: start
        entity_id: calendar.calendar_filtro_de_cima
      - platform: calendar
        event: end
        entity_id: calendar.calendar_filtro_de_cima
    condition:
      - condition: template
        value_template: "{{ 'Filtro_ON' in trigger.calendar_event.summary }}"
    action:
      - if:
          - "{{ trigger.event == 'start' }}"
        then:
          - service: light.turn_on
            entity_id: light.plug_filtro_de_cima_light
        else:
          - service: light.turn_off
            entity_id: light.plug_filtro_de_cima_light

When trying to save the automationI get:
“Message malformed: extra keys not allowed @ data[‘automation’]”

How can I fix this?

This is not what the Community Guides category is for. Please read the category descriptions. Moved.

I guess

automation:

is in configuration.yaml ?

Change that line to

automation: !include automations.yaml

Create a file automations.yaml and put everything under automation: in that file.