Node-RED nodes for hubitat

You understood it more than you realize, the change node was what I was missing. Thank you sir!

1 Like

Do you mind sharing the entire "Water detected..." expression you have in that change node example?

What is shown was the whole expression.

1 Like

You probably don't need this explanation, but just in case, @JasonJoel is using JSONata to concatenate "Water detected on " to msg.topic, which will always contain the name of the specific Hubitat device the message emanates from.

1 Like

@JasonJoel and @aaiyar Which of you two are willing to teach a noob? :stuck_out_tongue:

Here's what I'm trying to do.

I've got some contact sensors that I monitor for open/close in HE currently with notifications and want to move as much as I can to NR.

In NR I've got the following.

image

  • I have a device node with the Attribute set to contact. I attached a debug node to get the output of both the open and closed state. (output seen below)
  • Attached is a switch node with each side set to contains "currentValue":"open" or "currentValue":"closed" which came from the payload from opening and closing the door.

{"name":"contact","value":"open","displayName":"Office Door","deviceId":"273","descriptionText":null,"unit":null,"type":null,"data":null,"currentValue":"open","dataType":"ENUM","values":["closed","open"]}

{"name":"contact","value":"closed","displayName":"Office Door","deviceId":"273","descriptionText":null,"unit":null,"type":null,"data":null,"currentValue":"closed","dataType":"ENUM","values":["closed","open"]}

Next I was attaching a change node to change the payload depending on contents but unfortunately I can't get any data to flow through the switch.

What am I missing?

First, never use msg.payload.currentValue, it has been deprecated and will likely go away at some point. Always use msg.payload.value.

From the hubitat device node online help (and I'm not trying to lecture, just giving a bit of advice, but you should thoroughly read the online help for any node you use as there is often very important info in there):
image

Second, you didn't show the switch config, so I'm guessing what the issue is... But instead of using an expression in the switch node, consider just specifying msg.payload.value as the property to switch on.

Here is an example open/closed switch I use straight off a device node:
image

You could do the matching in a json expression, but it is MUCH easier to just look at the actual property you want to switch on (like above). If you really wanted to do it in an expression, it would be something like this:
image
(or "open", "closed", etc instead of "off" - you get the idea)

1 Like

If only I knew a fraction of what you know about this stuff. I really hope questions don't bother people here because as I move forward I'll be asking many, many more.

You sir, are a godsend, thank you.

2 Likes

No bother at all!! They are very good questions. And experience only comes with time and use.

I've screwed up so many elementary things in node-red (and everything else I do) so many times it isn't funny.

Heck, I even burned my finger with a soldering iron today, and I've definitely soldered enough to know better. So no one is perfect on any given day, even with experience. :laughing:

6 Likes

Now that files can be created, appended, and deleted on the HE with RM, is there a way any of that could be done using Node Red instead?

Hey there! So I'm a way behind you on setting up motion lighting but found the exact same article you referenced in post 129. Funny enough, going by Jason's suggestion I have the same issue where the light turns back on at the end of the timer. Unfortunately I don't quite understand what the fix was but seems you do. Mind giving me some pointers on that one?

Here's an example of a simplified motion lighting sequence that you can import. In this example, a dimmer is set to 100% between Dawn and 8PM and to 10% between 8PM and Dawn. The dimmer is turned off after 3 minutes of inactivity.

Sequence

[{"id":"97662e27.c6dcf","type":"hubitat device","z":"d3c447a.4b49db8","name":"Motion sensor","server":"a22e0ea9.276dc8","deviceId":"228","attribute":"motion","sendEvent":true,"x":160,"y":1460,"wires":[["4e18fa52.74a594"]]},{"id":"4e18fa52.74a594","type":"switch","z":"d3c447a.4b49db8","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":360,"y":1460,"wires":[["331bd2f1.606546"],["a8901484.0d08c8"]]},{"id":"331bd2f1.606546","type":"change","z":"d3c447a.4b49db8","name":"stop","rules":[{"t":"delete","p":"payload.value","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":1460,"wires":[["a8901484.0d08c8","fff39835.eb6a8"]]},{"id":"a8901484.0d08c8","type":"stoptimer","z":"d3c447a.4b49db8","duration":"3","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":720,"y":1580,"wires":[["8599b215.02a988"],[]]},{"id":"fff39835.eb6a8","type":"time-range-switch","z":"d3c447a.4b49db8","name":"Dawn-8PM","lat":"29.977091","lon":"-90.143000","startTime":"sunrise","endTime":"20:00","startOffset":0,"endOffset":0,"x":730,"y":1460,"wires":[["aae06219.b86fb8"],["4a64f16c.4b219"]]},{"id":"8599b215.02a988","type":"hubitat command","z":"d3c447a.4b49db8","name":"OFF","server":"a22e0ea9.276dc8","deviceId":"1478","command":"off","commandArgs":"","x":910,"y":1580,"wires":[[]]},{"id":"4a64f16c.4b219","type":"hubitat command","z":"d3c447a.4b49db8","name":"LEVEL 10","server":"a22e0ea9.276dc8","deviceId":"1478","command":"setLevel","commandArgs":"10","x":920,"y":1520,"wires":[[]]},{"id":"aae06219.b86fb8","type":"hubitat command","z":"d3c447a.4b49db8","name":"LEVEL 100","server":"a22e0ea9.276dc8","deviceId":"1478","command":"setLevel","commandArgs":"100","x":930,"y":1460,"wires":[[]]},{"id":"a22e0ea9.276dc8","type":"hubitat config","z":"","name":"HubitatM","usetls":false,"host":"192.168.1.46","port":"80","appId":"1522","nodeRedServer":"http://192.168.1.4:1880","webhookPath":"/hubitat/webhook","autoRefresh":true}]

3 Likes

I'll take a look, thanks for the response!

I'll take a look, thanks for the response!

That worked btw, but, would it be too much to ask if you could, in noob terms, explain why in your first attempt, post 129, that the lights were turned back on after they were turned off and why this fixes it? Was it because you weren't deleting the payload in the change node? I'm wanting to understand why things work, not just make them work. :stuck_out_tongue:

I can’t remember what I did yesterday; little chance of recalling something from a few months ago ....

1 Like

Either or, I appreciate the assistance. I'll poke around until I figure it.

1 Like

His version in post 129 reset the stoptimer if motion was active or inactive. That works fine as long as the sensor toggles back and forth frequently (in less time than the stoptimer timeout value) - some do, some don't.

If it is a type of sensor where motion=active the whole time there is motion, it would turn off the light after 3 minutes because there is never a new event to reset the stoptimer.

That is why it is better to only start the stoptimer on motion=inactive, and stop the stoptimer (not reset it) when motion=active. That way the lights don't get turned off if there is continuous motion.

1 Like

@JasonJoel

Thanks!

I'm still trying to find post 129 (that's how slow I am today!)

1 Like

:slight_smile:

1 Like

So guys,

I have a little project I want to try, and I figured I would reach out to ask those of you that are well versed with nod red.

Basically I want to create a device in hubitat that displays the status of my toyota and also be able to lock/unlock the doors.. There is not an api for this however google assistant has an integration that I can exploit through google assistant relay.

The thing is - I need to parse the response for GAR and then send response accordingly as the toyota integration requires you provide a pin, or at anytime may not respond so I need to parse for these responses. - any thoughts on how / what nodes to use to accomplish what I am after?

So far so good with alexa.remote2 palllete - Have got my speech notification working great.
However, i cant seem to get 'on device activity' to work.... I'm trying to setup something so that when my FireTV basic turns on it sets off a number of routines...
Anyone get something like this ot work?
Also, when i ask alexa to "open garage door" or "turn off light" the command gets send and actioned via NR, but she replies with "i cant find a device" or to that effect..
How are you getting around this? setting up blank routines or custom responses via NR?