Helper button to trigger node in node-red

Hello,

I’ve created a helper button in Lovelace of Home Assistant using the Helpers config UI.
I would like to know how can I use it to trigger a node in node-red if possible.
I managed to do it with Helper Toggles using Events: State node, but I have no lack with momentary buttons… Please help!

Thank you.

System Health

version core-2022.2.3
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.9.7
os_name Linux
os_version 5.10.92-v8
arch aarch64
timezone Europe/Athens
Home Assistant Community Store
GitHub API ok
Github API Calls Remaining 5000
Installed Version 1.22.0
Stage running
Available Repositories 1044
Downloaded Repositories 6
AccuWeather
can_reach_server ok
remaining_requests 13
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 7.3
update_channel stable
supervisor_version supervisor-2022.01.1
docker_version 20.10.9
disk_total 57.8 GB
disk_used 35.3 GB
healthy true
supported true
board rpi4-64
supervisor_api ok
version_api ok
installed_addons File editor (5.3.3), Mosquitto broker (6.0.1), FTP (4.4.1), Node-RED (10.4.0), Grafana (7.4.1), InfluxDB (4.3.0), Check Home Assistant configuration (3.9.0), Duck DNS (1.14.0), Home Assistant Google Drive Backup (0.105.2), Terminal & SSH (9.3.0), MariaDB (2.4.0), Studio Code Server (4.1.0), eWeLink Smart Home (1.2.3)
Lovelace
dashboards 4
resources 0
views 3
mode storage

What do you mean? Are you wanting the button to trigger a flow in NR, or are you wanting the flow to “press” the button?

The button to trigger a flow in NR.

Just put it in an event: state node

3 Likes

I thought I tried that, but now it works. Thank you!

This post was very helpful. Thank you.
I wanted to summarize this process I used with the steps to go from nothing to triggering a node in node-red because there is a lot of confusing information that comes up when searching for this topic on the internet.

Here are the steps I used:
A. Create a Helper Button in Lovelace of Home Assistant using the Helpers config UI.
1. Go to Settings > Devices & Services > Helpers > Create Helper.
2. Choose the Button type Helper and give it a meaningful name. Note the Helper Button Entity ID. Click “Create” to finish creating the Helper Button.
B. Add Helper Button to Your Dashboard
1. Go to your Dashboard. Edit Dashboard. Add Card. Select the Dashboard Button Card type.
2. Set up the Dashboard Button by selecting the Helper Button entity you created above (using your helper button Entity ID) and give the Dashboard Button a name.
3. There are three option switches for the Dashboard Button. Turn on the ones you want. Then click save.
4. Your Dashboard button should now be complete and show up on your Dashboard. Click done to finishing editing your Dashboard.
5. The Helper Button is now linked with your Dashboard Button.
6. The only thing the Dashboard button does is record the time it is clicked. This is its “state”. Each time it is clicked, the “state” changes.
C. Create flow in Node Red
1. The link between the Dashboard Button/Helper Button Entity and your Node-Red flow is the “events: state” node.
2. When the Dashboard Button is clicked, the state of the Helper Button Entity changes to the new/current time of the click, and the Node-Red “events: state” node hears that state change.
3. The first node in the flow is the “events: state” node. The server is “Home Assistant”, the entity is your Helper Button Entity, the msg.payload output property is the information you want the “events: state” node to pass to the next node in your Node Red flow.
4. Once the “events: state” node is set up, it will hear the fact that your Dashboard Button has been clicked and its state changed (i.e., when the Helper Button Entity records the time the Dashboard Button was clicked as the state of the entity).
5. When the “events: state” node “hears” the state change for the Helper Button Entity (when the Dashboard Button is clicked), it sends the payload to the next node in your Node Red flow.
6. You can set the payload (info) that will be passed from the “events: state” node to the next node in your Node Red flow and use that payload to control what happens next in your Node Red flow.

10 Likes

Iwvogan, thank you very much for your summary on how to create a button in Lovelace and link it to Node-RED! It was exactly what I was looking for to create a “Zoom In” button for my Reolink camera. I already had the Node-Red portion set up, and was dreading trying to figure out how to link Lovelace to Node-Red.

Thank you again for posting your succinct but complete summary!

Hello.

I tried to use this Helper button on custom-button card, but I get the error that says ‘failed to call the service input_button/turn_off. service not found.’

This is because it doesn’t have off state in this input_button entity? any solutions?

Thanks.

I have the EXACT same question - and I cannot find an answer to this at all. I assume this is because the custom-button card will require an update to handle the press action for the input_button helper.

Anyone else resolve this using custom-button card?

I just managed to get this working.

tap_action:
  action: call-service
  service: input_button.press
  service_data:
    entity_id: "entity id"
1 Like

Hmm, that doesn’t seem to work for me.

I have a button card inside a “container” and tap action does nothing. It only works when I go into “more info” and then press “press”

Hi,
I’m not able to fire my ‘service node’ based on a button on my LoveLace dashboard.
Creation of the input_button entity and link it to the dashboard wasn’t an issue.
In Node-Red when I press the button I do see a value (the timestamp) under the ‘trigger: state node’. When I press I see a red icon like it’s unavailble but the timestamp changes, each time I press.
Linked the ‘on’ output to ‘call service node’ but this one is never triggered.
Any idea what’s wrong?

Flow with the 2 nodes can be downloade here