Toggle Switch Trigger Automation

You want 'on' and 'off' in lower case, and entity_id is mis-spelled in your trigger code. Here’s how I’d format it, with alias, description and id. The id (just a random string: I use UUID4) allows the automation tracer / debugger to work.

- alias: Garage door momentary on
  description: Turns the garage door switch off as soon as it is turned on
  id: 7a66b9b0-0e44-4687-88b2-8b6e02c7edbd

  trigger:
    - platform: state
      entity_id: switch.garage_door
      from: 'off'
      to: 'on'
      for:
        milliseconds: 200

  action:
    - service: switch.turn_off
      entity_id: switch.garage_door

If the 200ms is critical, you may be disappointed: HA isn’t necessarily that “punctual”.

But do please format your code using the </> button. See point 11 here:

1 Like