Node-RED nodes for hubitat

So, im looking to join the NodeRed rabbit hole and thought I woul ddip my toes in
Ive read through the topic, but something tells me it going to take a few reads!!

Just wanted to know if i was on the path with what i have created - Simple motion sensor to turn fibaro switch on, the off after x seconds

It works, but dont know if there are better ways - or that's it!

I am curious if this works exactly as you want. I am still relatively new to Node Red but it would seem that since you split your sequence after active/inactive, you could have you motion sensor go active, then inactive, then immediately (less time than your delay) go active again while the bottom leg is in a delay and the result will be light turning off while the sensor is still active.

This is by no means the best way but is the way I do it:

FIrst, I have changed the colors of Device Nodes to light blue and Command Nodes to orange so that they are easier to distinguish. The 2nd node is a Time Range Node (node-red-contrib-time-range-switch) so that this sequence only runs between Sunset & Sunrise. The Switch Node only passes the Active status for the Motion Sensor. Then Exterior Patio Node turns on light and starts the timer on the Mytimeout Node (node-red-contrib-mytimeout) down from 300 seconds (5 minutes) then turns light off. The benefit over doing it this way is that every time that sensor senses motion, it resets the timer without the sequence trying to turn light off. I know that the Delay Node can be reset or cancelled but not as easily as the Mytimeout Node can be. Also, when the Mytimeout Node is in countdown mode, the time remaining appears under the node.

There are definitely experts in this thread who might have better, more efficient & prettier solutions.

I don't think you need the final Device Node unless you are going to continue the sequence to do something else when the MasterBed light changes. Devices update automatically from Hubitat on a change.

Good luck & keep the questions coming! There is a great range of Node Red experts and newbies on this thread.

1 Like

You don't need the device node at the end of sequence.

1 Like

I will look into mytimeout node and have a play

Plenty to learn, so im sure there will be plenty of questions

I did try removing it previously, but the light never turned on.. only seemed to work whe k added the final device node

Will give it another try!


Something else was wrong on that occasion. Anyway, here's what I would use as a simple motion sequence. It uses a stoptimer node. So whenever motion is active the timer is stopped and it runs again when motion is inactive.

Screen Shot 2020-03-25 at 7.21.38 AM

Question about this sequence:

I can see how motion being active stops the mytimeout node. How does motion being inactive get it started again?

Plenty of options to try.

Next i want to incorporate modes into the sequence!
Off to learn the mode node!

When the Mytimeout Node gets a payload, it resets and immediately starts counting down again. It doesn't need to be told to start the countdown again. I only do action when sensor goes active and just keep the light on for 5 more minutes. The timer won't get reset until motion sensor goes inactive and then active again from additional motion sensed.

Does the Stop Timer behave differently? I don't have that installed.... yet.

If you are like me, you will create a flow that's working exactly like you want then someone on this thread will point out a cool new Node Palette they started using and now you are re-doing half your flows to be more efficient using this new Palette. Also, as you can see just from @aaiyar and myself, there are tons of different ways to accomplish basically the same task and you will just tweak so it performs exactly like YOU want it to.

1 Like

So i have removed the last device node and it worked - So not sure what happened last time

However, i get this is the debug panel (just before the delay timer ends):
msg : string[105]

"Unable to cast to dataType. Open an issue to report back the following output: VECTOR3: "[x:-6,y:-7,z:0]""

What node did that message come from, though? It should say at the top of the debug message.

That's how I do mine, too. As I have a few motion sensors that stay active continuously (and don't toggle from active/inactive/active) when there is continued movement, I need the timer to STOP while motion=active.

It came from the 1st one. Motion sensor device

Well, that's a new one. Never seen that before.

If you get time, export/post the flow and I'll import it and take a peek. (you can delete your hubitat connection IP and token before pasting the flow if you want).

Is this what your after?
[{"id":"994a7bf5.258338","type":"tab","label":"Master Bed","disabled":false,"info":""},{"id":"60d934b5.e0ba9c","type":"hubitat device","z":"994a7bf5.258338","name":"MasterBed Motion sensor","server":"b0c51395.d586c","deviceId":"257","attribute":"motion","sendEvent":true,"x":170,"y":80,"wires":[["4183347c.0411bc"]]},{"id":"4183347c.0411bc","type":"switch","z":"994a7bf5.258338","name":"active/inactive","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"active","vt":"str"},{"t":"eq","v":"inactive","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":420,"y":80,"wires":[["1d67444f.9c2e9c","67731887.2d5268"],["4422fe45.896c6"]]},{"id":"1d67444f.9c2e9c","type":"hubitat command","z":"994a7bf5.258338","name":"MasterBed Switch ON","server":"b0c51395.d586c","deviceId":"393","command":"on","commandArgs":"","x":760,"y":40,"wires":[[]]},{"id":"a6677862.1c8c18","type":"hubitat command","z":"994a7bf5.258338","name":"MasterBed Switch OFF","server":"b0c51395.d586c","deviceId":"393","command":"off","commandArgs":"","x":1050,"y":200,"wires":[[]]},{"id":"67731887.2d5268","type":"change","z":"994a7bf5.258338","name":"active=stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"active=stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":120,"wires":[["4422fe45.896c6"]]},{"id":"4422fe45.896c6","type":"stoptimer","z":"994a7bf5.258338","duration":"30","units":"Second","payloadtype":"num","payloadval":"0","name":"30 sec timer","x":750,"y":260,"wires":[["a6677862.1c8c18"],[]]},{"id":"b0c51395.d586c","type":"hubitat config","z":"","name":"","usetls":false,"host":"","port":"80","token":"DELETED TOKEN-caf0b958bc9d","appId":"545","nodeRedServer":"","webhookPath":"/hubitat/webhook"}]

Also, i know as is, the change node doesnt work, as im trying @aaiyar way with the stop timer, and no idea how to set it correctly!

Nothing obviously wrong with the flow - other than the change block, as you already mentioned. For that just set the "to" to "stop", not "active=stop".

From the node help, it specifically says the payload has to be "stop" or "STOP" - not "active=stop".
Screenshot 2020-03-25 at 8.30.18 AM

So back to the original error message... That is a curious error message you received. I wouldn't worry about it unless you get it more times. If it was a once and never see it again, just move on. If you keep getting it report it here to @fblackburn.

I seem to get that error each time!!!

And for the dummy here, is this the change node settings:

Is there a period after payload? Looks like there is to me...

1 Like