Reset switch after automation

I have an automation rule that fires if a switch is triggered. The only problem is that the switch does not return to it’s initial (off) position. Is there any way through which I can set the state of a switch through automation?

switch:
  platform: rfxtrx
  automatic_add: True
  devices:
    0b11000000eac7220c010f80:
      name: Deurbel

As automation rule I use

  - alias: 'Deurbel notify'
    trigger:
    - platform: state
      entity_id: switch.deurbel
      to: 'on'
    action:
      service: notify.pushbullet
      data_template:
        title: "Deurbel"
        message: "Er staat iemand voor de deur"

Toggle the switch as one of your last actions. I have an automation where I do this if you want an example.

- alias: 'Washer Done'
  trigger:
    platform: state
    entity_id: sensor.washer_pwrdn
    from: 'False'
    to: 'True'
    for:
      minutes: 3
  condition:
      condition: state
      entity_id: input_boolean.washer_switch
      state: 'on'
  action:
    - service: notify.pushbullet
      data:
        message: 'Robert, the washer is done.'
    - service: input_boolean.turn_off
      entity_id: input_boolean.washer_switch
2 Likes

In the end I managed it through creating a script and calling that through automation. For people who want to achieve the same:

automation:
    action:
      service: script.turn_on
      entity_id: script.deurbel_notify_reset

And the script:

Script:
  deurbel_notify_reset:
    sequence:
      - service: notify.pushbullet
        data:
          title: "Deurbel"
          message: "Er staat iemand voor de deur"
      - service: homeassistant.turn_off
        data:
          entity_id: switch.deurbel
1 Like