QNAP NAS Integrations for UPS Monitoring, NodeRed, Home Bridge, etc

For those of you with a NAS, especially QNAP brand, I wanted to share ways that I am utilizing my NAS for various integrations. I don't have any familiarity with other NAS brands like Synology but I understand that many support Docker containers so these may be possible on those devices as well. Feel free to comment with other ways you are using your NAS for HE integrations.

  • UPS Integration - I have a UPS connected via USB to my NAS. When power outages occur, I wanted the ability to automate shutting down of devices within my home via my Web Power Switch as well as shut down my multiple HE hubs gracefully. This integration polls the QNAP NUT Server for status on a set interval. Huge thank you to @guyeeba for posting a RPi driver on the community that inspired me to create my own version for use with my NAS and @stephack for helping me test this driver! You can find the driver code and instructions here:
    NUT-UPS-Monitor/README.md at master · HubitatCommunity/NUT-UPS-Monitor · GitHub
  • Container Station Containers:
    • NodeRed - there are several posts on this Community on how to setup NodeRed on RPis such as this one but via Container Station, I downloaded the NodeRed image from Github and utilize that.
      • Every night at 4 AM a flow downloads the HE backups of my 3 hubs and puts it in a folder on my NAS. Export of this flow can be found here.
        • When setting up your NodeRed container be sure to create a Shared Folder so that NodeRed has access to upload the files:
      • Connection to the HE web socket to log events into InfluxDB and Grafana as well as SQL server
      • Monitor Performance of hubs which you can read more about in this thread. That solution was checking the installed apps page which didn't work for me because the number of apps varies greatly from hub to hub. I instead use how long it takes to load the System Events list.
      • Query my QNAP MySQL database once a day to check if a battery powered device hasn't updated in the last 24 hours and if one found send me a notification. Since I am logging all event data in MySQL, I have a "devices" table with a last updated timestamp that I keep updated based on events being inserted.
    • Homebridge - allows me to control devices via Apple HomeKit thanks to @dan.t's awesome plugin
    • InfluxDB - database for NodeRed
    • Grafana - visualization engine of InfluxDB data
    • NodeJS - runs @gabriele's code to update the Alexa cookie with @ogiewon's Alexa TTS Manager

I am happy to answer any questions you may have but I wanted to foster ideas on how to better utilize features on your NAS.

11 Likes

@ritchierich, I'm glad you decided to share this. I have it installed on my Dev hub and use it together with RM to shutdown my main hub if I have an extended power outage and the battery falls below 30%. Works perfectly as designed.

Unfortunately my Qnap does not support Container Station but I'm looking to upgrade as soon as I can gather the funds. Then I can move the NR instance, influxdb and Grafana from my win10 box to my Nas.

1 Like

I have a QNAP NAS and I’m struggling to get Node.JS in container station up and running. Do you have any step by step instruction on how you managed to get this working for use with the Alexa TTS that Id like to convert over too?

FYI I have the 453 with added ram sticks.

I have a 451 with added ram - 8GB I believe

I went to ContainerStation

  • Clicked Create
  • Search for "node"
  • This is the image I am personally using.
  • Then from a setup perspective I followed @gabriele's instructions in GitHub on deploying the code to the docker container.
  • Once you install the container you can click into it and then the terminal button, enter /bin/sh to setup the AlexaCookie code

Awesome, thanks for sharing!

I’m running homebridge in a docker container, but have been meaning to look into integrating the UPS I recently bought. I might want to give NodeRed a try as well for the scheduled backups and to visualize some data graphically.

1 Like

If a UPS is connected to a QNAP NAS via USB, is there a way to automate shutting down a windows 10 PC as well if the power goes out and the NAS switches to battery?

There is a program called "winnut" that you can install on the windows box and then set it up as another IP within QNAP to talk to. The winnut code is very old but it still works on one of my PCs. Here is a very old post of mine on the QNAP forum with some details:
https://forum.qnap.com/viewtopic.php?t=33248

Then search using your favorite engine for "winnut" to download the program. I believe I am using this one:
https://code.google.com/archive/p/winnut/downloads

Edit, there are third party programs that you can install as well that HE could potentially call to shut it down such as the first item in this list:

1 Like

What ports are you using for Node.JS? 81 and 82 didn’t work for me.

Typically when I need to configure something within the docker container I use bridge mode and set a static IP. Here are my container network settings:

Which version of Nodejs are you running? I've got 12.4.0 successfully setup but I'm having cookie issues and can't get the AlexaTTS setup to work. I keep getting an invalid cookie message notification from Hubitat :frowning: Just want to rule out it's not a version problem I'm having.

Version 9, see screenshot above for details on exact image I chose. Re version/install problem you may want to post a question in that other thread and maybe folks more familiar with Node may help. Unfortunately I don’t know a ton about it and was lucky to get it working. :grin:

Would this be the right rule (rm3) to get the HE to shutdown?

Question though if the UPS still has power once the HE shuts down.. wont it just start back up again ?

If you look at the second post in this thread, it shows my RM setup. I included a second condition that also checks if the UPS is on mains or battery power. If the battery is on mains (restoring charge), it won't shut down.

Also keep in mind, I'm sending the shutdown command from my Dev hub to my Main hub. If you are sending the shutdown command To and From the same hub (it's shutting itself down) you would need to use a different port. I use port 8080 and others have reported success with port 8081....so you command would be:
http://ipaddress:8080/hub/shutdown

The HE hub will only start itself back after power has been removed and readded...if you unplug the power cable and reinsert OR the ups battery completely drains and then power is restored.

3 Likes

Hey @stephack - what is the condition you choose to get "power source" ?
Thanks for the heads up re the correct IP address, appreciate your help.

That Rule was made using RM 3.0. I haven't used 4.0 yet so I don't know if there is a difference.
I simply chose "power source" as the capability.

yeah, mine is a 3.0 as well but doesnt list "power source" as an option.
@bravenel - was power source removed as a rule 3.0 option ?

No, 3.0 has Power Source.

1 Like

I love my QNAP. I use containers for Node-red for Harmony Hub programming and backups and whatever else I can come up with, Node.js running Cast-web API for all my Google Home, Chromecast devices, etc., and SmartThings Node Proxy for integration with my Honeywell alarm system. I also have, at any given time, a couple of other docker containers running for testing this or that.

A couple of pointers, since we're talking about this stuff:

I used to do the bridge mode, too, on my containers, but there are issues with that I didn't care for. What I do now (and it works fantastically) is just use Host mode for my containers. That way, whatever I'm creating will just be the IP(s) of my NAS: port.

So...
Node-red is 192.168.xx.46:1880
Cast-web is 192.168.xx.46:3000
ST Node Proxy is 192.168.xx.46:1337

Makes it clean and easy to remember. Now, sure, there are situations where there COULD be port clashes, but most of the things we're relegating to containers really only have simple (and configurable) port requirements, so this simplifies things down to basically only needing to remember the port number. Anyway, even if something changes and you need to put a container on another IP, that's THE ONE SETTING you can change in container station after the container has been created. Just throwing it out there.

AS FOR THAT PART about not being able to change things after the container has been created: That's a really weak spot for Container station, and requires you to get all the variables right at creation time, in regard to commands, entry points, etc. I've found and LIVE BY this article that lays out a really great system for the creation of containers that allows you to ACCESS LOCAL SHARES on the QNAP from inside your containers. This is huge, because it means that, in my Node-red container, I can tell my automated backup flow to save the files to /HomeAutomation/HubitatBackups, where it will be available on my Windows laptop from a mounted network share. If you don't create the container with those mount points at creation time, you will never ever be able to access those folders from within. On the flip side of it, setting up my ST Node Proxy, I made sure the container had access to my /HomeAutomation folder, and I just downloaded the Github repo on my laptop directly into that folder, unzipped within Windows explorer, cleaned it up, work locally with the JSON files on a web program, save them, move files, plugins, etc. around all within Windows explorer. If my container didn't have access to the shares on the QNAP, I'd have to be doing all that in the terminal. No thanks. (I know, I know...but no thanks)

Hope any of this was helpful! I love my QNAP. I have a 563 with upgraded RAM. :slight_smile:

5 Likes

Hey @bravenel - its not listed under conditions here in 3.0