Node-RED nodes for hubitat

You should try using msg.topic.

Edit: Yup, that'll work ....

Screen Shot 2020-03-08 at 10.39.10 AM

Screen Shot 2020-03-08 at 10.39.23 AM

1 Like

Thanks. I knew there was a simple answer.

1 Like

I'm trying to set this up but when I toggle my test switch, nothing comes out the device node.
I also get a 404 in my NR logs

I am running NR in a container but I don't think that is the issue as I have other integration using maker api without issue.

Edit: I see @kevin posted a similar issue earlier on. I'm also running NR as a HA addon.
@kevin, did you ever get this sorted out?

Edit 2: Figured it out. Just needed to read the Addon docs in details. @kevin, fyi, all http endpoints in the addon are exposed under /endpoint. So you would need to edit the Maker Api POST url to be
http://192.168.x.x:1880/endpoint/hubitat/webhook

1 Like

@danfox52, if you want to see everything a node is outputting, you should change the debug node to show the complete message.

image

This way you get the full picture of what is going in and coming out of nodes. I always change that on every debug node I create.

2 Likes

I wish I knew how to set "default" options for some nodes. For the debug node it isn't too much work to change it from msg.payload to the complete message object.

But for other nodes - like time-based nodes, it would be nice to have latitude and longitude set globally (or even just once per flow).

1 Like

At the bottom of every flow tab, I have a bunch of "template" node and flows. Anything I create often, I leave down there and then copy and paste as needed. I call it my Junk Yard :stuck_out_tongue_winking_eye:

This is my HA occupancy lighting tab. The junkyard is pretty empty now but I had a few long node strings.

If it gets crowded down there, I try to create a subflow to handle all the logic. That's what I did in this case. All the little teal nodes with the light bulbs were a string of nodes that was slowly growing. Every time I added more complexity to my logic, I would have to edit every node in the string for each room. Gets tiresome fast so I created a subflow that I have to edit once. Here's the subflow for the "bulb" node.

3 Likes

Are you able to post a code link to the subflows? I learn by seeing how others do it.

Also, what's the best way to only send a message to HE if required, with this flow.

On another note, I cant believe how easy this was. I was attempting to use function nodes until the discussion late last week. This rule in HE was one of those rules constantly throwing up sql/db errors.

2 Likes

I could but I'm not sure how helpful it would be to you. Firstly, this is a flow for HA not HE. I'm also not even sure it will let you import it anyway. The green nodes are a personally customized version of the stoptimer node.

I'm not sure what you mean here. Are you asking how to only send an on/off command if necessary? Eg is light is already on, then don't send on command. If so, then that would probably be a better answered by @aaiyar. I think he mentioned doing this earlier in the thread.

1 Like

Yup, I did.

@mike - let me know if you want an example. Basically, I just record the on/off of every switch (msg.payload.currentValue) in a flow variable, and then turn the light on only if the flow variable is "off".

Be happy to post a flow if you'd like.

2 Likes

I read through much of this thread again, to increase my knowledge. As they say, a little knowledge is dangerous. I appreciate the help offered here by you all.

Back at release 0.0.18 it was said that currentValue was being depreciated in favor of value (although, not anytime soon). Should I begin making flows with value instead?

Yes.

2 Likes

Is there a way to dynamically pass a command into a Hubitat/Node-Red "Command" node?

So instead of this Switch node which reads the payload:

Screenshot 2020-03-09 11.17.21

I'd like to have something like this where I feed in the command (and maybe even the deviceId) into the Command node

{ payload: { "command": "on"} } -> Command node for light with "# Command" not specified

I see many other nodes allow something like that, for instance the HttpRequest node allows one to leave the "url" parameter blank and it will then instead try to read "msg.url" (which was set somewhere before coming into the node)

So for instance, this would cut out a LOT of clutter of nodes.

Screenshot 2020-03-09 11.25.02

I realize that certain devices have certain commands and you're trying to make it easy for the average joe not to sent a setHue command to a light switch, but for advanced people it would leave that kind of validation and error trapping to us

You are setting msg.payload.command here. Try setting msg.command and/or msg.deviceId instead. If one deosn't work, usually the other does.
Also, don't type this in manually in the input fields. Set it via a change node (or function node if that is your preference).

1 Like

I created a test flow and it worked using msg.command.
The set the command node to turn off the switch (but could have left the command input blank as well). I set it to off to prove that it would also override any existing settings and also avoid the NR message that the node was not properly configured. The change node set the command to on and passed it into the command node, which then turned the switch on successfully.

1 Like

Very clever! I like that!!

1 Like

One of the many tricks you will learn over time and that will have you rewriting flows in the future :wink:. Like I mentioned in the past, I have rewritten most of my flows at least 3 times as I learn new tricks.

Most nodes (but not all) allow you to do this type of dynamic entries. If you remember when I recently advised Mike that I had a personalized version of the stoptimer node. That's because it did not support this type of dynamic data entry so I editted the node (with the help of the infamous @dan.t) to allow it to function this way. It's especially important when using subflows. I usually have a change node just before each subflow that sets all the dynamic variables that needed for processing by the subflow. This way it can be reused over and over again for different device with different delays, config, etc. This trick will save you a boatload of time (and screenspace) in the future.

4 Likes

I think the problem occurs when you leave the field blank. Just select a default command in the properties and overwrite the default with msg.command

1 Like

I use refresh as my default command on most command nodes.

1 Like

I have a simple Node Red Question. In a sequence, if the triggering node gets triggered again, does that stop the node in it's tracks and start it over or are 2 instances of sequence running simultaneously. Lemme try to explain question with this simple sequence below that turns on light due to motion and then turns it off 3 minutes later. If motion is detected again within 3 minutes, does that stop the delay and restart the sequence or will the delay continue and then turn off light when delay is over then be followed by a second instance of the sequence that turns light off again after the delay in instance 2?

It does not automatically cancel, you are creating a race condition there where one is going to walk on top of the other

If you walk into that room, the light turns on, walk out right away, let the motion sensor go inactive, and walk back in before 3 mins, the light will turn back on but it will still turn off when the first instance hits 3 minutes

Here is a simple example to see in action, if you click "inject" twice quickly you will see two debug messages

[{"id":"49147226.63632c","type":"inject","z":"1a044a0d.5350f6","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":880,"wires":[["f92c51ba.c7904"]]},{"id":"f92c51ba.c7904","type":"delay","z":"1a044a0d.5350f6","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":880,"wires":[["3c4cfdf.c4b2e02"]]},{"id":"3c4cfdf.c4b2e02","type":"debug","z":"1a044a0d.5350f6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":500,"y":880,"wires":[]}]