Node-RED nodes for hubitat

I’d dig to see more around that as it relates to devices (read: show more of the flow)

Can someone give me an idea on a screenshot or flow of a light and motion sensor working together?

So like a motion sensor turns on a light, a delay is set for 30 seconds to turn it off. I'm trying to figure out how to have new motion reset that 30 seconds as well as having my Zooz light switch override the motion sensor in action

So Zooz switch off:
Motion can turn on the light and then turn off 30 seconds after it goes inactive
If the motion becomes active in that 30 seconds, reset timer

Zooz switch on:
Ignore all motion events, set timer to turn off automatically in 30 mins if someone forgets to turn it off (at which point this switch is off, the motion stuff works again)

I haven't used all of the features of the node. This is all it takes to recreate a Hubitat Simple Lighting App:

The config dialog box is too big to show all at once. Make sure to go all the way to the bottom. Bigtimer defaults to the circled check boxes checked and I would usually not want either checked.

1 Like

Here is mine for the laundry room. Motion turns the light on and then turns off 5 minutes later. It also turns a plug off then back on one minute later that powers my tablet mounted to wall at door. Turning off/on power to tablet wakes up screen.

The pink node is mytimeout node. node-red-contrib-mytimeout

@aaiyar If you still plan on getting the nuc v10 I wouldn't bother trying right now..at least for the i5 model. I can't speak for the i7 as it might have a different shipping chain and level of stock. My shipping date got pushed back twice for me and when I called, I was told that they were awaiting delivery from China...so...yeah....actual ship date is completely up in the air and will likely be AT LEAST a month. I ended up cancelling that order and placed one on Newegg for the v8.

1 Like

Thank You for this, I was literally about to ask how people are best handling flows that deal with sunset/sunrise and specific times of day. This looks like it should cover it well.

You can modify a flow like this one:

Motion Lighting Flow
[
    {
        "id": "f314f65b.f2f8",
        "type": "hubitat device",
        "z": "1eb1e8e3.1c3ca7",
        "name": "M-GB",
        "server": "a22e0ea9.276dc8",
        "deviceId": "322",
        "attribute": "motion",
        "sendEvent": true,
        "x": 110,
        "y": 3140,
        "wires": [
            [
                "3c7830fc.5b93c8"
            ]
        ]
    },
    {
        "id": "3c7830fc.5b93c8",
        "type": "switch",
        "z": "1eb1e8e3.1c3ca7",
        "name": "active/inactive",
        "property": "payload.currentValue",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "active",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "inactive",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 300,
        "y": 3140,
        "wires": [
            [
                "1c868d4c.756a8b"
            ],
            [
                "63a711db.7c1eb"
            ]
        ]
    },
    {
        "id": "1c868d4c.756a8b",
        "type": "change",
        "z": "1eb1e8e3.1c3ca7",
        "name": "",
        "rules": [
            {
                "t": "delete",
                "p": "payload.currentValue",
                "pt": "msg"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "stop",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 520,
        "y": 3140,
        "wires": [
            [
                "5cfa961a.1c424"
            ]
        ]
    },
    {
        "id": "63a711db.7c1eb",
        "type": "stoptimer",
        "z": "1eb1e8e3.1c3ca7",
        "duration": "10",
        "units": "Minute",
        "payloadtype": "num",
        "payloadval": "0",
        "name": "",
        "x": 520,
        "y": 3220,
        "wires": [
            [
                "c62cb855.d621b8"
            ],
            []
        ]
    },
    {
        "id": "5cfa961a.1c424",
        "type": "switch",
        "z": "1eb1e8e3.1c3ca7",
        "name": "visitor off",
        "property": "visitor_status",
        "propertyType": "flow",
        "rules": [
            {
                "t": "eq",
                "v": "off",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 720,
        "y": 3140,
        "wires": [
            [
                "7e34fe82.95c6f",
                "63a711db.7c1eb"
            ]
        ]
    },
    {
        "id": "c62cb855.d621b8",
        "type": "switch",
        "z": "1eb1e8e3.1c3ca7",
        "name": "persist off",
        "property": "persist_status",
        "propertyType": "flow",
        "rules": [
            {
                "t": "eq",
                "v": "off",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 702,
        "y": 3220,
        "wires": [
            [
                "709f18be.ec9d68",
                "b222b838.8b1d78"
            ]
        ]
    },
    {
        "id": "7e34fe82.95c6f",
        "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": 910,
        "y": 3140,
        "wires": [
            [
                "f2fa6501.310ce8"
            ],
            [
                "54cd6606.908b38"
            ]
        ]
    },
    {
        "id": "709f18be.ec9d68",
        "type": "hubitat command",
        "z": "1eb1e8e3.1c3ca7",
        "name": "GB OFF",
        "server": "a22e0ea9.276dc8",
        "deviceId": "265",
        "command": "off",
        "commandArgs": "",
        "x": 880,
        "y": 3200,
        "wires": [
            []
        ]
    },
    {
        "id": "b222b838.8b1d78",
        "type": "hubitat command",
        "z": "1eb1e8e3.1c3ca7",
        "name": "GN OFF",
        "server": "662851c4.3ccad",
        "deviceId": "275",
        "command": "off",
        "commandArgs": "",
        "x": 880,
        "y": 3240,
        "wires": [
            []
        ]
    },
    {
        "id": "f2fa6501.310ce8",
        "type": "switch",
        "z": "1eb1e8e3.1c3ca7",
        "name": "guest bedroom off",
        "property": "gb_status",
        "propertyType": "flow",
        "rules": [
            {
                "t": "eq",
                "v": "off",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 1090,
        "y": 3100,
        "wires": [
            [
                "81a6fd4b.c98b5"
            ]
        ]
    },
    {
        "id": "54cd6606.908b38",
        "type": "switch",
        "z": "1eb1e8e3.1c3ca7",
        "name": "guest nightstand off",
        "property": "gn_status",
        "propertyType": "flow",
        "rules": [
            {
                "t": "eq",
                "v": "off",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 1100,
        "y": 3191,
        "wires": [
            [
                "b3344244.ec2fa8"
            ]
        ]
    },
    {
        "id": "81a6fd4b.c98b5",
        "type": "hubitat command",
        "z": "1eb1e8e3.1c3ca7",
        "name": "GB ON",
        "server": "a22e0ea9.276dc8",
        "deviceId": "265",
        "command": "on",
        "commandArgs": "",
        "x": 1100,
        "y": 3150,
        "wires": [
            []
        ]
    },
    {
        "id": "b3344244.ec2fa8",
        "type": "hubitat command",
        "z": "1eb1e8e3.1c3ca7",
        "name": "GN ON",
        "server": "662851c4.3ccad",
        "deviceId": "275",
        "command": "setLevel",
        "commandArgs": "70",
        "x": 1100,
        "y": 3239,
        "wires": [
            []
        ]
    },
    {
        "id": "a22e0ea9.276dc8",
        "type": "hubitat config",
        "z": "",
        "name": "HubitatM",
        "usetls": false,
        "host": "192.168.1.46",
        "port": "80",
        "token": "496f7f11-256d-44c9-99c6-4ed460d3efb0",
        "appId": "1522",
        "nodeRedServer": "http://192.168.1.4:1880",
        "webhookPath": "/hubitat/webhook"
    },
    {
        "id": "662851c4.3ccad",
        "type": "hubitat config",
        "z": "",
        "name": "HubitatS",
        "usetls": false,
        "host": "192.168.1.36",
        "port": "80",
        "token": "5dee560c-c42c-4e4b-bdf7-6bed1bb77371",
        "appId": "4489",
        "nodeRedServer": "http://192.168.1.4:1880",
        "webhookPath": "/hubitat/webhook2"
    }
]

@stephack and everyone else

I made a mistake in prematurely getting a NUC. There's no doubt that the NUC sped up my flows. But they were running slow in the first place because they were horrible and chock full of function nodes.

Consider this sequence:

This sequence runs about 200 msecs faster on the NUC than my Odroid XU4 (how long it takes the light to turn on).

After seeing yesterday's posts by @dan.t and @JasonJoel about the undesirability of using a lot of function nodes (prompted by you), I replaced that sequence with this one here (which does the same thing, but no function nodes):

Turning on the light takes an average of ~256 msecs with the NUC. It takes ~270 msec with the Odroid XU4.

That's not a difference I can perceive.

So the NUC speeds up badly constructed sequences. But we shouldn't be creating bad sequences in the first place ....

I'm still keeping the NUC, but I feel mighty sheepish right now ..... (one of my many Tim the Tool Man moments).

4 Likes

Streamlining the flow makes all the difference in the world when you are talking about time sensitive functions.

That is a pretty pronounced improvement!

1 Like

Yup. And that is not the only motion flow that improved dramatically.

The other thing I did was use variables so lights are only turned on if they were off (meaning multiple turn on commands are not being sent each time motion is detected).

I'm not saying my new flows are good. But they sure are a heck of a lot better than the old ones.

That is on my list to do.... but I'm intentionally waiting to see if Bruce adds physical vs. Digital event categorization to maker API. Said he thought he would be able to.

Then at that point I can capture the physical presses and keep everything in sync a little tidier. And do the command reduction at the same time.

1 Like

If there's one thing I've learned while using NodeRed, it's that there is almost always a better way. Pretty much every flow I've ever created was rewritten at least once if not 3 or 4 times. Either I learned a better way to do it or found a new node that let's me replace 10 existing ones. More than any other tool I've used for automation, NR is the epitome of the rabbit hole. The options seem eternal.

2 Likes

@aaiyar, would you mind posting the "Guest Bedroom Motion Lighting" flow json? I'd like to see how you are using context variables in this example.

Here you go. BTW, they're flow variables, not context variables.

There is simpler option if you are just doing sunset/sunrise/time of day:

node-red-contrib-time-range-switch

1 Like

And yet another one... I use this one and the time range switch on occasion too.

I always try to use the least feature filled / lightest weight node I can for the function needed. Realistically, it probably doesn't matter if you use a huge bloated node if it is used sparingly, though.

1 Like

Hi All,

Been tinkering with the notifications on node-red.....
I've currently got a flow to do display words on matrix 7219 via wemo D1 (via http request) when a particular event happened. within this flow, I've got an array and delay set so that it will be scrolling thru different phrases. (let's call this flow A)
That flow works fine on it's own whenever I trigger it.
the question that I have is, if it's possible say to set a ping on a wemo D1, if it is not responsive to then kill flow A completely, so that it will also kill the delay time to ensure that it won't be sending the different phrases.

hope I'm making sense here.

Thanks

command

What do I put in the Argument field to use the number provided from a previous node? Or is there a different way to handle this? This command node is a virtual humidity device in HE, I'm wanting a humidity sensor from another platform to set this value for the virtual humidity.

You can pass in a message where the attribute msg.arguments is set and it will take that value to apply it to the setHumidity function

1 Like

@waynespringer79

I spent today morning looking at the exact same type of problem. I want to add to the solution that @dan.t provided with an example sequence that sets the temperature of a virtual motion/temp sensor to 70 degrees.

It works. I use a change node to set msg.argument to whatever the previous node provided as a value. And pass that long in the argument field

[
    {
        "id": "cba86d54.6f75f8",
        "type": "inject",
        "z": "605352c3.da357c",
        "name": "",
        "topic": "70",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 310,
        "y": 440,
        "wires": [
            [
                "d2a7debc.413ba"
            ]
        ]
    },
    {
        "id": "d2a7debc.413ba",
        "type": "change",
        "z": "605352c3.da357c",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "argument",
                "pt": "msg",
                "to": "topic",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 530,
        "y": 440,
        "wires": [
            [
                "2a7c8db2.96dfda"
            ]
        ]
    },
    {
        "id": "2a7c8db2.96dfda",
        "type": "hubitat command",
        "z": "605352c3.da357c",
        "name": "Virtual Motion Sensor",
        "server": "a22e0ea9.276dc8",
        "deviceId": "1314",
        "command": "setTemperature",
        "commandArgs": "msg.argument",
        "x": 760,
        "y": 440,
        "wires": [
            [
                "9c3450c6.a32f88"
            ]
        ]
    },
    {
        "id": "9c3450c6.a32f88",
        "type": "debug",
        "z": "605352c3.da357c",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 980,
        "y": 440,
        "wires": []
    },
    {
        "id": "a22e0ea9.276dc8",
        "type": "hubitat config",
        "z": "",
        "name": "HubitatM",
        "usetls": false,
        "host": "192.168.1.46",
        "port": "80",
        "token": "",
        "appId": "1522",
        "nodeRedServer": "http://192.168.1.4:1880",
        "webhookPath": "/hubitat/webhook"
    }
]
1 Like