Node-RED nodes for hubitat

I take the Wifi strength from my Sonoff devices in MQTT and send a command to a virtual Humidity device in HE that sets the humidity equal to the wifi strength. I'm lazy because I should probably create a custom device w/ Wifi strength as an attribute but this works fine.

So.... Battery Level should be easy to pass to a virtual device in HE. I think one-word status should be easy thru the Hubitat Nodes also because you can also send "active" or "inactive" to a motion sensor using a Command node. You can also probably pass a multi-word status but I would bet that sending "Roomba is done" will turn into "Roomba%20is%20done" due to Maker API.

If you were to create your own device driver with the attribute(s) you want, I am 95% sure you could get what you want. Unfortunately, I don't know how to solve the "%20" issue.

1 Like

I was curious from a conversation a few weeks ago about preserving variables across restarts/reboots.... maybe the exact directions are posted elsewhere in this sea of posts on this thread, but I looked at 5-6 posts talking about this without seeing them, so just in case, i wanted to share this link with others

The great thing is setting things up like this with a separate store name is that you don't have to use it, but when you need that extra functionality it's just a matter of adding the store name as a third parameter on the "set" (or second param on the "get")

4 Likes

Thanks I literally tried a virtual humidity device before I saw your reply! That works fine for me.

I'll try the motion sensor route for status messaging, can I send custom messages this way like "Cleaning", "Charging" etc?

Lol love to but already at learning overload at the moment!

Ok, here you go:

Create a Virtual Omni Sensor. It has the ability to store a variable value. Then, in NR, send a command of setVariable and then your argument is a text string.
image
But, I was right, it will add "%20" for blank spaces. If yours are just one word, it should work .

Multi-word status
image

One-word status
image

2 Likes

What do you mean by this? This might be why my "persistant" globals/flows dont seem to be persistant. Do I need to add something in the flow.get // global.get ?

Thanks, that works for me!

If I could ask one more question, how would I inject a custom message into the SetVariable argument? I tried using a change node with Set msg.Arguments to a string but that didn't work. I'm afraid my node-red-fu is still sadly lacking.

EDIT: ignore that, msg.arguments is the correct parameter!

You need to add the filesystem store name if it’s anything other than default

So say you use the exact configuration I posted above:
-- flow.set(“foo”, “bar1”) : saves key/value in default memory based store (this technically assumes “default” as the store name)
— flow,set(“foo”, ”bar2”, “fs”) : saves to the file based “fs”-named store

-- flow.get(“foo”) : tries to pull out of default memory based store (this technically assumes “default” as the store name)
— flow,get(“foo”, “fs”) : tries to pull out of the file based “fs”-named store

In these examples: flow.get(“foo”) !== flow.get(“foo”, “fs”)

That help makes sense?

I’m not too sure how super reliable the filesystem method is as the article mentions :

“We can enable a new way of storing the data in variables. NodeRED v19 can save the data stored in the variables to a local file structure. These are saved automatically every 30 sec. It’s not enabled by default and we have to configure settings.js file to enable this.”

I was running some tests earlier and really couldn’t see the 30 second thing as a problem but I still neeed some more real world testing

3 Likes

I had previously enabled that option in settings.js

Here is a snippet
image

Do I need to update my flow.get//global.get to get from filesystem? Because, I dont think it's getting from filesystem at present, as my globals/flows dont seem to be persistent over a reboot.

I appreciate your help!

1 Like

I probably should go back and look at the prior conversation - but kinda lazy this a.m. and no coffee yet.. so apologies on that.

What kinds of things do you need to preserve across a NR reboot and why? Some sort of accumulation/counts?

The reason I'm asking is because I feel like I'm probably missing out on some useful/important ideas so am curious.

edit: I could see storing things for state recovery maybe for certain complicated/timed sequences..

I just found this simple app in another thread. I could have used this when getting started with NR and the Hubitat Nodes to understand what all of the devices can do. This is a cleaner process than using the HTTP requests in Maker API page.

No, not if you changed the default.

What you should see when using persistent storage is that a directory called "context" in your Node-RED data directory gets filled with files - one for each flow that uses flow variables in persistent storage, and a "global" for all global scoped variables that use persistent storage.

Like this:

That said, I do it like the article @morningz posted, as with slow storage on my RPi storing everything to disk could impact performance, so I use memory for default and only file system when needed.

3 Likes

Thanks, i'm using a Odroid with 16GB eMMC, so I hope I wont have issues. It was spare, I wanted it for something else, and that didnt pan out, so I now use it for Node Red

1 Like

If it's working fine, I wouldn't worry about it.

.
New toy alert, new toy alert!

4 Likes

Oooh. That looks like fun! I need a new toy, too!

Edit: Ouch, kind of pricey. But very cool. Hmm...

Save 5% with code JOINUS. They've run better deals, but that appears to be the current offering.

It's a moderately interesting device. Pretty good for announcements. Someone ported the ST driver to Hubitat. It didn't really work well in my experience. So I pass switches to ST via HubConnect. Node-red should be more flexible.

1 Like

Hubitat is nothing but a way to get devices to show up in Node-RED for me at this point, I didn't look to install anything on HE to make this LaMetric work.

The node setup is pretty straight forward

2 Likes

Woohoo!

  • Maker API: Add evt.type for events (physical/digital)
3 Likes

Dang, I was about to post that and tag you @JasonJoel :grin:

Does @fblackburn have to do anything to his Nodes to make that available?

Yeah, he does, but it is pretty minor (I took a peek when the feature was added to the beta release). All in due time...

I was going to try and make a PR for it, but he is changing so many things in the nodes/making new nodes right now I wasn't sure I could keep up... Lots of commits in the code right now.