HowTo: NodeRed – Read UPS status

One of those vulnerabilities of a smart home system that only really becomes aware of when things go wrong is “energy”. Unfortunately, all the sensors, actuators and the controlling intelligence are not running with air and love. And even if the energy used by the system is not very high and in general the savings are certainly higher than the “used up” energy, the energy supply is essential. Say: No power-> no SmartHome.

But that is first to share a luxury problem you could live with. Much worse, I think the idea that my RaspberryPi or any computer could swallow so much by a sudden power outage that it may not boot afterwards.
Because your SmartHome system (RaspberryPi, BeagleBone, Windows PC, etc ..) interrupted just in the moment in which he writes important (system) data so it is possible that this does not start up properly after restoring the power. In extreme cases, this leads to painful data loss and thus often to a high loss of time. Because in extreme cases you do not have a backup of the system and then have to re-install and configure the complete system including all system components.

But: In fact, other people seem to have stumbled on this problem. Namely, uninterruptible power supplies (UPSs) were invented for this case. These devices are switched between the socket and the consumer (in this case your RaspberryPi, etc.) And monitor from then on the quality of your mains voltage. It is continuously monitored whether the incoming AC voltage and the frequency are in the allowable range. If there is a low or high voltage, or something else is wrong with the supply voltage, the UPS switches off the voltage input within milliseconds and switches over to an internal buffer battery. This then takes over the supply of the connected consumers until the buffer battery is empty.

UPS’s are now in all sorts of forms. The smallest look like something bulky Multisocket. Others – or their batteries – can fill a complete room.

For the normal SmartHome user certainly the smaller variants are sufficient.

How to integrate your own UPS into NodeRed and react to changes is explained in this article.

Hints for our lovely english readers: Basically, many of the articles on Nerdiy.de are translations from the original german articles. Therefore, it may happen here and there that some illustrations are not available in english and that some translations are weird/strange/full of mistakes or generally totaly wrong. So if you find some obvious (or also not obvious) mistakes don't hesitate to leave us a hint about that in the comment section. 
Also please don't get confused, that instead of a "dot" often a "comma" is used as decimal separator. 🙂


Safety instructions

I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/sicherheitshinweise/


Requirements

Helpful Articles:
In order to be able to control / configure your UPS via your RaspberryPi and NodeRed this should of course be prepared so that NodeRed runs on it and you can access it via SSH.
RaspberryPi – Setting up for Nerdiys!
RaspberryPi – The First Configuration!
RaspberryPi – Control the RaspberryPi via SSH
NodeRed – Installing NodeRed on the RaspberryPi
NodeRed – import and export Node code
NodeRed – Pushbullet Send messages at events
NodeRed – Create a UI with dashboard nodes

Required material:

In the following list you will find all the parts you need to implement this article.


Reading out a UPS connected to the RaspberryPi

The downside of having an uninterruptible power supply is that the RaspberryPi will not notice anything as soon as something goes wrong with the power supply. Actually, it is so desired. On the other hand, the RaspberryPi can not react to this change.

Because even if the battery of a UPS in comparison to the consumption of a RaspberryPi’s quite lush: The battery capacity is finite. Therefore, the RaspberryPi should shut down automatically, for example, before the battery is completely exhausted. This minimizes the risk of data loss and allows you to react in a controlled manner to the power failure.

In order for the RasperryPi to be informed of changes to the UPS, it must be connected to the RasperryPi via a USB or serial connection.

For the RaspberryPi there is the program “Apcupsd”, which allows you to read the status of your UPS. You can also use this status to react to it via NodeRed.

For example, it would be possible to shut down certain components as well or shut down other RaspberryPi’s – insofar as they did not fail due to the power failure.

However, before you can read out the status of your UPS in NodeRed, you must first install “apcupsd”.


Log in via SSH on the RaspberryPi

To get started, you first need to log in to RasPi with SSH on Putty. How to do it is described in the article RaspberryPi - Controlling the RaspberryPi via SSH.

After entering your username and password you can start to enter the first commands.

Update package management

The package management in Linux is a "central point" over which various software packages can be installed. For this to work reliably, the lists and sources of package management should be updated before installing any new packages.

To start the package management update you have to enter the following command.
sudo apt-get update && sudo apt-get upgrade
Depending on how long your last update of the package management is, this process can take some time. First, the lists are updated in which the individual repositories are referenced.
Then the packages themselves are updated. As this additional memory is occupied, you will again asked for your consent. You have to confirm this with a "J"(in German) or a "Y" and "Enter".
When the update is complete, you will see a small summary of the duration and scope of the update.

Install “apcupsd” on the RaspberryPi

So that your RaspberryPi can communicate with the connected UPS, you must first install a few packages.

A program that can communicate directly with your USB-connected UPS is the program “apcupsd”, which you install with the following command.
sudo apt-get install apcupsd
Any requests that the program uses additional memory will be confirmed with “Y”.
The installation takes about two minutes.

Configure Apcupsd

Of course, before you can use “apcupsd”, this must first be configured. This requires a few configuration files to be edited.

The first configuration file opens with the following command.
sudo nano /etc/apcupsd/apcupsd.conf
In the open configuration file you must now first with the arrow keys …
… navigate to the displayed line. It determines which type of cable the UPS is connected to your RaspberryPi. Most likely, your UPS is connected to your RaspberryPi via the USB port. That’s why you also set “UPSCABLE usb” here.
UPSCABLE usb
Since you have a USB cable connected, you must of course also set the UPSTYPE to usb.
UPSTYPE usb
So that the connection to the UPS via USB works, you must now edit the parameter “DEVICE”. This can not be assigned a value. Remove the pictured part “/dev/ttsyS0” next to “DEVICE”.
This should look like this.
Now you can make a few settings on how apcupsd should behave in the event of a power failure. For example, the parameter “BATTERYLEVEL 5” can be used to shut down the RaspberryPi at a left battery capacity of 5%.
The parameter “MINUTES” indicates at which residual time in minutes the RaspberryPi should be shut down.
With the parameter “NETSERVER” you can activate a Server, which provides the information of the UPS over the network. In this way, other network subscribers can also react to them and shut down, for example, in the event of a power failure. To activate the network server you have to set the parameter to “NETSERVER on”.
With the parameter “NISIP” you can set to which IP address the server “hears”. This is only necessary if you have more than one network interface on the system in question. For example, on a RaspberryPi you could set it to ask the server to answer only requests that it receives via the WiFi interface and not over the LAN interface. In most cases, you can set this parameter to “NISIP 0.0.0.0”. This means that all requests, regardless of the network interface, will be answered.
The parameter “NISPORT” defines the port under which the information of the server can be retrieved. You should leave this unchanged at the value “3551”.
You then save this configuration by pressing “CTRL-X” and “J”(or “Y”) …
… and “Enter”.
Now you have to tell apcupsd that there is a configuration. Open another configuration file with the following command.
sudo nano /etc/default/apcupsd
Sets the parameter “ISCONFIGURED” to …
…”yes”.
You save this configuration again by pressing “CTRL-X” and “J”(or “Y”) …
… and “Enter”.
The apcupsd service can then be started with the following command.
sudo /etc/init.d/apcupsd start
If the program is successfully started then it should look like this.
The command “apcaccess status” then displays the current status of the UPS. If no connection to the UPS can be made the answer looks as shown.
apcaccess status
In case the connection to the UPS is established and the information can be read out, the displayed information will be displayed.
In case you have to restart “apcupsd”, you have to enter the following command.
sudo /etc/init.d/apcupsd restart

So you already have the possibility to display the information of the UPS on the RaspberryPi. To use this information for your SmartHome you can use the following NodeCode.


Import NodeCode

With the following NodeCode you can see some details of the current status of your UPS. So you can react individually to certain properties.

For example, it would be possible to notify you via a bulletin message about a power outage or, as shown in the example below, display the most important data on the dashboard. Of course, to be able to send Pushbullet messages in the event of a power failure, you should ensure that your entire network infrastructure is also protected by the UPS. Of course, if the power failure is very large, it will not help either. Therefore, communication over the Internet in the event of a power failure is of course not guaranteed.

How to import your NodeCode into your NodeRed configuration is described in the article NodeRed – Importing and Exporting Node Code. After importing, you may also have to configure the pushbullet node. You can find information on this in the article NodeRed – Pushbullet Send messages to events. Dashboard nodes are used to display the UPS data. You can find information on this in the article NodeRed – Create a User Interface with Dashboard Nodes.

View of the UPS status indicator in the dashboard.
Overview of the NodeCode configuration in the NodeRed configuration interface.
[{"id":"e2a1a48.9207858","type":"exec","z":"8c9f8f17.13eb78","command":"/sbin/apcaccess","append":"","useSpawn":"","name":"apcaccess","x":390,"y":1740,"wires":[["c5f64040.b7a32","9ef1333b.1cf96"],[],[]]},{"id":"ebe2e46e.660788","type":"inject","z":"8c9f8f17.13eb78","name":"status request","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":200,"y":1740,"wires":[["e2a1a48.9207858"]]},{"id":"c5f64040.b7a32","type":"trigger","z":"8c9f8f17.13eb78","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"1","extend":true,"units":"min","reset":"","bytopic":"all","name":"status","x":570,"y":1700,"wires":[["c65a87d0.d60ef8"]]},{"id":"c65a87d0.d60ef8","type":"change","z":"8c9f8f17.13eb78","name":"","rules":[{"t":"change","p":"topic","pt":"msg","from":"^(.*)$","fromt":"re","to":"online","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":1700,"wires":[["e9c65962.f1bd98"]]},{"id":"9ef1333b.1cf96","type":"function","z":"8c9f8f17.13eb78","name":"convert2Json","func":"const ans = {}\n\nArray.prototype.map.call( msg.payload.trim().split(\"\\n\"), function(line) \n{\n    if ( line.trim() === '' ) return\n    let part = line.split(':')\n    // Some values contain ':', when they do, we have to rejoin\n    if ( part.length > 2 ) {\n        let newPart = []\n        newPart.push( part.shift() )\n        newPart.push( part.join(':') )\n        part = newPart\n    }\n    \n    let payloadName = part[0].toLowerCase().trim()\n    let payloadValue = part[1].trim()\n    ans[payloadName] = payloadValue\n    return\n    \n} )\n\nmsg.payload = ans\n\nreturn msg","outputs":1,"noerr":0,"x":600,"y":1760,"wires":[["7177d00d.0f8c1","f49b6561.709b18","9cd3b15b.3aa0a","cbdff947.6252f8","9a68559b.2e0408","a998a9f0.b4c2f8","cbb1400b.8107f","4db0abb3.948d94"]]},{"id":"e9c65962.f1bd98","type":"debug","z":"8c9f8f17.13eb78","name":"online/offline-Status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":980,"y":1700,"wires":[]},{"id":"7177d00d.0f8c1","type":"debug","z":"8c9f8f17.13eb78","name":"Data as JSON payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":840,"y":1760,"wires":[]},{"id":"90dd24c3.50c968","type":"ui_gauge","z":"8c9f8f17.13eb78","name":"Battery charge","group":"c8fbbc62.c288a","order":4,"width":0,"height":0,"gtype":"gage","title":"Battery charge:","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#ca3838","#e6e600","#00b500"],"seg1":"","seg2":"","x":1080,"y":1800,"wires":[]},{"id":"4b7d84af.22ddfc","type":"ui_gauge","z":"8c9f8f17.13eb78","name":"Batterie-Temperature","group":"c8fbbc62.c288a","order":5,"width":0,"height":0,"gtype":"gage","title":"Batterie-Temperature:","label":"°C","format":"{{value}}","min":"20","max":"40","colors":["#00b500","#00b500","#ca3838"],"seg1":"","seg2":"","x":1100,"y":1840,"wires":[]},{"id":"c655e83c.23f538","type":"ui_gauge","z":"8c9f8f17.13eb78","name":"Batterie-Voltage","group":"c8fbbc62.c288a","order":6,"width":0,"height":0,"gtype":"gage","title":"Batterie-Voltage:","label":"V","format":"{{value}}","min":"11","max":"15","colors":["#ca3838","#00b500","#ca3838"],"seg1":"","seg2":"","x":1080,"y":1880,"wires":[]},{"id":"3ce99364.46890c","type":"ui_gauge","z":"8c9f8f17.13eb78","name":"Mains voltage","group":"c8fbbc62.c288a","order":7,"width":0,"height":0,"gtype":"gage","title":"Mains voltage:","label":"V","format":"{{value}}","min":"220","max":"240","colors":["#ca3838","#00b500","#ca3838"],"seg1":"","seg2":"","x":1080,"y":1920,"wires":[]},{"id":"810aaaf7.ec4f48","type":"ui_text","z":"8c9f8f17.13eb78","group":"c8fbbc62.c288a","order":1,"width":0,"height":0,"name":"Status","label":"Status:","format":"{{msg.payload}}","layout":"row-spread","x":1050,"y":1960,"wires":[]},{"id":"f49b6561.709b18","type":"change","z":"8c9f8f17.13eb78","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.bcharge","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":1800,"wires":[["90dd24c3.50c968"]]},{"id":"9cd3b15b.3aa0a","type":"change","z":"8c9f8f17.13eb78","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.itemp","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":1840,"wires":[["4b7d84af.22ddfc"]]},{"id":"cbdff947.6252f8","type":"change","z":"8c9f8f17.13eb78","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.battv","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":1880,"wires":[["c655e83c.23f538"]]},{"id":"9a68559b.2e0408","type":"change","z":"8c9f8f17.13eb78","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.linev","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":1920,"wires":[["3ce99364.46890c"]]},{"id":"a998a9f0.b4c2f8","type":"change","z":"8c9f8f17.13eb78","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.status","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":1960,"wires":[["810aaaf7.ec4f48"]]},{"id":"5f70becf.c02b8","type":"ui_text","z":"8c9f8f17.13eb78","group":"c8fbbc62.c288a","order":2,"width":0,"height":0,"name":"Last Update","label":"Last Update:","format":"{{msg.payload}}","layout":"row-spread","x":1070,"y":2000,"wires":[]},{"id":"cbb1400b.8107f","type":"function","z":"8c9f8f17.13eb78","name":"","func":"msg.payload=Date(Date.now());\nreturn msg;","outputs":1,"noerr":0,"x":790,"y":2000,"wires":[["5f70becf.c02b8"]]},{"id":"4db0abb3.948d94","type":"function","z":"8c9f8f17.13eb78","name":"","func":"if (msg.payload.linev<=100)\n{\n    msg.payload=\"Power failure: UPS-Mains-voltage below 100V!\";\n    return msg;\n}","outputs":1,"noerr":0,"x":790,"y":2040,"wires":[["f62fd4e0.66c8b8"]]},{"id":"f62fd4e0.66c8b8","type":"pushbullet","z":"8c9f8f17.13eb78","config":"e3daf163.eeb16","pushtype":"note","title":"SmartHome","chan":"","name":"","x":1070,"y":2040,"wires":[]},{"id":"622137c.74419c8","type":"inject","z":"8c9f8f17.13eb78","name":"Test Power failure","topic":"","payload":"60","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":410,"y":2040,"wires":[["4f72d77f.af5ee8"]]},{"id":"4f72d77f.af5ee8","type":"change","z":"8c9f8f17.13eb78","name":"","rules":[{"t":"set","p":"temp","pt":"flow","to":"payload","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.linev","pt":"msg","to":"temp","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":2040,"wires":[["4db0abb3.948d94"]]},{"id":"c8fbbc62.c288a","type":"ui_group","z":"","name":"USV2","tab":"4719e8d9.2a46f8","disp":true,"width":"6","collapse":false},{"id":"e3daf163.eeb16","type":"pushbullet-config","z":"","name":"FabsPushbullet"},{"id":"4719e8d9.2a46f8","type":"ui_tab","z":"","name":"Einstellungen","icon":"dashboard"}]

Reading a UPS connected to a Synology NAS

If you own a Synology NAS or NAS in general, data loss is even more important. After all, should the family photos (or a part of it) in a power outage not disappear to the data nirvana. Because of this, many manufacturers offer the function of protecting their own NAS from power failure with a UPS. The UPS is then also connected via USB to the NAS to inform about a status change. Should a power failure occur, the NAS detects this and shuts down automatically and in a controlled manner. Practical and good for the data stored on the NAS. At the same time, it is impractical that the other network participants are not aware of the situation (except that the power has failed).

At least the Synology NAS offer a solution: An integrated network UPS server can also be used by other network participants to record the status of the UPS connected to the NAS. So you can finally capture the status on the RaspberryPi and thus also in NodeRed.

For the network UPS server to work, it must first be set up. Go to the Control Panel of the DiskStationManager (DSM) interface ...
... and the category "Hardware & Energy". There you click on the index card "UPS".
There, the connected UPS should already be configured. In this case, the NAS automatically shuts down after 3 minutes of power failure. In order to activate the network UPS server, check "Activate network UPS server" and click on the button "Allowed DiskStation devices".
In the window that opens, you can enter several IP addresses of devices in your network that are allowed to access the information of the network UPS server. This so-called "whitelist" procedure ensures that only authorized network subscribers can receive this information. In this field you enter as shown the IP address of your RaspberryPi's from which you want to read the UPS status via NodeRed. How to find out the IP address of the devices in your network is described in the article "Displaying / finding the IP address of the devices in the network". Did you enter the IP address click on "OK" ...
... and in the following window on "Apply".

Install the NetworkUpsTools (NUT) on the RaspberryPi to retrieve UPS data from a UPS server

Now that the server is set up to provide the UPS information, of course, the client side (ie your RaspberryPi) must be configured accordingly. Because, this must also be able to contact the network UPS server on your NAS record. A program that allows this is the "NetworkUpsTool", which can be installed as follows.

To install the NUT application, enter the following command.
sudo aptitude install nut

Note: For the installation of "NUT" you need the extension "aptitude" for the package management "APT". This can be installed - if not already available - with the following command.

sudo apt-get install aptitude
Any questions during the installation you confirm with a "y" and "Enter". In most cases (as in this example), these questions relate to whether additional space is to be allocated by the tools to be installed and whether additional (required) packages may also be installed.
After installation, "NUT" must be configured. To do this, open the configuration file with the following command.
sudo nano /etc/nut/nut.conf
In the open configuration file, navigate with the arrow keys to the displayed line.
Once there, you change the line from "Mode = none" to "Mode = netclient". This part of "NUT" states that it should act as a network client for a network UPS server.
Mode=netclient
You save this configuration by pressing "CTRL-X" and "J" (or "Y")...
... and finally on "Enter".
Now of course you have to configure under which address the network UPS server can be reached. To do this, open another configuration file with the following command.
sudo nano /etc/nut/upsmon.conf
Then navigate with the arrow keys until you have arrived in the indicated line. There the line "MONITOR ups@*IP-ADDRESS-EURER-NAS*1 monuser secret slave" must be inserted. Of course *IP-ADDRESS-EURER-NAS* must be replaced by the IP address of your network UPS server, ie your NAS. Only then does NUT know where it can get the UPS information from.
MONITOR ups@*IP-ADRESSE-EURER-NAS* 1 monuser secret slave
You save this configuration again by pressing "CTRL-X" and "J" (or "Y") ...
... and finally on "Enter".
In order for the changes to the configuration file to be transferred, you just have to restart the NUT client. This is done with the command "sudo service nut-client restart".
sudo service nut-client restart
You can now use the command " sudo upsc ups@*IP ADDRESS-EURER-NAS*" to get the latest information about your UPS from the network UPS server. Of course *IP-ADDRESS-EURER-NAS* must be replaced by the IP address of your network UPS server, ie your NAS.
sudo upsc ups@*IP-ADRESSE-EURER-NAS*
The information will then be displayed according to the specified pattern. This will indicate, for example, the state of charge, the model, and various voltages.

Import NodeCode

With the following NodeCode you can see some details of the current status of your connected UPS. So you can react individually to certain properties.

For example, it would be possible to notify you via a bulletin message about a power outage or, as shown in the example below, display the most important data on the dashboard. Of course, to be able to send Pushbullet messages in the event of a power failure, you should ensure that your entire network infrastructure is also protected by the UPS. Of course, if the power failure is very large, it will not help either. Therefore, communication over the Internet in the event of a power failure is of course not guaranteed.

How to import your NodeCode into your NodeRed configuration is described in the article NodeRed - Importing and Exporting Node Code. After importing, you may also have to configure the pushbullet node. You can find information on this in the article NodeRed - Pushbullet Send messages to events. Dashboard nodes are used to display the UPS data. You can find information on this in the article NodeRed - Create a User Interface with Dashboard Nodes.

View of the UPS status indicator in the dashboard.
Overview of the NodeCode configuration in the NodeRed configuration interface.
[{"id":"b7aefd76.e8bf9","type":"comment","z":"8c9f8f17.13eb78","name":"USV-Server data request","info":"","x":170,"y":2160,"wires":[]},{"id":"66e7a9bd.eb6c58","type":"inject","z":"8c9f8f17.13eb78","name":"","topic":"status request","payload":"","payloadType":"date","repeat":"60","crontab":"","once":true,"onceDelay":0.1,"x":180,"y":2240,"wires":[["d3649b9.f1b5468"]]},{"id":"d3649b9.f1b5468","type":"exec","z":"8c9f8f17.13eb78","command":"sudo upsc ups@192.168.3.59","addpay":false,"append":"","useSpawn":"","timer":"","oldrc":false,"name":"get UPS status","x":420,"y":2240,"wires":[["22edb893.55ed38"],[],[]]},{"id":"22edb893.55ed38","type":"function","z":"8c9f8f17.13eb78","name":"convert2Json","func":"const convertData = {}\n\nArray.prototype.map.call( msg.payload.trim().split(\"\\n\"), function(line) \n{\n    if ( line.trim() === '' ) return\n    let part = line.split(':')\n    \n    // Some values contain ':', when they do, we have to rejoin\n    if ( part.length > 2 ) {\n        let newPart = []\n        newPart.push( part.shift() )\n        newPart.push( part.join(':') )\n        part = newPart\n    }\n    \n    let payloadName = part[0].toLowerCase().trim()\n    payloadName = part[0].replace(/\\./g, \"_\")\n    let payloadValue = part[1].trim()\n    convertData[payloadName] = payloadValue\n    return\n    \n} )\n\nmsg.payload = convertData\n\nreturn msg","outputs":1,"noerr":0,"x":630,"y":2240,"wires":[["61f07a9c.f54824","a1504bd4.049f18","4e4d02.d85ad3","641d6b8a.a25e34","49343e5b.85218","3c698623.45215a","83b9ebee.451878","282426fe.c5650a","50224b5b.8a4164"]]},{"id":"61f07a9c.f54824","type":"debug","z":"8c9f8f17.13eb78","name":"Data as JSON payload","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":920,"y":2240,"wires":[]},{"id":"21f21239.2c2bce","type":"ui_text","z":"8c9f8f17.13eb78","group":"6f8a5651.9e0318","order":0,"width":0,"height":0,"name":"Test:","label":"Test:","format":"{{msg.payload}}","layout":"row-spread","x":1130,"y":2480,"wires":[]},{"id":"a1504bd4.049f18","type":"change","z":"8c9f8f17.13eb78","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.battery_charge","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":2280,"wires":[["3442fea.41d6702"]]},{"id":"4e4d02.d85ad3","type":"change","z":"8c9f8f17.13eb78","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.battery_temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":2320,"wires":[["5362d4fa.9026ac"]]},{"id":"641d6b8a.a25e34","type":"change","z":"8c9f8f17.13eb78","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.battery_voltage","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":2360,"wires":[["bd21c5da.510bc8"]]},{"id":"49343e5b.85218","type":"change","z":"8c9f8f17.13eb78","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.input_voltage","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":2400,"wires":[["22a47d9.d019982"]]},{"id":"3c698623.45215a","type":"change","z":"8c9f8f17.13eb78","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.ups_status","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":2440,"wires":[["6a33c3ab.06088c"]]},{"id":"83b9ebee.451878","type":"change","z":"8c9f8f17.13eb78","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.ups_test_result","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":2480,"wires":[["21f21239.2c2bce"]]},{"id":"282426fe.c5650a","type":"function","z":"8c9f8f17.13eb78","name":"","func":"msg.payload=Date(Date.now());\nreturn msg;","outputs":1,"noerr":0,"x":870,"y":2520,"wires":[["12142ef5.0928f1"]]},{"id":"50224b5b.8a4164","type":"function","z":"8c9f8f17.13eb78","name":"","func":"if (msg.payload.input_voltage<=100)\n{\n    msg.payload=\"Stromausfall: USV-Eingangsspannung unter 100V!\";\n    return msg;\n}","outputs":1,"noerr":0,"x":870,"y":2560,"wires":[["b4128198.758dd"]]},{"id":"b4128198.758dd","type":"pushbullet","z":"8c9f8f17.13eb78","config":"","pushtype":"note","title":"SmartHome","chan":"","name":"","x":1150,"y":2560,"wires":[]},{"id":"88e174da.1ab6d8","type":"inject","z":"8c9f8f17.13eb78","name":"Test Power failure","topic":"","payload":"60","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":490,"y":2560,"wires":[["b7ac5f17.07bbb"]]},{"id":"b7ac5f17.07bbb","type":"change","z":"8c9f8f17.13eb78","name":"","rules":[{"t":"set","p":"temp","pt":"flow","to":"payload","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.input_voltage","pt":"msg","to":"temp","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":2560,"wires":[["50224b5b.8a4164"]]},{"id":"3442fea.41d6702","type":"ui_gauge","z":"8c9f8f17.13eb78","name":"Battery charge","group":"c8fbbc62.c288a","order":4,"width":0,"height":0,"gtype":"gage","title":"Battery charge:","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#ca3838","#e6e600","#00b500"],"seg1":"","seg2":"","x":1160,"y":2280,"wires":[]},{"id":"5362d4fa.9026ac","type":"ui_gauge","z":"8c9f8f17.13eb78","name":"Batterie-Temperature","group":"c8fbbc62.c288a","order":5,"width":0,"height":0,"gtype":"gage","title":"Batterie-Temperature:","label":"°C","format":"{{value}}","min":"20","max":"40","colors":["#00b500","#00b500","#ca3838"],"seg1":"","seg2":"","x":1180,"y":2320,"wires":[]},{"id":"bd21c5da.510bc8","type":"ui_gauge","z":"8c9f8f17.13eb78","name":"Batterie-Voltage","group":"c8fbbc62.c288a","order":6,"width":0,"height":0,"gtype":"gage","title":"Batterie-Voltage:","label":"V","format":"{{value}}","min":"11","max":"15","colors":["#ca3838","#00b500","#ca3838"],"seg1":"","seg2":"","x":1160,"y":2360,"wires":[]},{"id":"22a47d9.d019982","type":"ui_gauge","z":"8c9f8f17.13eb78","name":"Mains voltage","group":"c8fbbc62.c288a","order":7,"width":0,"height":0,"gtype":"gage","title":"Mains voltage:","label":"V","format":"{{value}}","min":"220","max":"240","colors":["#ca3838","#00b500","#ca3838"],"seg1":"","seg2":"","x":1160,"y":2400,"wires":[]},{"id":"6a33c3ab.06088c","type":"ui_text","z":"8c9f8f17.13eb78","group":"c8fbbc62.c288a","order":1,"width":0,"height":0,"name":"Status","label":"Status:","format":"{{msg.payload}}","layout":"row-spread","x":1130,"y":2440,"wires":[]},{"id":"12142ef5.0928f1","type":"ui_text","z":"8c9f8f17.13eb78","group":"c8fbbc62.c288a","order":2,"width":0,"height":0,"name":"Last Update","label":"Last Update:","format":"{{msg.payload}}","layout":"row-spread","x":1150,"y":2520,"wires":[]},{"id":"6f8a5651.9e0318","type":"ui_group","z":"","name":"USV","tab":"fe022c7.d9788d","disp":true,"width":"6","collapse":false},{"id":"c8fbbc62.c288a","type":"ui_group","z":"","name":"USV2","tab":"4719e8d9.2a46f8","disp":true,"width":"6","collapse":false},{"id":"fe022c7.d9788d","type":"ui_tab","z":"","name":"Einstellungen","icon":"dashboard"},{"id":"4719e8d9.2a46f8","type":"ui_tab","z":"","name":"Einstellungen","icon":"dashboard"}]

Additional information

https://wiki.ubuntuusers.de/USV/NUT/
https://flows.nodered.org/flow/cf9813fbca341607a73786c31df362c9
http://www.gtkdb.de/index_36_2203.html

https://www.biesalski.info/wordpress/synology-diskstation-als-netzwerk-usv-server-fuer-linux-oder-windows-rechner-verwenden/


I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. :)

Fab

P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. :)

Buy Me a Coffee at ko-fi.com

Leave a Reply

Your email address will not be published. Required fields are marked *