I have setup an automation in node-red and schedule it to trigger at certain time. Sometimes I want to trigger that flow from HA lovelace ui, what is the best way to do this?
Thanks.
I have setup an automation in node-red and schedule it to trigger at certain time. Sometimes I want to trigger that flow from HA lovelace ui, what is the best way to do this?
Thanks.
You can use a button in lovelace to fire an event when pressed and listen for that in NR.
If you have the NR custom integration installed you can call the nodered.trigger
service call from a button in lovelace.
I can’t get my head around this… Would you be so kind to provide an exemple (including the lovelace side) ? Thanks
type: button
tap_action:
action: call-service
service: nodered.trigger
service_data:
entity_id: switch.lovelace_button
name: Lovelace Button
entity: switch.lovelace_button
type: button
tap_action:
action: call-service
service: nodered.trigger
service_data:
entity_id: switch.lovelace_button
payload: hello
name: Lovelace Button
entity: switch.lovelace_button
type: button
tap_action:
action: call-service
service: nodered.trigger
service_data:
entity_id: switch.lovelace_button
payload:
test: 123
abc: xyz
name: Lovelace Button
entity: switch.lovelace_button
[{"id":"123ae7c0.58ab28","type":"ha-entity","z":"70481014.55bbc","name":"","server":"9c202bd8.b64db8","version":1,"debugenabled":false,"outputs":2,"entityType":"switch","config":[{"property":"name","value":"Lovelace Button"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":212,"y":672,"wires":[["e69a1437.7ee568"],[]]},{"id":"e69a1437.7ee568","type":"debug","z":"70481014.55bbc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":390,"y":672,"wires":[]}]
Great, thank you.
Thank you for this!!!
If I understand correctly, this will work for entities created in NodeRed.
However, for entities not created in nodered, I would have to use the “events: all” node filter there with “call_service” and use a switch node to get only nodered.trigger events. Correct?
Something like this?
[{"id":"28cfe7b2.4e3df8","type":"server-events","z":"c07c0ac5.ca6f98","name":"","server":"d28c9492.f419c8","event_type":"call_service","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"x":460,"y":2400,"wires":[["97e96963.963288"]]},{"id":"97e96963.963288","type":"switch","z":"c07c0ac5.ca6f98","name":"","property":"payload.event.domain","propertyType":"msg","rules":[{"t":"eq","v":"nodered","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":630,"y":2400,"wires":[["5bf6c26f.06834c"]]},{"id":"5bf6c26f.06834c","type":"debug","z":"c07c0ac5.ca6f98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":770,"y":2400,"wires":[]},{"id":"d28c9492.f419c8","type":"server","name":"hassio","legacy":false,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
At the moment, I am using this method https://bonani.tech/how-to-trigger-a-node-red-flow-from-the-home-assistant-ui-new-version/ with the empty script “trick”…
I was wondering if have the option to filter from within the “events: all” node itself (eg by being able to select in the node which service and payload should be considered) would be more efficient? Saving a switch node at least
Thanks for the link, at the end of the above link, it says “Exposing to voice assistants”. If we don’t have HA cloud, what method do we use to expose it the voice assistant like Alexa?
I dunno… I don’t have these voice stuff at my place.
I still can’t find the service “nodered.trigger”
I’ve restart and updated node-red and hass a bunch of times. Even created a few entity nodes as switches (restart, etc, etc).
What am I missing?
@dmauro There is a Node-red Integration for HA with additional HA nodes available in the HACS as @Kermit is alluding to above NR custom integration.
Adding this integration should also give you access to the call service i.e nodered.trigger
Got it, thank you! It was confusing to install “Node-RED” (which is the Companion Component installed from HACS) as apposed to the Node-RED"Add-On"
Once I installed the HACS Node-RED I found a new entry under integrations for “Node-RED”. From there my nodered.trigger service magically showed up!
You can also trigger a node-red sequence from a lovelace card via svc2evnt custom component. I made a guide in swedish here: https://frosenlind.se/hemautomation/trigga-node-red-flode-direkt-fran-home-assistant/ maybe google translates it well, if not ask and I will make a post in English.
The component can be found here and just allows you to trigger event from a button. Then you just listen for the event in nr.
HI, I am not able to make it work… node-red integration has no entity and no service “nodered.trigger”…
I should miss something. Any idea ? Thx
You have to create one by using the entity node.
So easy… thx a lot
I have nodred integration installed and there are some entities showing up. Could you post some concrete examples on how to use nodered.trigger service? I am not sure what ‘data’ needed.
Once the entity node is deployed, it creates an entity in HA. Then for example I would use switch.turn_on
for switch.laura_hand_free
. I don’t use nodered.trigger
.
Buttons to trigger rednode flows are working well. Thanks for the tip and thanks to the author of the addon.
My question is the following… the buttons created in lovelace have not state, they are just triggers (maybe I am wrong…)…
- type: button
tap_action:
action: call-service
service: nodered.trigger
service_data:
entity_id: switch.nodered_easee_power
payload:
power: 6
state: resume
entity: switch.nodered_easee_power
show_name: true
show_icon: false
show_state: true
and I have a couple of these to select the power of my charger…
…is it possible to change the color of the button last pressed ?
Thx for your help.
No problem. It would be considered a momentary switch. You maybe able to make a template sensor or some type of custom lovelace card to show last button pressed.
Hey guys,
I’ve created a switch using the entity node, but no entity gets created. I also cant see anything in the logs.
What do you think I’m missing? This should just work on its own with nothing else added (ie, if you have the node, you have everything you should need?)