HowTo: Node Red - Read UPS status

One of the weak points of a SmartHome system that you only really become aware of when something goes wrong is "energy". Unfortunately, all the sensors, actuators and the controlling intelligence behind them don't run on air and love. And even if the energy used by the system is not very high and the general savings are certainly higher than the "consumed" energy, the supply energy is essential. In other words: no electricity -> no SmartHome.

But that's a luxury problem that I could live with for the time being. What I find much worse is the thought that my RaspberryPi, or any computer in general, could be swallowed up by a sudden power failure in such a way that it might no longer boot up afterwards.
If your SmartHome system (RaspberryPi, BeagleBone, Windows PC, etc.) is interrupted just at the moment when it is writing important (system) data, it is possible that it will no longer boot up properly after the power supply is restored. In extreme cases, this can lead to a painful loss of data and often to a considerable loss of time. In extreme cases, there is no backup of the system and the entire system, including all system components, has to be reinstalled and reconfigured.

However, it seems that other people have also encountered this problem. Uninterruptible power supplies (UPSs) were invented for this case. These devices are connected between the socket and the load (in this case your RaspberryPi, etc.) and from then on continuously monitor the quality of your mains voltage. In other words, they continuously monitor whether the incoming AC voltage and frequency are within the permitted range. If an undervoltage or overvoltage occurs, or if something else is wrong with the supply voltage, the UPS switches off the voltage input within milliseconds and switches to an internal buffer battery. This then takes over the supply to the connected loads until the buffer battery is empty.

UPSs are now available in all kinds of forms. The smallest ones look like somewhat clunky multiple sockets. Others - or rather their batteries - can fill an entire room.

For the normal SmartHome user, the smaller versions will certainly suffice. Like for example ...

This article explains how you can integrate your own UPS into NodeRed and react to changes.


Safety instructions

I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.
https://www.nerdiy.de/sicherheitshinweise/

Affiliate links/advertising links

The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and make a purchase via this link, Nerdiy.de will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support Nerdiy.de in being able to offer other useful projects in the future. 🙂 


Requirements

Helpful articles:
So that you can control/configure your UPS via your RaspberryPi and NodeRed, it should of course be prepared so that NodeRed runs on it and you can access it via SSH.

RaspberryPi – setup 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 - Send pushbullet messages for events
NodeRed - Create a user interface 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 disadvantage of an uninterruptible power supply is that the RaspberryPi does not notice anything as soon as something is not (or no longer) right with the power supply. This is actually what is desired. On the other hand, the RaspberryPi cannot react to this change.

Even if the battery of a UPS is quite large compared to the consumption of a RaspberryPi, the battery capacity is finite. For this reason, the RaspberryPi should shut down automatically before the battery is fully depleted. This minimizes the risk of data loss and allows a controlled response to the power failure.

The UPS must be connected to the RasperryPi via a USB or serial connection so that the RasperryPi can be informed about changes.

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

For example, it would also be possible to switch off certain components or shut down other RaspberryPi's - if they have not already failed due to the power failure.

However, before you can read out the status of your UPS in NodeRed, "apcupsd" must first be installed.


Log in to the RaspberryPi via SSH

To start, you must first log in to the Rasp Pi with Putty via SSH. How to do this is in the article RaspberryPi - Control the RaspberryPi via SSH described.

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

Update package management

The package management in Linux is a "central place" through which various software packages can be installed. In order for this to work reliably, the lists and sources of the package management should be updated before each installation of new packages.

To start the update of the package management you have to enter the following command.
sudo apt-get update && sudo apt-get upgrade
Depending on how long ago your last update of the package management was, this process can now take a while. The lists that refer to the individual package sources are updated first.
After that, the packages themselves are updated. Since additional memory is occupied, you will be asked again for your consent. You have to confirm this with a "J" and "Enter".
Once the update is complete, you will see a small summary of the duration and scope of the update.

Install "apcupsd" on the RaspberryPi

To enable your RaspberryPi to communicate with the connected UPS, you must first install a few packages.

A program that can communicate directly with your UPS connected via USB is the program "apcupsd", which you install with the following command.
sudo apt-get install apcupsd
If you are asked whether the program is using additional memory, confirm with "Y".
The installation takes about two minutes.

Configure Apcupsd

Before you can use "apcupsd", it must of course first be configured. To do this, a few configuration files need to be edited.

Open the first configuration file with the following command.
sudo nano /etc/apcupsd/apcupsd.conf
In the opened configuration file you must now first use the arrow keys to...
...navigate to the line shown. The type of cable used to connect the UPS to your RaspberryPi is specified there. Your UPS is most likely connected to your RaspberryPi via the USB port. That is why you also set "UPSCABLE usb" here.
UPSCABLE usb
Since you have connected a USB cable, you must of course also set the UPSTYPE to usb.
UPSTYPE usb
To ensure that the connection to the UPS via USB works, you must now edit the "DEVICE" parameter. No value may be assigned to this parameter. To do this, remove the "/dev/ttsyS0" part shown next to "DEVICE".
This should look like this.
Now you can make a few settings for how apcupsd should behave in the event of a power failure. For example, the "BATTERYLEVEL" parameter can be used to set the RaspberryPi to shut down if the UPS has a remaining charge level of 5%.
The "MINUTES" parameter specifies the remaining runtime in minutes at which the RaspberryPi should be shut down.
You can use the "NETSERVER" parameter to activate a network server that makes the UPS information available via the network. In the event of a power failure, other network participants can also react to this and shut down, for example. To activate the network server, you must set the parameter to "NETSERVER on".
You can use the "NISIP" parameter to set which IP address the server "listens" to. This is only necessary if you have more than one network interface on the system in question. On a RaspberryPi, for example, you could use this to set the server to only respond to requests that it receives via the WLAN interface and not via the LAN interface. In most cases, however, you can set this parameter to "NISIP 0.0.0.0". This means that all requests are answered, regardless of the network interface.
The "NISPORT" parameter defines the port under which the server information can be retrieved. You should leave this unchanged at the value "3551".
You can then save this configuration by pressing "CTRL-X" and "J"...
...and "Enter".
Now you have to tell apcupsd that a configuration exists. To do this, open another configuration file with the following command.
sudo nano /etc/default/apcupsd
Set the "ISCONFIGURED" parameter to...
... "yes".
You can then save this configuration again by pressing "CTRL-X" and "J"...
...and "Enter".
The apcupsd service can then be started with the following command.
sudo /etc/init.d/apcupsd start
Once the program has started successfully, it should look like this.
The current status of the UPS can then be displayed with the "apcaccess status" command. If no connection to the UPS can be established, the response looks as shown.
apcaccess status
If the connection to the UPS is established and the information can be read out, the information shown will be displayed.
If you need to restart "apcupsd", simply enter the following command.
sudo /etc/init.d/apcupsd restart

You now have the option of displaying the UPS information on the RaspberryPi. To use this information for your SmartHome, you can use the following NodeCode.


Import node code

You can use the following NodeCode to display a few details of the current status of your UPS. This allows you to react individually to certain properties.

For example, it would be possible to be notified of a power failure via a pushbullet message or to display the most important data on the dashboard, as in the example below. To ensure that pushbullet messages can be sent in the event of a power failure, you should of course make sure that your entire network infrastructure is also protected by the UPS. However, if the power failure is very extensive, even this will of course no longer help. Therefore, communication via the Internet is of course not guaranteed in the event of a power failure.

How to import NodeCode into your NodeRed configuration is described in the article NodeRed - import and export node code described above. After importing, you may also need to configure the pushbullet node. You can find information on this in the article NodeRed - Send pushbullet messages for events. Dashboard nodes are used to display the UPS data. You can find information about this in the article NodeRed - Create a user interface with dashboard nodes.

View the UPS status display 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 = {}

Array.prototype.map.call( msg.payload.trim().split("\n"), function(line) 
{
    if ( line.trim() === '' ) return
    let part = line.split(':')
    // Some values contain ':', when they do, we have to rejoin
    if ( part.length > 2 ) {
        let newPart = []
        newPart.push( part.shift() )
        newPart.push( part.join(':') )
        part = newPart
    }
    
    let payloadName = part[0].toLowerCase().trim()
    let payloadValue = part[1].trim()
    ans[payloadName] = payloadValue
    return
    
} )

msg.payload = ans

return 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());
return 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)
{
    msg.payload="Power failure: UPS-Mains-voltage below 100V!";
    return msg;
}","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 have a Synology NAS or a NAS in general, the issue of data loss is even more important. After all, the family photos (or some of them) shouldn't disappear into data nirvana in the event of a power outage. That's why many manufacturers offer the function of protecting your own NAS from power failures with a UPS. The UPS is then connected to the NAS via USB in order to be able to provide information about a status change. If a power failure occurs, 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 do not find out about the situation (except that the power has gone out).

At least the NAS from Synology offer a solution for this: via an integrated network UPS server, other network participants can also record the status of the UPS connected to the NAS. This means you can ultimately record the status on the RaspberryPi and therefore also in NodeRed.

In order for the network UPS server to work, it must first be set up. To do this, go to the Control Panel of the DiskStationManager (DSM) interface...
... and to the “Hardware & Energy” category. There you click on the “UPS” tab.
The connected UPS should already be configured there. In this case, the NAS will automatically shut down after 3 minutes after a power failure occurs. To activate the network UPS server, check “Activate network UPS server” and click on the “Approved DiskStation devices” button.
In the window that now opens, you can enter several IP addresses of devices in your network that are allowed to access the information from the network UPS server. This so-called “whitelist” process ensures that only authorized network participants can receive this information. In this field you enter the IP address of your RaspberryPi from which you want to read the UPS status via NodeRed, as shown. How you can find out the IP address of the devices in your network is in the article Display/find out the IP address of the devices in the network described. Once you have entered the IP address, click on “OK”…
...and in the following window click “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, the client side (i.e. your RaspberryPi) must of course also be configured accordingly. Of course, this must also be able to contact the network UPS server on your NAS. A program that makes this possible is the “NetworkUpsTool”, which can be installed as follows.

To install the “NUT” application you must enter the following command.
sudo aptitude install nut

A notice: To install “NUT” you need the “aptitude” extension for the “APT” package management. This can be installed – if it is not already available – with the following command.

sudo apt-get install aptitude

If you have any questions during the installation, confirm with “y” and “Enter”. Most of the time (as in this example) these questions relate to whether additional storage space is required by the tools to be installed and whether additional (required) packages can also be installed.

After installation, “NUT” still needs to be configured. To do this, open the configuration file with the following command.
sudo nano /etc/nut/nut.conf
In the now open configuration file, use the arrow keys to navigate to the line shown.
Once there, change the line from “Mode=none” to “Mode=netclient”. This tells “NUT” to act as a network client for a network UPS server.
mode=netclient
You save this configuration by pressing “CTRL-X” and “J”…
…and finally click “Enter”.
Now, of course, you still have to configure the address at which 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 arrive at the specified line. The line “MONITOR ups@*IP-ADDRESS-EURER-NAS* 1 monuser secret slave” must be inserted there. Of course, *IP-ADDRESS-EURER-NAS* must be replaced by the IP address of your network UPS server, i.e. your NAS. This is the only way NUT knows where to get the UPS information from.
MONITOR ups@*IP-ADDRESS-YOUR-NAS* 1 monuser secret slave
You can then save this configuration again by pressing "CTRL-X" and "J"...
…and finally click “Enter”.
In order for the changes to the configuration file to be applied, all you have to do is restart the NUT client. This can be done with the command “sudo service nut-client restart”.
sudo service nut-client restart
Using the command “sudo upsc ups@*IP-ADDRESS-EURER-NAS*” you can now retrieve the current 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, i.e. your NAS.
sudo upsc ups@*IP-ADDRESS-YOUR-NAS*
The information will then be displayed to you according to the specified pattern. This displays, for example, the charging status, the model and various voltages.

Import node code

With the following NodeCode you can display a few details of the current status of your UPS connected to your Synology NAS. This means you can react individually to certain characteristics.

For example, it would be possible to be notified of a power failure via a pushbullet message or to display the most important data on the dashboard, as in the example below. To ensure that pushbullet messages can be sent in the event of a power failure, you should of course make sure that your entire network infrastructure is also protected by the UPS. However, if the power failure is very extensive, even this will of course no longer help. Therefore, communication via the Internet is of course not guaranteed in the event of a power failure.

How to import NodeCode into your NodeRed configuration is described in the article NodeRed - import and export node code described above. After importing, you may also need to configure the pushbullet node. You can find information on this in the article NodeRed - Send pushbullet messages for events. Dashboard nodes are used to display the UPS data. You can find information about this in the article NodeRed - Create a user interface with dashboard nodes.

View the UPS status display 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 = {}

Array.prototype.map.call( msg.payload.trim().split("\n"), function(line) 
{
    if ( line.trim() === '' ) return
    let part = line.split(':')
    
    // Some values contain ':', when they do, we have to rejoin
    if ( part.length > 2 ) {
        let newPart = []
        newPart.push( part.shift() )
        newPart.push( part.join(':') )
        part = newPart
    }
    
    let payloadName = part[0].toLowerCase().trim()
    payloadName = part[0].replace(/\./g, "_")
    let payloadValue = part[1].trim()
    convertData[payloadName] = payloadValue
    return
    
} )

msg.payload = convertData

return 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());
return 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)
{
    msg.payload="Stromausfall: USV-Eingangsspannung unter 100V!";
    return msg;
}","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"}]

Further information

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


Have fun with the project

I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂

PS 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 think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂

Buy Me a Coffee at ko-fi.com       

Kommentar hinterlassen

Your email address will not be published. Erforderliche Felder sind mit * markiert

This site uses Akismet to reduce spam. Learn how your comment data is processed.