How to make a push button

Tags: #<Tag:0x00007f73ae0a6008> #<Tag:0x00007f73ae0a5d88>

How can I define a push button, a momentary switch that gets back to off state after X seconds?

I have an Arduino integration that works and looks like this (in configuration.yaml):

  - platform: arduino
        name: auto_gate

The only issue I have is that I’d need this switch to get back to off state after 2-3 seconds.

I found some posts related to this and I’ve tried adding a momentary attribute to PIN 2, but it’s not a recognized attribute.

I am a noob. Can you please explain step by step what and where to add.

I’m using hassio, default UI and I’m editing files through web File editor add-on.

Thank you

So, I assume that this can only be achieved through actions, scripts or some plugin.

Would this feature make sense to be added to the Home Assistant core?

Essentially, your arduino code needs to to that.

Arduino only has FirmataStandard, as advised in the integration docs.

From my understanding this is doable via automations, right?

I might look at the core code, this is why I am asking if it makes sense to have push buttons in the core with a configurable delay of X seconds before reverting back to off state.

Below is what I use for a momentary push button:

 - id: '1551029125083'
   alias: South Shop Door
     - event_data: {}                                      
       event_type: ''
       platform: event                                  
   condition: []                                        
   - data:                                                 
        entity_id: switch.ch1                             
    service: switch.turn_on                           
   - delay:
        milliseconds: 500                               
   - data:
       entity_id: switch.ch1
    service: switch.turn_off

Not sure in which file and under which yaml node to put that.

All I have now as added config is:

  - platform: arduino
        name: auto_gate

in configuration.yaml.

Which file to edit in the web File editor?


I think your best bet would to be bring your push button into home assistant as a binary_sensor. Then you can use that as a trigger for an automation to turn on an input_boolean for however long you require and then turn it off again.

1 Like

You can either put in automations.yaml or create an automation through the web editor.

1 Like

Take a look here: Simple push button in dashboard?

Seems possible to add a momentary parameter to a switch.
Not tested by me, only read fast :slight_smile: