Can I press an button entity from an automation?

I’ve created a button called “Test button” and it appears just fine in the Overview. When I click on the name and settings tab, it says the entity id is input_button.test_button. All good so far, and now I’d like an automation to press it. I created an automation and created a “Call service” action with the service set to “Button: Press”. I then have to type input_button.test_button into the target, as nothing comes up for the “Choose entity”. It looks OK in the as the “Test button” entity appears with the correct icon.

When I trigger the automation, nothing happens and this appears in the home_assistant.log file:

2022-04-21 10:38:56 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities input_button.test_button

Am I doing something wrong?

The YAML view of the action looks like this:

service: button.press
data: {}
target:
  entity_id: input_button.test_button

There are seperate services for Input button helpers and Button entities generated by other integrations. You need to use input_button.press

service: input_button.press
data: {}
target:
  entity_id: input_button.test_button
2 Likes

Oh, I missed that when I saw the Button sevice. Thanks, it’s working nicely.

Not sure if we’re talking about different buttons but I found I needed to use this code

      - service: button.press
        target:
          entity_id: button.amazon_fire_load_start_url

to ‘press’ the button from an automation. (This is for a fully kiosk tablet integration.)

Anyway just hope this might help someone in the future.

3 Likes

it helped me thank you :pray:

1 Like

For some reason, this is not working for me.

Automation:

  - alias: Weerstand dimmer pingen
    trigger:
      - platform: time_pattern
        minutes: "/15"
    action:
      - service: button.press
        data: {}
        target:
          entity_id: button.flush_dimmer_0_10v_boilerweerstand_ping

My Zwave dimmer goes offline regularly. When I go to integrations, zwave, find the dimmer, and I click the available button, the dimmer comes back online within seconds. So pressing this button does have a result.

Also, when I make this button available in my dashboard, this is working.

But when I do this in the automation, nothing happens.
What am I doing wrong?

Edit:
When this is working I will use this as a trigger (to avoid unneeded button-presses):

      - platform: state
        entity_id: light.flush_dimmer_0_10v_boilerweerstand
        to: "unavailable"
        for:
          minutes: 2