Press "Enter" to skip to content

Momentary switch in Home Assistant

bist 0

I had a really hard time to create a momentary switch in HA. Installed HACS and added custom stuff all over the place. Sometimes it’s just that simple.

My use case was creating a button for my garage door opener which only requires a momentary press of a button. I use velbus with a simple relay. It turned out that the only thing you need to do if configure a normal button in lovelace that controls the entity with the relay of the garage door opener. If you stop here this would TOGGLE the switch. And this is of course not what we needed.

type: button
  action: toggle
entity: switch.pool_pump

Example of a button. You can just do this visually in lovelace

It turns out you only need to create a simple automation. This can be used to turn any button into a momentary switch.

  alias: Momentary  switch
  description: 'Turn any switch into a momentary switch'
  - platform: state
    entity_id: switch.pool_pump , add any other switch
    from: 'off'
    to: 'on'
    for: '00:00:00.5'
  condition: []
  - service: switch.turn_off
    data: {}
    entity_id: switch.pool_pump, add any other switch
  mode: single

Yes it’s that simple

Leave a Reply

Your email address will not be published. Required fields are marked *