automation:
trigger:
platform: state
entity_id: switch.sonoffxxxxxxxx
# Optional
from: "off"
# Optional
to: "on"
for: "00:00:02"
action:
# With a single service call, we don't need a '-' before service - though you can if you want to
service: switch.turn_off
entity_id: switch.xxxxxxxxxxxxxx