Turn off "virtual" switch after 2 seconds

Hi all!
I’m trying to turn a switch off after I have pressed it. The wait time should be 2 seconds.
What I have created so far is this
How do i turn of the switch after 2 seconds?

wake_on_lan:

switch:

  • platform: wake_on_lan
    mac: (MAC ADDRESS)
    name: GamerPC

First, please see the sticky post about code formatting.

Second, you’ll want an automation

Something very roughly like:

automation:
- alias: "Turn it off"
  trigger:
  - platform: state
    entity_id: switch.gamer_pc
    to: 'on'
    for: '00:00:02'
  action:
  - service: switch.turn_off
    data:
      target: switch.gamer_pc

Hi

Thanks for the help.

I will look into automation and the sticky post