A Node-Red Introduction for Hubitat Owners

I would love to know how to use node-red but I can't find a really good source to teach me.

Many videos on YouTube. I watched a series of videos by Opto Video when I first got started. Here is his series:

2 Likes

The video linked by @ritchierich is a great intro as are the other videos in the series.

One thing I would recommend is try not to overthink things with NR... it only looks complicated. It's really just a simple message passing system with only one type object called "message" (msg).

The visual way you build "rules" (sequences) by connecting nodes and wires is very logical and super easy to construct and troubleshoot..

If you initially stick with the HE & NR system nodes you can do a lot of cool stuff. Once you gain experience and confidence you can start to branch out into other things...

I am a big fan but ymmv.

2 Likes

The following is part of a re-post from a PM..

This example shows an HE Device node representing a Smart Things button and a smart bulb paired to my system.

  1. When the physical button is pushed this node (the first one on the left) generates a msg object that has the HE event stored as a JSON object in the msg's payload property. The msg is then passed to the next node.
  2. The next node is another HE device node that has events turned off. It gets "activated" by receiving the message from the prior node. It overwrites the existing msg object replacing it with a msg object containing the specified device's switch status.. and passes the msg along.
  3. The next node, the "switch" node, is an if/then/else construct - here it is checking the incoming msg object property "msg.payload.value" for "on" or "off" values. IF the value is "off" then branch to the top node to turn the table bulb "on", if it is "on" then branch to the bottom node to turn the table bulb "off".
  4. The HE command nodes simply sends a command back to HE to trigger an action. In this case "on" or "off". Since the nodes are preconfigured for "on" or "off" the incoming message data is not needed.

For giggles here is the "switch" node property page for the above example.. you can add as many conditions as you want...

Note: the "Name" property is just a label that appears in the node on the page.. I got a little fancy in order to be a bit more descriptive - the "\n" is a line break.

2 Likes

Thanks for the link to the videos. I will definitely go watch them. Probably more than once.

1 Like

I may be able to do this after all. I try to do things using logic so this might be right up my alley. Thanks for the examples, steps and pics.

1 Like

Well you are way ahead of me then.. at least according to my wife!

:wink:

I think our wives have the same idea. :grinning: Thanks again.

1 Like

@erktrek @ritchierich Well I finally got Node-RED to load on my computer. Now all I need to figure out, not sure of the terminology, is to get the hubitat library brought in so I can access the devices on hubitat. Is there a link to a procedure for this? Thanks

You first need to load the Hubitat nodes. You can do this within Node-RED using the following steps:

  1. Go to the Hamburger menu on the top right
  2. Click on Manage Palette
  3. Click on the Install tab
  4. Type "hubitat" in the search bar titled "search modules"
  5. Click on the Install button

After installing the Hubitat nodes, next you will have to configure these nodes. To do so, follow the detailed instructions in this post:

3 Likes

:+1: on @aaiyar...

Report back if you have trouble or if you need further guidance!

:crossed_fingers:

2 Likes

@aaiyar @erktrek Thank you guys. I will give this a try later today. Hopefully I can get most figured out but thanks for offering to help. Will report back.

2 Likes

is there a way to send mqtt event to hubitat using node red

Hubitat doesn't have an MQTT broker. But there are several MQTT clients. So if you configure Node-RED to send data for a particular topic to an MQTT broker, you can use an MQTT client on Hubitat to subscribe to that particular topic at that MQTT broker.

1 Like

ok that i will try that

What are you trying to interface from NR? There might be a simpler possibly lower resource utilization solution depending on what you need. For example to expose devices from Home Assistant you can use the Hubitat Addon in HACs. If using a thermostat or other device you could write sync sequence to a related HE virtual device using the HE Nodes..

I am trying to subscribe to mqtt topic and publish to hubitat

Just use the hubitat nodes. Catch the mqtt message in node red, parse the message as needed to get the value, and then write it down via the hubitat node red nodes to a hubitat virtual device.

I've done that for dozens of devices.

2 Likes

I was asking what particular services are you using to populate MQTT.. My point is there might be an easier way depending upon what services you are using..

I have been playing around with Zigbee2MQTT for example and use Node-RED to sync HE and Z2M as needed. This puts any additional overhead on my NR server NOT the HE hub which is nice.

edit: using the Mosquitto Broker.

2 Likes

This is the way .... you don't need an MQTT client in Hubitat. In this example, Ecowitt is a virtual Hubitat device.

1 Like