Node-RED nodes for hubitat

Thank you for the help. I didn't use your example flow path, but was able to see what I needed to change to make all of mine work. Just needed to use a change to set the desired text to msg.arguments then pass that straight to the notification. I might use your function idea for passing on which zone is tripping my alarm system if i have an intrusion alarm. Thanks for the help.

Just got myself a zigbee door lock and have this simple flow.


image
Can someone tell me why when the mode changes from Home to Away - Nothing happens, but when mode changes from Away to Home, the flow runs??

why is your property global.house_mode? Iā€™m not sure how you have everything else setup, but if you want to switch based on the hubitat mode changing in this flow it should be msg.payload.value.

2 Likes

I have a flow that sets the modes as a global variable. Then i can use a switch node anywhere in the middle of a flow to check mode
image

I solved my issue by putting a link out node after the global variable flow, and then again before my switch for the lock flow.
image

I think anywhere i need to start a flow based on Mode, i use a link in node 1st, then continue with the rest of the flow!!

Glad you got it working! I use lots of link nodes when it comes to flows that set the mode.

I also put my mode into a global variable, but I only ever use it as a test condition. I prefer to use the actual event to trigger an automation (like a change in presence) rather than a change in mode. I feel like using a mode change as a trigger just adds another level of abstraction. The way you had this setup essentially created a race condition depending on whether the mode trigger fired first or the global variable was set.

1 Like

It is a consequence of your sequence being constructed in a manner that permits this to happen. Consider the following:

  1. At the very instant that Mode changes, your global variable still has the value of the LAST mode change.
  2. Ergo, at the instant the mode changes from Home to Away, the global variable still has the value of the previous mode (i.e. Home), and your sequence does not proceed.
  3. Conversely, at the instant mode changes from Away to Home, the global variable still has the value of the previous mode and your sequence proceeds.

@jrau272's suggestion to evaluate msg.payload.value for the Mode change would certainly have worked. As an alternative, adding even a 10 millisecond delay node between the Mode node and the switch node for the global variable work just as well because it permits the value of the global variable to match the Mode.

Not that it matters any more as you have a solution that meets your needs. Just one suggestion, in place of having a switch node with two outputs for the global variable, you could have a single output matching either "Away" or "Sleep" if you use "matches Regex" in place of "==" in that switch node.

3 Likes

fwiw I like to use MQTT instead of links.. to me it's a bit more flexible and allows external connections as well. I use the node-red-contrib-aedes node and then use the MQTT in/out nodes. I created a simple subflow for storing in a global var and mqtt and then use the MQTT IN node for capturing the "event".

2 Likes

Thanks to you all!!
Some food for thought re: adding a delay

1 Like

Doesn't JsonATA work well here too??

Screen Shot 2021-06-14 at 7.23.19 AM

global.house_mode = "away" or global.house_mode = "asleep"

3 Likes

It should. Don't see why that wouldn't work just as well.

1 Like

Just FYI that I've been testing the node-red 2.0 beta 1 release with all my standard node sets, and it seems to work fine with the Hubitat nodes - at least the ones I tested. I don't use the mode or hsm nodes (although I should probably add them to my test flow) , so can't comment there.

Side note, node-red 2.0b1 does NOT currently work fine with Deconz or zigbee2mqtt when using the new Monaco editor (which is optional anyway, so not a show stopper, just an FYI).

6 Likes

Oh it's a really good news, thank you.
If there are some issue I think it will be in the UI part (not in the backend part where the logic is done)
For the UI, there are some hacks based on undocumented core code, so I'm going to double check code, but nothing with big impact (I guess).

I'm pretty busy this summer (home buying process, and HE is already in a box :sweat_smile: ), so I hope to give this project some love this fall :slight_smile:

4 Likes

I didn't know what could be done with JSONATA till very recently. Where I would have previously used a function node to validate if a value matched one in a list, I found that I could do it from within a switch node!

1 Like

I wish someone here could direct me in the path of replacing my Hubconnect instance with Node-Red.
I have a Samsung VRF (hvac) installed and connected to the Smartthings cloud (no hub on my side) using a Wifi kit (MIM-H04N). I can see and operate each unit in the system using the ST app.
Using HubConnect I created virtual devices on Hubitat side and was able to connect and sync the units to Hubitat. It is working nice but reading that Samsung will not support the IDE platform I am looking for an alternative.
For tetsing I installed Node-Red on my PC and ws able to bring ST deivces and Hubitat devices to the Node-Red system. All units are there and I can see their attributes.
I am now looking for a way to make sure whatever I do in one of the systems (ST or HE) gets reflected in the other system.
What is the best way to get this done?

Move all your "rules" to Node-RED? That way it doesn't matter which platform you incorporate.

1 Like

You need to begin with creating a MakerAPI instance on each hub. Then, create in Node-Red multiple Hubitat Configs, one for each Hub, filling in the IP addr, App number and security Token.

Screen Shot 2021-06-14 at 6.52.26 PM

They need to be unique for the webhook:

Screen Shot 2021-06-14 at 6.53.19 PM

For me, I just add the sequential hub number (order in which they were purchased) to the end. Sixth hub?? then "/webhook6"

From then on, you simply pick the Hub that the device lives on and select away. :smiley:

Don't just edit an existing node to create a new Hubitat config in Node-red... :slight_smile: In other words, if you have 4 hubs, add 4 'blank" Hubitat nodes and then in each one, create the config that ties to the instance. It's not a requirement, but it sure reduced accidentally changing a perfectly working Node into one that isn't. :slight_smile:

3 Likes

Looks like they found the issue...

1 Like

Trying to set complex arguments for the first time and I'm running into a problem... I'm trying to call setColor() on the LED device for my Inovelli Red Series dimmer switches. It says the arguments should be of the form {"hue":67,"saturation":100,"level":100} and when I put that directly in the arguments of the command node it works... but when I set the msg.arguments to an object with those properties I get this in the logs:

groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object

The current character read is 'o' with an int value of 111
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 1
[object Object]

How do I pass these named arguments if not as an object?

I only have 1 color bulb, and I just specify it in the command node like you show - so I'm not much help. I am sure others on here might do it though, and will chime in.

In your change node do you have your message.arguments set to a "string" or "JSON"? Try setting it to string maybe...

1 Like