Error in automation - "Message malformed: value should [...] string for dictionary value @ data['actions'][0]['action'] - do not see it!

Hi there,

I am new to HA or better to say to ymal. I did create a automation based on the schedule integration to turn on/off a few xmas lights in and around the house using smart plugs (Zigbee mostly) and such.

I came up w/ the following automation in ymal (used the GUI to get a base setting and went from there). Editing happens inside HA automation via opton ‘Edit in YAML’

alias: Xmas Schedule for Light
description: "x"
triggers:
  - trigger: state
    entity_id:
      - schedule.xmas_lights_inhouse
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 2
  - trigger: state
    entity_id:
      - schedule.xmas_lights_inhouse
    from: "on"
    to: "off"
    for:
      hours: 0
      minutes: 0
      seconds: 2
conditions: []
actions:
  - action:  
    - service: 'switch.turn_{{ trigger.to_state.state }}'
      metadata: {}
      data: {}    
      target:
        entity_id: switch.zigbee_3_0_stecker_ali_002
mode: single

That code produces:

Message malformed: value should be a string for dictionary value @ data['actions'][0]['action']

I seem not fot get my head around, I can’t see the forest for the trees I guess.
Sorry - if it is very obvious to the experienced eye but I am missing it.
Checking the forum did not help me out here.

Thanks for reading that far,
HANT

PS. Syntax check w/. yamllint.com did not find any issues

use only action, not both.

actions:
  - action: 'switch.turn_{{ trigger.to_state.state }}'
    metadata: {}
    data: {}    
    target:
      entity_id: switch.zigbee_3_0_stecker_ali_002

Thank you - that one solved the issue!

Not yet obvious to me, but I am working on it and glad that the lights are now working and can be set up.

Thanks,
HANT