A Node-Red Introduction for Hubitat Owners

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

Can i get copy of your nood red example
Thanks

Here is a very simple example that dumps my pool pump watts reading into a Hubitat virtual omni sensor device named vOmni999 using the setPower command on the device.

Note that what you need to do in the change block to parse your MQTT message into something usable is MQTT message/message format dependent, and an exercise for you. As is determining what kind of virtual device makes sense for the value you are trying to write down.

The hubitat command node (and all other hubitat nodes in node-red) have very good online documentation in node-red, so if you aren't sure of the input names, look at the node help - they are all described there.

EDIT: In case you are wondering about the DELETEs in the change block, I have screwed myself up multiple times accidentally passing msg.deviceId, msg.arguments, or msg.command values to a Hubitat node unintentionally (typically from upstream logic). So now I just "sanitize" all messages for Hubitat input variables I'm not using before it goes to a Hubitat node.

Exported Flow
[
    {
        "id": "989fc48270b947c3",
        "type": "tab",
        "label": "Hubitat Example",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "332642c6bc91bef2",
        "type": "hubitat command",
        "z": "989fc48270b947c3",
        "deviceLabel": "vOmni999",
        "name": "",
        "server": "919f1e6a880ec538",
        "deviceId": "705",
        "command": "setPower",
        "commandArgs": "",
        "x": 710,
        "y": 120,
        "wires": [
            []
        ]
    },
    {
        "id": "dcbd6070a7df7c8e",
        "type": "change",
        "z": "989fc48270b947c3",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "arguments",
                "pt": "msg",
                "to": "payload.watts",
                "tot": "msg"
            },
            {
                "t": "delete",
                "p": "payload",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "command",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "deviceId",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 520,
        "y": 120,
        "wires": [
            [
                "332642c6bc91bef2"
            ]
        ]
    },
    {
        "id": "2387f834a2336ee3",
        "type": "debug",
        "z": "989fc48270b947c3",
        "name": "debug 5",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload.watts",
        "statusType": "msg",
        "x": 500,
        "y": 180,
        "wires": []
    },
    {
        "id": "45d81daa0917eccf",
        "type": "mqtt in",
        "z": "989fc48270b947c3",
        "name": "",
        "topic": "easytouch2-8/state/pumps/1/intelliflovsf/watts",
        "qos": "2",
        "datatype": "auto-detect",
        "broker": "7f7e5343557e3a8c",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 230,
        "y": 120,
        "wires": [
            [
                "dcbd6070a7df7c8e",
                "2387f834a2336ee3"
            ]
        ]
    },
    {
        "id": "919f1e6a880ec538",
        "type": "hubitat config",
        "name": "162",
        "usetls": false,
        "host": "192.168.2.162",
        "port": "80",
        "appId": "215",
        "nodeRedServer": "http://192.168.2.5:18880",
        "webhookPath": "/hubitat/webhook",
        "autoRefresh": true,
        "useWebsocket": false,
        "colorEnabled": false,
        "color": "#ace043"
    },
    {
        "id": "7f7e5343557e3a8c",
        "type": "mqtt-broker",
        "name": "",
        "broker": "192.168.2.165",
        "port": "1883",
        "clientid": "nrtest",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]
2 Likes

Ok thanks let me give it a try

@erktrek I have managed to bring in the Hubitat Nodes into Node-RED. There are 9 of them but there is no Config node to put in the info from Maker API.