Can either turn switch on or off in automation, not both, and new error in configuration

Two related issues, created automation to turn Tasmota flashed sonoff basic (i can control OK via UI), but can only get it to turn on or off - extract from automation.yaml below

##Automation Test_door_2 open   
  - alias: 'test door 2 to Tas plug 1 off'
    hide_entity: true
    trigger:
    - platform: state
      entity_id: binary_sensor.Test_door_2
      to: 'off'
    action:
    - service: switch.turn_off
      entity_id: switch.Tas_plug_1

    ##Automation Test_door_2 closed   
  - alias: 'test door 2 to Tas plug 1 on'
    hide_entity: true
    trigger:
    - platform: state
      entity_id: binary_sensor.Test_door_2
      to: 'on'
    action:
    - action:
    - service: switch.turn_on
      entity_id: switch.Tas_plug_1

Also, started to get this error on config check “Invalid config for [automation]: [action] is an invalid option for [automation]. Check: automation->action->0->action. (See /config/configuration.yaml, line 26). Please check the docs at https://home-assistant.io/integrations/automation/”

It’s moaning about the automation line.


group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

Any ideas welcomed! Thanks.

The first automation is ok.
Why not the second?

    action:
    - action: # remove this line
    - service: switch.turn_on
      entity_id: switch.Tas_plug_1

EDIT: Look at your entities. They should all be lower case.
Copy them from Dev Tools/states.

1 Like

I feel like a right muppet! I was looking at that for an hour and didn’t spot it, thanks very much.

Welcome to the club!
Everyone off us had that experience.

1 Like

Also, action is not a valid step in the action part:

    action:
    - action:  <== THIS SHOULD NOT BE HERE
    - service: switch.turn_on
      entity_id: switch.Tas_plug_1
1 Like