Node-RED nodes for hubitat

Looks really nice. Could you send me that function node? It'll be easier than retyping it.

Thanks much!

1 Like

Here ya go!

pylName = msg.payload.name;
pylValue = (msg.payload.value === undefined?"":msg.payload.value);

varName = "vctlDenLights_status";

//flow.set(varName,undefined);

if(!flow.get(varName)){
    initVar = {};
    flow.set(varName,initVar);
}

dict = flow.get(varName);
dict[pylName] = pylValue;
flow.set(varName,dict);

switch( pylName ){
    case "switch":
        msg.command = pylValue;
        break;
    case "hue":
        msg.command = "setHue";
        msg.arguments = pylValue;
        break;

    case "sat":
        msg.command = "setSaturation";
        msg.arguments = pylValue;
        break;

    case "level":
        msg.command = "setLevel";
        msg.arguments = pylValue;
        break;

    case "colorTemperature":
        msg.command = "setColorTemperature";
        msg.arguments = pylValue;
        break;

    case "colorMode":
        break;
}

return msg;
1 Like

I just realized you could probably use the msg.topic for the variable name.. that would make things even more generic.

use this:
varName = msg.topic;

instead of this:
varName = "vctlDenLights_status";

Then its just a matter of grabbing the flow dict obj

dictObj = flow.get(msg.topic)

and referencing the values as needed

dictObj["switch"]
dictObj["colorMode"]
dictObj["colorTemperature"]
dictObj["level"]
dictObj["hue"]
dictObj["sat"]

1 Like

@fblackburn
If I can just make one TINY suggestion....something to include in the first post to help new folks. A breakdown of how the message that gets passed from node to node is built would be helpful. I tried setting this up for the first time yesterday and worked for almost an hour to try and get two switches to sync with each other. One goes on the other goes on and vice versa. Simplest thing I could think of to try first, right? Well....at least that was what I thought...an hour later I wasn't so sure I was ever going to get it to work. By dumb luck I happened to realize that you have to use msg.payload.value to get the "on" or "off" to react to. Then I finally got it to work. Obviously makes 100% sense now. But I'm not a programmer so it wasn't entirely evident at first. So, just a couple of sentences on how the event and device objects get translated into the payload would be a huge help to new folks I think. And might help someone else avoid the headache I had yesterday. It just one of those simple things that you don't realize while your hip-deep in trying to get something this complicated set up. I thought it was my setup in some way.
:man_facepalming:
:point_up_2: me

And thanks for sucking all of my time up for the foreseeable future! I get a half-way decent handle on Groovy and now this comes along, forcing me to learn something else new! :wink: jk

Seriously though...thanks. Amazing job. I can see this opening up a huge world of possibilities given the scope of node red and the things it can interact with.

3 Likes

A big fish = hooked!

Thanks a bunch!

1 Like

This is the biggest challenge with almost EVERY new node palette that I have installed. You will find quickly that a Debug Node will become your new best friend. I suggest you always set it up as a complete msg object in you case you didn't already know that was an option:
image

Also, I know you don't like those Home Depot remotes and you only have 1 but with help here I was able to get them working locally so they are fast now using a SmartThings Node. It doesn't make them any better looking. :grinning:

If you were able to learn even some Groovy, I bet you will get this quickly.

Good luck! The crew active on this thread have been great.

1 Like

BTW, when you click on the node in NR, there is usually a pretty good description available in the "info" view:


This is not only true for this plugin, but most of them maintain this.
The info view is the on the right side bar. It might be that you have to click the little i button in the top right corner

image

This is pretty helpful as every node plugin does things differently

Well, then an explanation of where to find that would be helpful in the first post. None of this will help me now....I figured it out. I mention this so that folks who try this later could figure this out.

That's all Node Red documentation and @JasonJoel shared this earlier in this long thread: Documentation : Node-RED

1 Like

Sorry, that link doesn't do much for what Hubitat nodes are looking for

That has easily been my biggest struggle going to NR, and I am a Web Developer for 60 hours a week, so I know my way around JS and Node

I thought @Ryan780 as asking about explanation for the right column in general for Node Red, not Hubitat Nodes specifically.

What I was asking for, I thought pretty clearly, as an explanation of how the event and device objects are translated in to the message. That's all. Not some long 20 min or 10 page explanation. Just a sentence or two to describe that if you would normally look for event.value, you would look for msg.payload.value. That's all.

I, and i suspect a large number of people who will be trying this, have never used node-red before. While that might seem intuitive to you, it certainly wasn't to me. And I'm not some layman off the street either. So, if I could miss it, I guarantee someone else will not realize it either. And asking someone to read this whole 1500 post thread is a little unreasonable.

But hey...it was just an idea. You don't have to do anything.

msg.command = "on/off/etc" = your friend!

Thank you for your feedback, it's really appreciated.
I edited the first post to include a warning section for those who have never used node-red before. I redirect them to Node-RED tutorials :laughing:
I hope it will help next readers

Honestly I don't like to copy/paste the result into documentation. Because code can change and the documentation can be out of date. For this reason, I prefer recommending debug node usage

Firstly, I wrote this post to only share the hubitat module for those who already used Node-RED. But it interested many more people who were not using Node-RED (but how to do not falling for the beautiful screenshots/result). Which is really nice :grin:

2 Likes

How would that help understand the question that I asked? event.value =msg.payload.value? That's in the Node-Red tutorials? You'd think I was asking for the library of congress over here. The doc is already generated....@dan.t showed it. A simple pointer to that would work. I really don't get this pushback. We've spent more time talking about it than it would have taken for me to write a dissertation on the topic at this point.

The first tutorial explains how to use debug node and the debug node will show you the message

1 Like

Clearly you don't want feedback. Noted.

Please refer to your comments made in this post. It's time to stop now. This dialogue is going nowhere. Please stay on track.

6 Likes

The node-red tutorials show the end user how to look at any message using a debug node. That is all you need for any node-red node to understand what the output is, and is fundamental to node-red.

I do understand what you are asking for. But I believe the author is saying that the output is self-documenting by looking at the output in a debug node. Maybe that could be made clearer in the OP somehow, but nothing obvious is coming to mind.

So it isn't that he doesn't want feedback, in fact he has made many changes based on user feedback, it is that he disagrees with you that it needs to be documented in the OP.

And, for the record, he DID take your feedback and subsequently made a change to the OP. Just not the exact change you wanted. :man_shrugging:

EDIT: Oops, that was redundant with what @fblackburn said.

2 Likes