Node-RED nodes for hubitat

Thanks @JBrown, I thought I did try that b4 (from your link back to dan.t's reply on the other thread) and didn't work, but it did this time for some reason :man_shrugging:.

I've got a couple follow up questions from here:

  1. this query took about 30 seconds to 1 min before it came out, is that normal? or is that just showing how busy my hubitat is? (don't have that many devices) less than 20 definitely.
  2. how can I extract just the power value from this attribute? I tried using debug on payload.power and that didn't work. I tried parsing it and that still came out with the same payload output. I just wanna aim for certain device then extract the power value from it. if possible.

I get a response in less that a second.
Use the Json node to Change it.

Awesome! you're a life saver, now I can move on with my tinkering :rofl:

I use stopwatch and it took 15 seconds. any idea why i might be taking that long?

Not really, what are you running node-red on? Is your Hubitat hub slow?

I'm running node-red on docker. not sure how to check if my hubitat hub slow as things are switching on and off quite ok.

I'm running node-red on a raspberry pi without docker.

Not very scientific, but reboot your hub and see if it is faster after ...

thanks guys.
I'll give it ago, the reason why I'm thinking that it might be the hub is because when i click the inject/timestamp, the http request has "requesting" under it and stayed there for 15 seconds, then it came up with the payload after it finished.

EDITED: rebooted, same thing on the http request...maybe because it's docker version? :man_shrugging:

How do I inject the currentValue of a device node into a sequence?

One thing I've read about node-red if you use a lot of debug nodes it will slow down.

New version 0.0.17 :tada:

Changes

  • deviceId is now part of the payload message (thank you to @dan.t)
  • topic message property is now set to the node name for device and to hubitat-mode for mode node (thank you to @dan.t)
  • Add a webhook configuration section to make configuration easier
  • New icons for all nodes :sunglasses:
  • Fix a bug where authenticated Node-RED user cannot configure nodes
    • Add a warning to do not expose Node-RED on internet, because the /hubitat/webhook endpoint is not authenticated

Ongoing

  • Review @dan.t PR to support multi Hubitat hub
  • Review @btk PR to set command with flow or global variable
  • I will try to ask to my friend to clean these ugly icons :laughing:
  • Work to authenticate /webhook/hubitat endpoint with specific URL or query string
5 Likes

0.0.17 Works as described so far. Thanks for the continued improvement!!!

Edit: Webhook config didn't work for me. Not sure if it is because I already had Hubitat configured or not but this is what I got when I clicked "Configure webhook":
image

Was I actually supposed to type something in the box? (EDIT: Yes I was.) The text in there, although 'light grey', made me think it would put that in if I didn't type anything else in the box. And that is the correct IP/port of my node-red server.

1 Like

If I understand you, you want to poll a device and inject the current status into a flow?

Yes, that is exactly what I want to do.

Hehe sorry for late reply :sweat_smile:

You need to set the attribute property in the input message of the device node to receive the current value. Otherwise if you want to set temperature with the command node, you can add arguments property to the input message to set the desired value

Can you confirm that topic property solve your issue or you want the real device name (not the node name)?

Yeah, it's only a placeholder and you need to retype the same thing if it's right. I thought it was confusing to use the placeholder for default value, but you prove me wrong :sweat_smile:

Node name is fine with me. Thanks for that - I've already redone a few of my flows and it seems to work well.

No worries. It was pretty obvious that was the next logical thing to do.

1 Like

What type of device is it? I don't know how to poll a device, but you can query Hubitat what it has for the latest status, if that will work for you.

1 Like

Hard to visualize, but maybe take the output from the event, run it through a change node? In the change block do a set msg.payload.x to whatever you want. Note, that adding subvariables to a payload only works if the payload is already in json format. If payload is just a single value, you can't use the change block to add additional subvariables unless you overwrite the whole msg.payload with json.

The other option may be to use a join node.

It's a switch (virtual switch). How do I poll Hubitat?

Here's what happens. I have the output from the switch going through a function node into a Boolean node.

Everytime I re-deploy my flows, the Boolean node "forgets" the state of the switch. So ideally, I need something that saves the state of the switch in the Boolean node.

image

Here I'm doing it manually, but you could do it on a timer, or any other condition you can calculate. The change block sets msg.attribute to "switch".

If you feed a Hubitat event block with a message telling it what attribute to fetch, it will.

Yeah, initialization can be tricky. Can write it to flow/context variables, and the read them back in at startup - but that is kind of a pain. I most often lean towards doing a 1-time manual poll. Basically an inject node set to trigger only once after load.

Like this:
image

Here is the kick-start I use on mode based lighting, to ensure everything is kosher after a restart:
image

1 Like