Node-RED nodes for hubitat

The node-red organization standard for naming community developed nodes which are published in npm is to name the packages with a prefix of “node-red-contrib”. By that I just meant nodes which aren’t official. As others have said this is short for contributed, meaning that they aren’t part of the official node palette.

I linked here to the archive.org because at the moment the node-red site (and maybe broader github) is having trouble rendering pages.

3 Likes

You have to weigh the functionality of the node and the most recent updates to it. There are some very useful nodes that can help reduce complexity. Some of the older nodes work just fine as well. I totally get what you are saying. Do not want to get locked in to something that won't be supported in the next upgrade(s). The trouble and strength of NR is based around contributions so not using them limits the possibilities... as with all things, balance and wisdom.. :mage:

4 Likes

And there are other contrib nodes that already do what they need to, so may not have any updates - as they aren't needed. The more single functioned the node, the more likely that's the case.

Kind of like I have some hubitat drivers I haven't updated in over a year as they do what I intended them to, and work fine. Doesn't mean they aren't supported.

4 Likes

I know this isnt a Hubitat Node red question, so forgive me.

I've recently installed Home Assistant, and it's got some pretty nifty integrations. One of which is google tracking, which we already do in our family. It just means we can keep an eye on where everyone is.

The way Home Assistant works with Node Red, is that it brings across all devices as an (??) object array global variable in Node Red. This is just an example, there are dozens and dozens of them, just from automatically finding them in my network. I've not added Hubitat devices into Home Assistant, and am not sure if I will (I'm aware of the integration). Node Red is my logic engine.

This seems a really dumb question, but I cant seem to figure out a way to get just the homeAssistant.states.person.mike.state status. The answer I want is "home", as I want to put it on my Node Red dashboard. I've got other places defined (like my kids school, my wifes work, etc). It would be very handy, rather than just "away".

Is it possible? I'm sure it is, but I'm not sure how to get only part of a global variable??

If you send that information into a debug node, and then hover over the field you want, you are given the option to copy the path or the value for that field. Then you can just paste into a switch node or similar. I am not sure if that answers your question.

2 Likes

The problem was I didnt know how to send it to a debug node, because it was all in the Global Variable section, as an array. The trick was having two homeassistants, as per below.

var x = global.get("homeassistant.homeAssistant.states['person.mike'].state");

1 Like

You can access the data in a function node like this:

msg.payload["homeAssistant"]["states"]["person.mike"]["state"]

OR can use some JSONATA magic.. like this:

edit: the JSONATA probably won't work since "person.mike" is a key... but it is a cool trick anyway.

2 Likes

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