Node-RED nodes for hubitat

I don't use Google but in this flow, motion is ignored if the light is already on.

[{"id":"1dd1fb73.73e095","type":"group","z":"68be3b45.fb2464","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["a31667ea.aadf","abfe7e4a.c24058","cf39e458.37188","3bc1ae70.748552","1e93ab9d.366914","f2b43711.a4276","7a3b878.b36b1f8","80bc3b7d.29dca","aca11047.6fc428","6e9ab0d1.74682","cee08a62.a12318","a48fcf51.994c68","6dc1f51a.b9561c","fbae6e61.cf485","49ac679c.a688d","750e04e7.cd72ec"],"x":109.5,"y":3401.5,"w":1413.0000762939453,"h":271.5},{"id":"a31667ea.aadf","type":"hubitat device","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","deviceLabel":"Pantry Motion Sensor","name":"","server":"2e073620.1f85c2","deviceId":"712","attribute":"motion","sendEvent":true,"x":256.0000190734863,"y":3525.666799545288,"wires":[["abfe7e4a.c24058"]]},{"id":"abfe7e4a.c24058","type":"switch","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","name":"Motion (Y/N)?","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":482.0000114440918,"y":3526.4167737960815,"wires":[["cf39e458.37188","3bc1ae70.748552"],["1e93ab9d.366914"]],"outputLabels":["Active","Inactive"]},{"id":"cf39e458.37188","type":"hubitat device","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","deviceLabel":"Pantry Light","name":"Pantry Light State","server":"2e073620.1f85c2","deviceId":"700","attribute":"switch","sendEvent":false,"x":883.2500343322754,"y":3518.666799545288,"wires":[["f2b43711.a4276"]]},{"id":"3bc1ae70.748552","type":"change","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","name":"Reset Delay","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":646.9999732971191,"y":3465.6667985916138,"wires":[["7a3b878.b36b1f8"]]},{"id":"1e93ab9d.366914","type":"delay","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","name":"Delay 1 minute","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":666.2500343322754,"y":3578.9168004989624,"wires":[["750e04e7.cd72ec"]]},{"id":"f2b43711.a4276","type":"switch","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","name":"Light Off?","property":"payload.currentValue","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1073.333293914795,"y":3518.4167985916138,"wires":[["6e9ab0d1.74682"]]},{"id":"7a3b878.b36b1f8","type":"link out","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","name":"Reset Delay (P) - Out","links":["80bc3b7d.29dca"],"x":847.4166603088379,"y":3465.6667985916138,"wires":[],"l":true},{"id":"80bc3b7d.29dca","type":"link in","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","name":"Reset Delay (P) - In","links":["7a3b878.b36b1f8"],"x":460.4166564941406,"y":3579.166748046875,"wires":[["1e93ab9d.366914"]],"l":true},{"id":"aca11047.6fc428","type":"link in","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","name":"Time Delay - In","links":["45f02297.6a5ad4"],"x":478.33331298828125,"y":3632,"wires":[["1e93ab9d.366914"]],"l":true},{"id":"6e9ab0d1.74682","type":"change","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","name":"Turn On","rules":[{"t":"set","p":"command","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1246.7500762939453,"y":3518.916748046875,"wires":[["cee08a62.a12318"]]},{"id":"cee08a62.a12318","type":"hubitat command","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","deviceLabel":"Pantry Light","name":"","server":"2e073620.1f85c2","deviceId":"700","command":"","commandArgs":"","x":1426.5000762939453,"y":3552.416748046875,"wires":[[]]},{"id":"a48fcf51.994c68","type":"change","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","name":"Turn Off","rules":[{"t":"set","p":"command","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1248.2500762939453,"y":3580.416748046875,"wires":[["cee08a62.a12318"]]},{"id":"6dc1f51a.b9561c","type":"switch","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","name":"Light On?","property":"payload.currentValue","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1076.7498321533203,"y":3579.75,"wires":[["a48fcf51.994c68"]]},{"id":"fbae6e61.cf485","type":"comment","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","name":"Pantry Light: Turn on/off if motion detected","info":"","x":305.5,"y":3442.5,"wires":[]},{"id":"49ac679c.a688d","type":"comment","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","name":"Change Log","info":"2021-08-26: Created\n2021-08-26: Separated logic for turning off/on based on motion. Also added link from light turning on with contact sensor\n2021-08-27: Changed motion delay off to 1 minute (2 mins was too long)","x":216.75,"y":3627.5,"wires":[]},{"id":"750e04e7.cd72ec","type":"hubitat device","z":"68be3b45.fb2464","g":"1dd1fb73.73e095","deviceLabel":"Pantry Light","name":"Pantry Light State","server":"2e073620.1f85c2","deviceId":"700","attribute":"switch","sendEvent":false,"x":887.6666870117188,"y":3579.33349609375,"wires":[["6dc1f51a.b9561c"]]},{"id":"2e073620.1f85c2","type":"hubitat config","name":"Hubitat_Prod","usetls":false,"host":"192.168.1.113","port":"80","appId":"225","nodeRedServer":"http://192.168.1.82:1880","webhookPath":"/hubitat/webhook_","autoRefresh":true,"useWebsocket":false}]

Hope this helps

2 Likes

Don't have a specific flow for this but here are some ideas:

  • Set up a virtual HE switch that flips on when you issue the command from google. Test for that switch during your motion sequence.

  • Test for msg.payload.type = 'digital' if your switch supports it. This will only distinguish between physical and digital switches not Google Home specifically. You can then set a global variable to test during your motion sequence.

You would still have to figure out how you want to reset the switch when you are done - either timeout or issue another Google command etc..

2 Likes

I turned up Node Red logging to Debug to see if I noticed anything that could be causing my slowdown and saw this in the logs that happens every 5-10 seconds. I am not saying this has anything to do with slowdown, just curious what is being "locked" as I have no actual locks.

It's only for debug purpose
To avoid spamming hub, I added a lock to limit number of requests. This log only show remaining slot available to do simultaneous requests

4 Likes

Cool! Thank you. I learn something new every day.

1 Like

I was updating the log level in the settings.js file and noticed this above the Log Settings:

It looks like if I were to change the "//paletteCategories: ['subflows..." to "paletteCategories: ['hubitat', 'subflows', ....." then the Hubitat palette would always be at the top of left column? Can someone confirm if that is correct?

EDIT: I took a chance and made the change and that is in fact what it does. I wish I would have known this at the beginning.

4 Likes

Oh thank you for sharing, I added a link to your post in the first post FAQ :slight_smile:

3 Likes

Anyone tried linking to Tuya using these nodes?

It seems like they offer a way to support all Tuya devices!

There also appears to be a local approach too....

Update: cant get these to work. They require a device key (not the account key) and I can't find any way to generate or find that.

I just started using the Broadlink HE integration & Node Red together and the Command Node puts the code being sent underneath. Is it possible to disable that just for specific nodes? It really grates on my OCD with all of those numbers but I generally want that information on every other node. :grinning:

1 Like

:rofl: Unfortunately, not possible ... I'm sorry for you

Workaround (not tested)
Add a Change node before each command to inject the command arguments in the msg.arguments.
Then the node will not print dynamic arguments

You can open an issue on github to ask for a better solution.
I may re-start to give a little bit love to this project. Now that I have a house and waiting for end-of-year deal to buy more IoT stuff :drooling_face:

3 Likes

GREAT MINDS THINK ALIKE!!! This morning, I set it up for the first few to test and it works as we both knew it would. :grinning: And, since it will eventually only add one net node because I am replacing a Command Node with a Change Node then all of them can go to one Command Node, I might not even call this a workaround.

3 Likes

Can someone help me?

I'm at my friend's place "helping" him get Node-RED up and running with Hubitat, and I forget how I configured a change node to send three saved flow context variables as msg.arguments for hue, saturation, and level.

I thought I had done something like setting msg.arguments to be JSONata with the following entry:

$flowContext(".hue_variable"),$flowContext("saturation_variable"),$flowContext("level_variable")

But this is obviously wrong because it throws an error.

Many thanks!

It's not exactly what you want but this is how I'm setting Hue lamp brightness level and temp, based on global context variables, in case it helps (probably not since I guess it is Philips Hue specific and just white lamps not colour/hue)...

1 Like

The only thing I can find quickly is:

(payload != '') ? payload : $globalContext('currentMode')

again, not on point, but it's syntactically correct ")

Is the dot in

(".hue_variable"),

the error?

1 Like

Thanks guys! In the end, I just used a join node .....

3 Likes

A bit late, but for the Inovelli LEDs, I use the following:

So did you have to build the string?

2 Likes

Yup. And it was so easy using a join node ...... no JSONata or functions needed!

2 Likes

Anyone know if I can use a change node to take a message msg.Varname and msg.Value and set global. {msg.Varname} to msg.Value? I don't see a way to do it with a non-function node.

Not in a change node that I know of but easily done with a function node like this:

global.set(msg.varName, msg.varValue);

return msg;
2 Likes

Thanks!
I ended up with that... It is my first function node, I have been avoiding them...

3 Likes