Node-RED nodes for hubitat

I am confused on your description of your setup. I have 3 hubs so I have a Maker API instance for each. In my case, it added an "_" to the 2nd instance I setup and a "__" to the 3rd instance automatically. What confuses me about your description is that you are talking about the underscores being added for each node. You should only be seeing the webhook information in the single Config Node that you have per instance of Maker API. When adding any of the Hubitat nodes to your flow, you simply choose that Server which will then give you a list of your devices you have allowed in Maker API.

This is the Config Node for the 3rd instance of Maker API that I setup. Note the 2 underscores at end.
image

When I want to add a Device Node to a flow for a device on that hub, I just choose the existing Server and the select device from drop-down below it.
image

It sounds like you are trying to create a different server for every Hubitat node you create but that is not necessary.

Am I completely misunderstanding what you have done?

Ah maybe that is part of the issue! You only need one configuration per hub.. also you can set the webhook address to be whatever you want.. you do not have to leave an underscore if you don't want to - see my C-5 net config below

Edit your configurations and remove all the configs except the first one. Then as @stephen_nutt says in your devices nodes see if you can't select multiple ones..

Note: If you have more than one hub like I do then it's better to name the webhook link something more manageable like this:

@erktrek and @stephen_nutt

I will check my configuration when I get home tonight. Thank-you !

1 Like

Okay! :crossed_fingers: - Let us know how it works out. I've always configured the settings in Maker API first then Node-RED.

Although it isn't difficult to look in Hubitat for the device ID when needed in node-red, I thought I just put together a node-red table that shows the device id, device label and device type. Click the refresh button when ever you make changes to you API.
This is one of those things that doesn't need to exist but it does, lol.... :smiley:

[{"id":"84be7bf5.82d088","type":"http request","z":"e2a712f7.92277","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://192.168.109.###/apps/api/305/devices?access_token=[actual token]","tls":"","persist":false,"proxy":"","authType":"","x":370,"y":1380,"wires":[["5148076a84dcf4fb"]]},{"id":"5148076a84dcf4fb","type":"ui_table","z":"e2a712f7.92277","group":"24b0a419.20986c","name":"HDI","order":1,"width":15,"height":13,"columns":[{"field":"id","title":"ID","width":"8%","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"name","title":"Device Name","width":"25%","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"label","title":"Device Label","width":"30%","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"type","title":"Device Type","width":"35%","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}}],"outputs":1,"cts":true,"x":530,"y":1380,"wires":[[]]},{"id":"177fa7ab69607d37","type":"ui_button","z":"e2a712f7.92277","name":"","group":"24b0a419.20986c","order":2,"width":15,"height":1,"passthru":false,"label":"Update HDI","tooltip":"If you added a new devide click refresh it identify the ID","color":"","bgcolor":"green","icon":"fa-refresh fa-spin fa-1x fa-fw","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":210,"y":1380,"wires":[["84be7bf5.82d088"]]},{"id":"24b0a419.20986c","type":"ui_group","name":"HDI","tab":"a169fb7.ae6ec08","order":1,"disp":true,"width":"15","collapse":false},{"id":"a169fb7.ae6ec08","type":"ui_tab","name":"Hubitat Device IDs","icon":"fa-map","order":12,"disabled":false,"hidden":false}]

3 Likes

Thank-you @erktrek and @stephen_nutt for the help. I hadn't realized that you just need one config for all of the nodes. I can't believe I didn't realise that.

Everything works now.

Thanks again.

Yannick

2 Likes

In a function node, how would I return a message that has data in msg.payload and msg.payload.value

return {topic: 'Garage', payload:'open'} works well.
return {topic: 'Garage', payload: {value: 'open'}} works well.

But how to do msg.payload and msg.payload.value in the same function node?

You can't really have a payload with a datatype (ex String) as well as an object. You could probably do it with an array, but your notation following it would still be different than just msg.payload. It would be msg.payload[0] and msg.payload[1].value.

As @erktrek alluded to, you'd have to have two msg objects.

3 Likes

Removed my prior post due to insanity (apologies)... here is the JSON array that @harold.min is talking about and is probably the best answer:

var retMsg = {
    "payload": [
        "somedata",
        { "value": "somedata" }
    ]
}

return retMsg;

The "jaggedness" kind of weirds me out a little but it works fine.

2 Likes

Yuck, I don't like that at all. I hate root values + arrays in the same object.

BUT, it will work / is technically correct (I think... lol...).

2 Likes

I personally liked @erktrek's double msg solution, but, you know... options.

1 Like

I would have just made two objects in the payload array. But 2 messages works too!

Too many options.

3 Likes

It does - just tested. I like this one a little better..

var retMsg = [
    {
        "payload": "somedata"
    },
    { 
        "payload": {"value": "somedata"}
    }
]
2 Likes

In a completely different direction for @mike ...

Since I have a Zooz relay for my garage, I just used their awesome HE app and added that virtual device to maker... I believe you could use this one for other setups.

:slight_smile:

1 Like

Hey. How do we do a node-RED configuration for Hubitat if we are hosting node-RED on an oracle server, and not locally?
I think this is the root of all my issues trying to get it to work.

Thanks @erktrek, @harold.min, @JasonJoel

I now realise that what I was trying to do was dumb, and just bit the bullet and changed all my node rules to msg.payload, rather than having some with msg.payload.value It only took 5 minutes, rather than the inordinate amount of time I spend attempting to complicate things with arrays and objects and incompatible data types. Thanks for all the help. It did improve my understanding of Javascript.

3 Likes

Any reason why you're hosting it in the cloud? I mean... one of the big benefits of using Hubitat is keeping as much as you can local.

If possible, I'd just bite the bullet, get a Raspberry Pi and throw NR on it.

2 Likes

Nah, not dumb at all. Just different than typical. There are lots of ways to do everything in computer-land. :slight_smile:

1 Like

Yeah but the atypical or clever stuff really bites you in the a** a few months or years down the line when you have to revisit it and can't remember why you took that approach.. Of course that's usually true with most of my prior code sadly... :rofl:

3 Likes

Months or years? I’m lucky if I can manage days and hours.

I’m pretty good with minutes though. :grin:

2 Likes