Node-RED nodes for hubitat

Thanks. That was very helpful. So the "send Event" option enabled makes it a (HE) trigger, and disabled, in the middle of a flow makes it a (HE) condition.

Can I run another 2 questions by you. I've been using yours and Joel's flow.current_house_mode examples above in my flows. I can only seem to get the mode switch (or any flow switch) to update if there is a connector from the "save mode" node to the Current Mode switch. Is that correct? I was under the assumption it was similiar to a variable, and if I updated the mode via the "save mode" node, that it would automatically flow through to the Current Mode switch (without a connector).

Second, does anyone know what the formating is for the yellow box? It's a Hue color bulb in Hubitat. I have tried the formatting required by HE, but it doesnt work.

.

This is the set color box in the device.
image

I tried removing the Island ON again and just going directly to the setLevel and that does work as expected (ie: it does turn the light on as well). However I still have the issue where the flow terminates in each of the command nodes (Livingroom ON and Island 100%).

(As a side note in my Command nodes the Command field lists duplicates for each command. Similarly in my Device nodes the Device field lists duplicates of each device.)

I am having a hard time visualizing your connections here. Do you have a flow as an example?

new release 0.0.18

Changes

  • add attribute setting to the device node
    • It doesn't break current/default configuration
  • add value to device payload and deprecate currentValue
    • currentValue will not disappear soon
  • add a CHANGELOG.md to easier track changes (without reading 400 posts :sweat_smile:) (Thank you to @stephack)

Ongoing

  • Review @dan.t PR to support multi Hubitat hub. It change the core functional of the webhook (to be better), but I just want to be sure to not break anything and doing it right. So maybe I will ask the community help to test before the release :slight_smile:
5 Likes

Problem resolved. Apparently I was running an older node-red instance and while it worked, it was causing my noted issues with duplicates and with command nodes stopping flows.

1 Like

Are the yellow highlighted connectors required?

image

No - I don't have those connectors and can use the saved flow.* values.

In the sequence (Cat Room Motion lighting), the stored flow.* values are used for Pattie Poehl and Mode .....

As far as I can tell, sequences using those saved flow.* values just have to be on the same flow.

Well, not exactly. Used in the middle WITH ADDITIONAL LOGIC (a function node, a switch node, other) makes it a condition. In the middle just makes it a piece of data that you then have to do something else with.

1 Like

I'll probably figure this out before you answer, but...

If a device node has an attribute specified, does that mean it will ONLY return events of that attribute. All the time - manually triggered (assuming no attribute override specified) or event triggered?

Can you show how you are using the saved mode or PP status please, a screen shot of the actual (I presume) true/false switch?

I couldnt get it to work last night, until I added in a connector.

Here you go @mike:

Exported sequence

[{"id":"3c053f8.54b004","type":"switch","z":"1eb1e8e3.1c3ca7","name":"true only","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"true","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":160,"y":412,"wires":[["6513387f.d6a5d"]]},{"id":"6513387f.d6a5d","type":"function","z":"1eb1e8e3.1c3ca7","name":"Saved Pattie Poehl status to Boolean","func":"var switch_boolean = flow.get(\"pp_status\");\nif (switch_boolean === \"on\") {\n msg.payload = true;\n} else {\n msg.payload = false;\n}\nvar newmsg = { topic:msg.topic, payload:msg.payload };\nreturn newmsg;","outputs":1,"noerr":0,"x":670,"y":420,"wires":[["d7eb2d72.b08ae8"]]},{"id":"49077781.2615f","type":"function","z":"1eb1e8e3.1c3ca7","name":"Saved mode to Boolean","func":"var mode = flow.get(\"house_current_mode\");\nif (mode === \"Home\") {\n msg.payload1 = true;\n msg.payload2 = false;\n msg.payload3 = false;\n} else if (mode === \"Away\") {\n msg.payload1 = false;\n msg.payload2 = true;\n msg.payload3 = false;\n} else if (mode === \"Sleep\") {\n msg.payload1 = false;\n msg.payload2 = false;\n msg.payload3 = true;\n}\nvar msg1 = { topic:msg.topic, payload:msg.payload1 };\nvar msg2 = { topic:msg.topic, payload:msg.payload2 };\nvar msg3 = { topic:msg.topic, payload:msg.payload3 };\nreturn [ msg1, msg2, msg3 ];","outputs":3,"noerr":0,"x":790,"y":520,"wires":[["cb63d35e.be1178"],["3c053f8.54b004"],[]]},{"id":"d7eb2d72.b08ae8","type":"switch","z":"1eb1e8e3.1c3ca7","name":"true only","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"true","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1080,"y":420,"wires":[["4b160dd8.d0739c"]]},{"id":"cb63d35e.be1178","type":"switch","z":"1eb1e8e3.1c3ca7","name":"true only","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"true","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1080,"y":480,"wires":[["4b160dd8.d0739c"]]},{"id":"52336bd8.279fec","type":"switch","z":"1eb1e8e3.1c3ca7","name":"true false","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"true","vt":"str"},{"t":"cont","v":"false","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":500,"y":540,"wires":[["49077781.2615f"],[]]},{"id":"4b160dd8.d0739c","type":"time-switch","z":"1eb1e8e3.1c3ca7","name":"Dawn-20 hrs","lat":"29.977091","lon":"-90.143000","startTime":"sunriseEnd","endTime":"20:00","startOffset":0,"endOffset":0,"x":1250,"y":440,"wires":[["4ffe52b3.0563a4"],["66b3b00.86bea5","3dbec798.3f81d"]]},{"id":"687cca9d.e0f6d4","type":"function","z":"1eb1e8e3.1c3ca7","name":"mike - active/inactive","func":"switch (msg.payload.currentValue) {\n case \"active\":\n msg.payload = 'true'\n var newmsg = {payload: 'stop'}\n return [msg, newmsg]\n case \"inactive\":\n msg.payload = 'false'\n return [msg, msg]\n}","outputs":2,"noerr":0,"x":300,"y":572,"wires":[["52336bd8.279fec"],["7490a862.4aee48"]]},{"id":"4ffe52b3.0563a4","type":"hubitat command","z":"1eb1e8e3.1c3ca7","name":"CR 100","server":"a22e0ea9.276dc8","deviceId":"266","command":"setLevel","commandArgs":"100","x":1420,"y":400,"wires":[[]]},{"id":"66b3b00.86bea5","type":"hubitat command","z":"1eb1e8e3.1c3ca7","name":"CL 80","server":"a22e0ea9.276dc8","deviceId":"85","command":"setLevel","commandArgs":"80","x":1410,"y":460,"wires":[[]]},{"id":"3dbec798.3f81d","type":"hubitat command","z":"1eb1e8e3.1c3ca7","name":"CL 3500K","server":"a22e0ea9.276dc8","deviceId":"85","command":"setColorTemperature","commandArgs":"3500","x":1420,"y":500,"wires":[[]]},{"id":"1663bf8c.7cbbb8","type":"hubitat device","z":"1eb1e8e3.1c3ca7","name":"M-CR","server":"a22e0ea9.276dc8","deviceId":"228","sendEvent":true,"x":110,"y":572,"wires":[["687cca9d.e0f6d4"]]},{"id":"7490a862.4aee48","type":"stoptimer","z":"1eb1e8e3.1c3ca7","duration":"3","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":220,"y":672,"wires":[["548bb30e.a74dd4"],[]]},{"id":"548bb30e.a74dd4","type":"function","z":"1eb1e8e3.1c3ca7","name":"Switch Status","func":"msg.attribute = \"switch\"\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":700,"wires":[["cbc7235e.857178"]]},{"id":"cbc7235e.857178","type":"hubitat device","z":"1eb1e8e3.1c3ca7","name":"Persist","server":"a22e0ea9.276dc8","deviceId":"287","sendEvent":false,"x":720,"y":700,"wires":[["1096a0a5.44357f"]]},{"id":"1096a0a5.44357f","type":"function","z":"1eb1e8e3.1c3ca7","name":"off = true","func":"if (msg.payload.currentValue === \"off\") {\n msg.payload = true;\n} else {\n msg.payload = false;\n}\nvar newmsg = { topic:msg.topic, payload:msg.payload };\nreturn newmsg;","outputs":1,"noerr":0,"x":900,"y":700,"wires":[["b4250b57.43e02"]]},{"id":"b4250b57.43e02","type":"switch","z":"1eb1e8e3.1c3ca7","name":"only true","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"true","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1100,"y":700,"wires":[["57b79ca4.889fec"]]},{"id":"57b79ca4.889fec","type":"function","z":"1eb1e8e3.1c3ca7","name":"Motion Status","func":"msg.attribute = \"motion\"\nreturn msg;","outputs":1,"noerr":0,"x":620,"y":640,"wires":[["df54fa97.7c659"]]},{"id":"df54fa97.7c659","type":"hubitat device","z":"1eb1e8e3.1c3ca7","name":"M-K","server":"a22e0ea9.276dc8","deviceId":"79","sendEvent":false,"x":785,"y":640,"wires":[["a3b98aad.ab529"]]},{"id":"a3b98aad.ab529","type":"function","z":"1eb1e8e3.1c3ca7","name":"inactive = true","func":"if (msg.payload.currentValue === \"active\") {\n msg.payload = false;\n} else {\n msg.payload = true;\n}\nvar newmsg = { topic:msg.topic, payload:msg.payload };\nreturn newmsg;","outputs":1,"noerr":0,"x":960,"y":640,"wires":[["d040a62e.5db9a"]]},{"id":"d040a62e.5db9a","type":"switch","z":"1eb1e8e3.1c3ca7","name":"true only","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"true","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1180,"y":620,"wires":[["69eb0b45.b18cb4","85f1f2aa.05858"]]},{"id":"69eb0b45.b18cb4","type":"hubitat command","z":"1eb1e8e3.1c3ca7","name":"CL OFF","server":"a22e0ea9.276dc8","deviceId":"85","command":"off","commandArgs":"","x":1380,"y":572,"wires":[[]]},{"id":"85f1f2aa.05858","type":"hubitat command","z":"1eb1e8e3.1c3ca7","name":"CR OFF","server":"a22e0ea9.276dc8","deviceId":"266","command":"off","commandArgs":"","x":1380,"y":612,"wires":[[]]},{"id":"a22e0ea9.276dc8","type":"hubitat config","z":"","name":"Hubitat","usetls":false,"host":"192.168.1.46","port":"80","token":"496f7f11-256d-44c9-99c6-4ed460d3efb0","appId":"1522","nodeRedServer":"http://192.168.1.4:1880"}]

Edit:
The nodes "Saved Pattie Poehl status to Boolean" and "Saved mode to Boolean" give examples of how I use saved values in a flow. Here's how you can import a node-red flow.

I cant import them. It has an error. Are you able to format the flow as text?

Here you go

[
    {
        "id": "3c053f8.54b004",
        "type": "switch",
        "z": "1eb1e8e3.1c3ca7",
        "name": "true only",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 160,
        "y": 412,
        "wires": [
            [
                "6513387f.d6a5d"
            ]
        ]
    },
    {
        "id": "6513387f.d6a5d",
        "type": "function",
        "z": "1eb1e8e3.1c3ca7",
        "name": "Saved Pattie Poehl status to Boolean",
        "func": "var switch_boolean = flow.get(\"pp_status\");\nif (switch_boolean === \"on\") {\n    msg.payload = true;\n} else {\n    msg.payload = false;\n}\nvar newmsg = { topic:msg.topic, payload:msg.payload };\nreturn newmsg;",
        "outputs": 1,
        "noerr": 0,
        "x": 670,
        "y": 420,
        "wires": [
            [
                "d7eb2d72.b08ae8"
            ]
        ]
    },
    {
        "id": "49077781.2615f",
        "type": "function",
        "z": "1eb1e8e3.1c3ca7",
        "name": "Saved mode to Boolean",
        "func": "var mode = flow.get(\"house_current_mode\");\nif (mode === \"Home\") {\n    msg.payload1 = true;\n    msg.payload2 = false;\n    msg.payload3 = false;\n} else if (mode === \"Away\") {\n    msg.payload1 = false;\n    msg.payload2 = true;\n    msg.payload3 = false;\n} else if (mode === \"Sleep\") {\n    msg.payload1 = false;\n    msg.payload2 = false;\n    msg.payload3 = true;\n}\nvar msg1 = { topic:msg.topic, payload:msg.payload1 };\nvar msg2 = { topic:msg.topic, payload:msg.payload2 };\nvar msg3 = { topic:msg.topic, payload:msg.payload3 };\nreturn [ msg1, msg2, msg3 ];",
        "outputs": 3,
        "noerr": 0,
        "x": 790,
        "y": 520,
        "wires": [
            [
                "cb63d35e.be1178"
            ],
            [
                "3c053f8.54b004"
            ],
            []
        ]
    },
    {
        "id": "d7eb2d72.b08ae8",
        "type": "switch",
        "z": "1eb1e8e3.1c3ca7",
        "name": "true only",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 1080,
        "y": 420,
        "wires": [
            [
                "4b160dd8.d0739c"
            ]
        ]
    },
    {
        "id": "cb63d35e.be1178",
        "type": "switch",
        "z": "1eb1e8e3.1c3ca7",
        "name": "true only",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 1080,
        "y": 480,
        "wires": [
            [
                "4b160dd8.d0739c"
            ]
        ]
    },
    {
        "id": "52336bd8.279fec",
        "type": "switch",
        "z": "1eb1e8e3.1c3ca7",
        "name": "true false",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "true",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "false",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 500,
        "y": 540,
        "wires": [
            [
                "49077781.2615f"
            ],
            []
        ]
    },
    {
        "id": "4b160dd8.d0739c",
        "type": "time-switch",
        "z": "1eb1e8e3.1c3ca7",
        "name": "Dawn-20 hrs",
        "lat": "29.977091",
        "lon": "-90.143000",
        "startTime": "sunriseEnd",
        "endTime": "20:00",
        "startOffset": 0,
        "endOffset": 0,
        "x": 1250,
        "y": 440,
        "wires": [
            [
                "4ffe52b3.0563a4"
            ],
            [
                "66b3b00.86bea5",
                "3dbec798.3f81d"
            ]
        ]
    },
    {
        "id": "687cca9d.e0f6d4",
        "type": "function",
        "z": "1eb1e8e3.1c3ca7",
        "name": "mike - active/inactive",
        "func": "switch (msg.payload.currentValue) {\n    case \"active\":\n        msg.payload = 'true'\n        var newmsg = {payload: 'stop'}\n        return [msg, newmsg]\n    case \"inactive\":\n        msg.payload = 'false'\n        return [msg, msg]\n}",
        "outputs": 2,
        "noerr": 0,
        "x": 300,
        "y": 572,
        "wires": [
            [
                "52336bd8.279fec"
            ],
            [
                "7490a862.4aee48"
            ]
        ]
    },
    {
        "id": "4ffe52b3.0563a4",
        "type": "hubitat command",
        "z": "1eb1e8e3.1c3ca7",
        "name": "CR 100",
        "server": "a22e0ea9.276dc8",
        "deviceId": "266",
        "command": "setLevel",
        "commandArgs": "100",
        "x": 1420,
        "y": 400,
        "wires": [
            []
        ]
    },
    {
        "id": "66b3b00.86bea5",
        "type": "hubitat command",
        "z": "1eb1e8e3.1c3ca7",
        "name": "CL 80",
        "server": "a22e0ea9.276dc8",
        "deviceId": "85",
        "command": "setLevel",
        "commandArgs": "80",
        "x": 1410,
        "y": 460,
        "wires": [
            []
        ]
    },
    {
        "id": "3dbec798.3f81d",
        "type": "hubitat command",
        "z": "1eb1e8e3.1c3ca7",
        "name": "CL 3500K",
        "server": "a22e0ea9.276dc8",
        "deviceId": "85",
        "command": "setColorTemperature",
        "commandArgs": "3500",
        "x": 1420,
        "y": 500,
        "wires": [
            []
        ]
    },
    {
        "id": "1663bf8c.7cbbb8",
        "type": "hubitat device",
        "z": "1eb1e8e3.1c3ca7",
        "name": "M-CR",
        "server": "a22e0ea9.276dc8",
        "deviceId": "228",
        "sendEvent": true,
        "x": 110,
        "y": 572,
        "wires": [
            [
                "687cca9d.e0f6d4"
            ]
        ]
    },
    {
        "id": "7490a862.4aee48",
        "type": "stoptimer",
        "z": "1eb1e8e3.1c3ca7",
        "duration": "3",
        "units": "Minute",
        "payloadtype": "num",
        "payloadval": "0",
        "name": "",
        "x": 220,
        "y": 672,
        "wires": [
            [
                "548bb30e.a74dd4"
            ],
            []
        ]
    },
    {
        "id": "548bb30e.a74dd4",
        "type": "function",
        "z": "1eb1e8e3.1c3ca7",
        "name": "Switch Status",
        "func": "msg.attribute = \"switch\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 540,
        "y": 700,
        "wires": [
            [
                "cbc7235e.857178"
            ]
        ]
    },
    {
        "id": "cbc7235e.857178",
        "type": "hubitat device",
        "z": "1eb1e8e3.1c3ca7",
        "name": "Persist",
        "server": "a22e0ea9.276dc8",
        "deviceId": "287",
        "sendEvent": false,
        "x": 720,
        "y": 700,
        "wires": [
            [
                "1096a0a5.44357f"
            ]
        ]
    },
    {
        "id": "1096a0a5.44357f",
        "type": "function",
        "z": "1eb1e8e3.1c3ca7",
        "name": "off = true",
        "func": "if (msg.payload.currentValue === \"off\") {\n   msg.payload = true;\n} else {\n   msg.payload = false;\n}\nvar newmsg = { topic:msg.topic, payload:msg.payload };\nreturn newmsg;",
        "outputs": 1,
        "noerr": 0,
        "x": 900,
        "y": 700,
        "wires": [
            [
                "b4250b57.43e02"
            ]
        ]
    },
    {
        "id": "b4250b57.43e02",
        "type": "switch",
        "z": "1eb1e8e3.1c3ca7",
        "name": "only true",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 1100,
        "y": 700,
        "wires": [
            [
                "57b79ca4.889fec"
            ]
        ]
    },
    {
        "id": "57b79ca4.889fec",
        "type": "function",
        "z": "1eb1e8e3.1c3ca7",
        "name": "Motion Status",
        "func": "msg.attribute = \"motion\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 620,
        "y": 640,
        "wires": [
            [
                "df54fa97.7c659"
            ]
        ]
    },
    {
        "id": "df54fa97.7c659",
        "type": "hubitat device",
        "z": "1eb1e8e3.1c3ca7",
        "name": "M-K",
        "server": "a22e0ea9.276dc8",
        "deviceId": "79",
        "sendEvent": false,
        "x": 785,
        "y": 640,
        "wires": [
            [
                "a3b98aad.ab529"
            ]
        ]
    },
    {
        "id": "a3b98aad.ab529",
        "type": "function",
        "z": "1eb1e8e3.1c3ca7",
        "name": "inactive = true",
        "func": "if (msg.payload.currentValue === \"active\") {\n   msg.payload = false;\n} else {\n   msg.payload = true;\n}\nvar newmsg = { topic:msg.topic, payload:msg.payload };\nreturn newmsg;",
        "outputs": 1,
        "noerr": 0,
        "x": 960,
        "y": 640,
        "wires": [
            [
                "d040a62e.5db9a"
            ]
        ]
    },
    {
        "id": "d040a62e.5db9a",
        "type": "switch",
        "z": "1eb1e8e3.1c3ca7",
        "name": "true only",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 1180,
        "y": 620,
        "wires": [
            [
                "69eb0b45.b18cb4",
                "85f1f2aa.05858"
            ]
        ]
    },
    {
        "id": "69eb0b45.b18cb4",
        "type": "hubitat command",
        "z": "1eb1e8e3.1c3ca7",
        "name": "CL OFF",
        "server": "a22e0ea9.276dc8",
        "deviceId": "85",
        "command": "off",
        "commandArgs": "",
        "x": 1380,
        "y": 572,
        "wires": [
            []
        ]
    },
    {
        "id": "85f1f2aa.05858",
        "type": "hubitat command",
        "z": "1eb1e8e3.1c3ca7",
        "name": "CR OFF",
        "server": "a22e0ea9.276dc8",
        "deviceId": "266",
        "command": "off",
        "commandArgs": "",
        "x": 1380,
        "y": 612,
        "wires": [
            []
        ]
    },
    {
        "id": "a22e0ea9.276dc8",
        "type": "hubitat config",
        "z": "",
        "name": "Hubitat",
        "usetls": false,
        "host": "192.168.1.46",
        "port": "80",
        "token": "496f7f11-256d-44c9-99c6-4ed460d3efb0",
        "appId": "1522",
        "nodeRedServer": "http://192.168.1.4:1880"
    }
]

P.S. Sorry about the other one not importing. It imported okay into my Node-RED. No, I made an error when I pasted the original. Fixed it. They should both be importable now.

1 Like

Thanks, that worked. I'll look at it later, as busy/life.

1 Like

Yes
If a device node has an attribute configured (ex: switch), then yes it will only return EVENTS for this attribute.
If a device node has an attribute configured (ex: switch), and you override attribute with the input message. (ex power) Then the output will be an power payload. But all following events will stay on the switch attribute only

Any rewording/improving of the node documentation is welcome :slight_smile:

2 Likes

Excellent Job, this is very handy!

1 Like

Here is the command being sent
sonos

This is the error it returns

I am trying something simple getting my Google Home mini to speak using a Command Node. It's connected using the native HE Chromecast Integration. Any idea how I can keep it from saying "Good Percent 20 Morning" I tried enclosing the words in "", {}, [], <> and ' '.

image

The % is not encoded properly. I don't have access to computer right now, but I will try to fix it tomorrow

You can test with %25value%25

3 Likes

Maybe put periods between words instead of spaces in the meantime. Or comma.