Node-RED nodes for hubitat

I know I'm jumping back in this thread really late...but I saw over 2000 unread posts and got really curious over all the activity. WOW..this thread has been busy..lol.

Saw this and was curious as to why this data is coming in as a global variable in the first place. Are you using the HA nodes to bring in your entities? The most popular one is
node-red-contrib-home-assistant-websocket.
I stopped using NR recently so assisting further might prove tricky but thought the info might be helpful. These nodes were designed to bring data from HA into NR.

1 Like

Yes, I'm using: node-red-contrib-home-assistant-websocket

It seems to bring all the states into Node Red as global variables. I didnt particurly select that option, it just happened. I've got it figured out now. In the end, I skipped the global variable part, and just used a device state node. Although I did figure out how to access the global variable...see above.

3 Likes

I'm gonna apologize right now as I am a n00b with Hubitat HE (C-7), I've been reading this thread for a few hours now and Node-Red seems to be the "I'm not a programmer but I can visualize how I want things to work" kinda guy, so this looks right up my ally.

The one real issues I have is I'm confused as to where the "node-red" code lives with respect to using it with HE. I'm betting that it live out on a Raspberry Pi (what Pi4?) out on my home network and just interfaces with the HE rather than actual code running on the HE itself. If this is the case, please let me know as I would have no issue getting an rPi4 and setting up Node-Red on it (I'm n00b at rPi too - I'm a glutton for punishment).

I see using Node-Red as the visual programming that would really help me get my smart home working the way I would like it. I have had Smarthings but never really dove into it too much. I started trying to get more zigbee and zwave devices for reporting window and door status, temperature/humidity/motion/light sensors as well for monitoring room conditions with the hopes of controlling exhaust fans in bathrooms when someone is showering and forgets to turn on the fan (my oldest son), I'm working on getting a rPi zero to monitor a bluetooth tag to tell me if my cat is in the garage "chilling out from foster kittens" (semi successful - monitors tag, just not reporting to my phone). I have been using wifi color lights and apps, smartthings, or Alexa to do some automations. I have a few good routines on Alexa and I'm happy with their "Routines" programming setup such as it is. I got the HE to do more and working on it.

So to do this Node-Red do I need to get an rPi4 to get things going and is there a step-by-step on how to get the Node-Red set up?

Thanks in advance.

NorbertD

Correct. But it doesn't have to be a RPi. It can be any platform that supports Node.js - including a Mac, a Windows PC, a Synology NAS, or any single-board computer that runs a Linux distribution.

To get an RPi setup, I'd look here, and you'll find instructions on setting up Node-RED here.

The first post in this thread has detailed instructions on setting up Hubitat nodes for node-red (node-red-contrib-hubitat) .

3 Likes

Thank you! I probably would prefer a rPi4 as I don’t want to dedicate a whole computer for this as it would be running all the time and going with a rPi gives me more experience with the rPi.

Now to raid Amazon! Lol

1 Like

When you get that RPi, @csteele has made an image for RPis with everything needed to get node-red running.

Described here:

3 Likes

A rPi is a good place to start and determine that it is the tool for you. But there are other NodeJS products that you may eventually want as well. My home has Node-Red, HubConnect Proxy Server and several instances of Homebridge. All are NodeJS programs and they all run on a single always-on computer.. a Mac Mini that was once 100% a media server and is now 98% media server, 2% NodeJS. :slight_smile:

3 Likes

Anyone understand Do-red?

I am attempting to use the abort node, but it doesnt abort. Is it supposed to abort the whole flow, or just the branch where the abort is.

In the following flow, I'd expect the abort to stop the flow after the second branch, but all three debug nodes have outputs when the flow is run.

Edit: so I realised that it skips all remaining tasks and passes the message on to the output, which in my situation, is the 3rd node. I get it now. Is there a way to actually abort the flow?

[{"id":"a5ace7a9.f00058","type":"inject","z":"8c249630.076968","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":920,"wires":[["9bab0d97.8b1d"]]},{"id":"9bab0d97.8b1d","type":"do","z":"8c249630.076968","name":"","tasks":["Task 1","Task 2"],"outputs":3,"x":420,"y":920,"wires":[["fb0ec318.7274","c6405e03.c3f37"],["9f2e2d14.99f0f","ee3c6b3c.4507f8"],["ed327738.52e0f8"]]},{"id":"c6405e03.c3f37","type":"do-return","z":"8c249630.076968","name":"","mode":"done","x":630,"y":900,"wires":[]},{"id":"fb0ec318.7274","type":"debug","z":"8c249630.076968","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":860,"wires":[]},{"id":"ee3c6b3c.4507f8","type":"do-return","z":"8c249630.076968","name":"","mode":"abort","x":630,"y":980,"wires":[]},{"id":"9f2e2d14.99f0f","type":"debug","z":"8c249630.076968","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":940,"wires":[]},{"id":"ed327738.52e0f8","type":"debug","z":"8c249630.076968","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":1020,"wires":[]}]

I think that's because when the "abort" action happens, it goes to the "done" (last) output.
If you have a task after the "abort" task, you would see it skipping that and going to the "done" output.

1 Like

You probably have to handle that in the "output" node like this:

[{"id":"a5ace7a9.f00058","type":"inject","z":"9c025ca7.62a12","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":219,"y":4689,"wires":[["9bab0d97.8b1d"]]},{"id":"9bab0d97.8b1d","type":"do","z":"9c025ca7.62a12","name":"","tasks":["Task 1","Task 2","Task 3"],"outputs":4,"x":429,"y":4689,"wires":[["fb0ec318.7274","c6405e03.c3f37"],["9f2e2d14.99f0f","f7388487.6ba0c"],["ed327738.52e0f8"],["f685a2e0.91cb9"]]},{"id":"c6405e03.c3f37","type":"do-return","z":"9c025ca7.62a12","name":"","mode":"done","x":639,"y":4669,"wires":[]},{"id":"fb0ec318.7274","type":"debug","z":"9c025ca7.62a12","name":"Task1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":629,"y":4629,"wires":[]},{"id":"ee3c6b3c.4507f8","type":"do-return","z":"9c025ca7.62a12","name":"","mode":"abort","x":832,"y":4710,"wires":[]},{"id":"9f2e2d14.99f0f","type":"debug","z":"9c025ca7.62a12","name":"Task2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":633,"y":4749,"wires":[]},{"id":"ed327738.52e0f8","type":"debug","z":"9c025ca7.62a12","name":"Task3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":629,"y":4789,"wires":[]},{"id":"f7388487.6ba0c","type":"change","z":"9c025ca7.62a12","name":"Abort?","rules":[{"t":"set","p":"abort","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":677.3333740234375,"y":4708,"wires":[["ee3c6b3c.4507f8"]]},{"id":"f685a2e0.91cb9","type":"switch","z":"9c025ca7.62a12","name":"Abort Flow","property":"abort","propertyType":"msg","rules":[{"t":"true"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":648.3333435058594,"y":4871.33349609375,"wires":[["c94c678b.604c4"],["d29f3a0a.56387"]]},{"id":"c94c678b.604c4","type":"debug","z":"9c025ca7.62a12","name":"Stop","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":849.3333435058594,"y":4825.000038146973,"wires":[]},{"id":"d29f3a0a.56387","type":"debug","z":"9c025ca7.62a12","name":"Carry On","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":853.3333740234375,"y":4900,"wires":[]}]
2 Likes

Thanks. That little msg.abort is a winner. How did you find that?

1 Like

I just created a msg. attribute in the change node before abort. I could have called it anything and checked that in the switch node at the end as it is not a standard attribute.

Now I feel dumb, cause I didnt see that change node. I thought it was built into the Do-Red logic. Clever.

1 Like

So I have this object:


and I want an array of just the payload.songs,id parts.

{["music_86808","music_91627"]}

Any suggestions on nodes to use?

Easiest would probably just use a function node and do a foreach to cycle through the songs array..

1 Like

Or maybe the template node...

see "mustache templates"..

1 Like

Also consider the split and join nodes. They work really well for this purpose.

For example I can take a list like this:

And process it into something like this, which is convenient to send as an SMS:

1 Like

I love that there are so many ways to handle stuff in NR. Really shows the flexibility and power...

1 Like

Yup.

That output is actually from a set of sequences that are super-useful to me. I use the Alexa app to add things to various shopping lists (eg. Grocery, Pharmacy, Costco). When OwnTracks detects that I am in the vicinity (100 ft) of the appropriate place, I use alexa2-remote (or cakebaked now) to retrieve the correct list, process it, and send it as an SMS to myself. Which shows up on my watch ...

Helps protect me from my own absent-mindedness!

3 Likes

That is so cool - I have had a love hate relationship with OwnTracks on Android. Hard to figure out which mode to be in. Right now just using Unifi node to detect when our phones are connected to our WiFi. With MAC protection set off for each of our phones of course.

1 Like