Remote UPS for Raspberry

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

User avatar
bizziebis
Posts: 182
Joined: Saturday 19 October 2013 14:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8805
Location: The Netherlands
Contact:

Remote UPS for Raspberry

Post by bizziebis »

Today I installed a APC Back-UPS ES Power-Saving 700VA 230V, BE700G-GR to my Synology DS413.
973577_LB_00_FB_EPS_1000.jpg
973577_LB_00_FB_EPS_1000.jpg (43.37 KiB) Viewed 23724 times
It's possible to enable UPS server on the Synology and use it on the Raspberry. If you connect the Raspberry's powersupply to the UPS, you can safely shut down the system when the battery is almost empty.

On the raspberry you need to install NUT

Code: Select all

sudo apt-get install nut
edit the monitoring config

Code: Select all

sudo nano /etc/nut/upsmon.conf
Scroll down to the part MONITOR

Code: Select all

# MONITOR [email protected] 1 upsmon secretpass slave
# MONITOR myups@localhost 1 upsmon pass master  (or slave)
and add below:

Code: Select all

MONITOR [email protected] 1 monuser secret slave
Change the IP to the IP of your NAS. All the other info suitable for every Synology NAS

Save the file and quit nano

Edit nut configuration

Code: Select all

sudo nano /etc/nut/nut.conf
Change MODE=none into

Code: Select all

MODE=netclient
Save the file and quit nano

Start monitoring the remote UPS server

Code: Select all

sudo /etc/init.d/nut-client start
With the default settings the Raspberry will check the UPS status every 5 seconds. If it detects that the UPS is running on battery (when main power has failed), it will continue to monitor. If the connection is lost after that (NAS powered down) it will monitor for another 15 seconds before the Raspberry will shut down.

I have my Synology DS413, Raspberry and DSL router connected to the APC. It should keep everything running for al least 15 minutes when the power is down. :mrgreen:
Last edited by bizziebis on Tuesday 10 February 2015 20:57, edited 1 time in total.
advfr
Posts: 3
Joined: Saturday 20 September 2014 15:03
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10213
Location: France
Contact:

Re: Remote UPS for Raspberry

Post by advfr »

Dear bizziebis, you've made my day :D

Thanks a lot for this great info, just applied @ home !

Just another info than may be usefull for others...

You can check if the link with the UPS is good with: upsc [email protected]
(replace with your NAS IP addr.)

and there is a little mistake in your post at "Edit nut configuration", nano is missing in the command ;)

Merci beaucoup :!:

Have a great day !
Raspberry 3 - Domoticz Beta | Piface v.2 + Téléinfo + RFXtrx433E + Aeon Z-Wave+GEN5
Oregon, 9 motorisations Somfy Yslo Flex 2 RTS, prises chacon, Fibaro FGD-212, FGSD002, FGFS101, Sonoff
User avatar
bizziebis
Posts: 182
Joined: Saturday 19 October 2013 14:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8805
Location: The Netherlands
Contact:

Re: Remote UPS for Raspberry

Post by bizziebis »

Oops you are right.. I fixed it ;)

Nice to see the guide was usefull!

Reminds me to run this setup again for my new installed system..
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Remote UPS for Raspberry

Post by ThinkPad »

Nice tutorial, thanks for writing!
I am not active on this forum anymore.
antwan
Posts: 116
Joined: Saturday 13 July 2013 13:28
Target OS: Linux
Domoticz version: Latest
Location: Hilversum, The Netherlands
Contact:

Re: Remote UPS for Raspberry

Post by antwan »

Nice tutorial for the wiki!
Rasp Pi 2B: 3x DS18S20 (1-wire), BME280 (i2c)
Cubietruck 1: Aeotec Z-Wave+, RFXtrx433XL+P1, RFXtrx868, TE923 display, SolarEdge API
Cubietruck 2: Aeotec Z-Wave, Voltcraft CO-20
McMike
Posts: 3
Joined: Monday 12 October 2015 21:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Remote UPS for Raspberry

Post by McMike »

Hi,
thanks for that great tutorial. I just forgot to enter the allowed clients IP-adresses at the Synology, but once I did, everything worked.

Just one question. After the connection to the Synology is lost (it shut down before battery was empty) the Raspi will also shut down. However... what happens if the UPS doesn't shut down completely and regular power comes back on again so that there never was a full outage on the backup-site of the system? How can the Raspi start up again automatically?

Maybe a stupid question, but I am a bit confused.

Thanks
Michael
User avatar
happer66
Posts: 9
Joined: Monday 20 July 2015 18:48
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5x
Location: Sweden, EU 868,4MHz
Contact:

Re: Remote UPS for Raspberry

Post by happer66 »

Great guide, thanks!
I somewhat imagined it would be alot harder than this... ;)
(Using a ReadyNAS Pro + APC Back-UPS RS 1500G)

Cheers!
I was really looking forward to this, sadly it'll never be:
http://aeotec.com/smart-switchable-film-z-wave-wifi
:(
stlaha2007
Posts: 370
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: Remote UPS for Raspberry

Post by stlaha2007 »

McMike wrote:Hi,
thanks for that great tutorial. I just forgot to enter the allowed clients IP-adresses at the Synology, but once I did, everything worked.

Just one question. After the connection to the Synology is lost (it shut down before battery was empty) the Raspi will also shut down. However... what happens if the UPS doesn't shut down completely and regular power comes back on again so that there never was a full outage on the backup-site of the system? How can the Raspi start up again automatically?

Maybe a stupid question, but I am a bit confused.

Thanks
Michael
Only way to Startup your Pi is by hand. Remove USB-cable/Charger and insert it again.

Please keep in mind its not a PC and therefor your Pi is missing two things:
- BIOS
- Powerswitch

I can think of other options, however needs some enginering.

Sent from my D6503 using Tapatalk
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Remote UPS for Raspberry

Post by jannl »

Off course a Pi has a bios, how do you think it starts reading the sd-card for instance? May be not as complex as a pc but still.

As soon as my ups gets power again, my pi also restarts. Only problem is that the ups gets it power back before my nas switches the ups off.

Verstuurd vanaf mijn GT-I9300 met Tapatalk
PuckStar32
Posts: 2
Joined: Friday 07 October 2016 20:28
Target OS: -
Domoticz version:
Contact:

Re: Remote UPS for Raspberry

Post by PuckStar32 »

Thanks for this! Just bought a UPS and configured it.
Questions:
How can I check if the nut service is still running and ok?
Is it automatically started again after a reboot of the pi?
bluepi

Re: Remote UPS for Raspberry

Post by bluepi »

I do the same thing and then fetch the details into Domoticz with virtual utility switches..

Code: Select all

#!/bin/bash


#sudo service nut-server status | grep "upsd is running"
setvoltage=`upsc rphs | grep "battery.voltage:" | awk '{print $NF}'`
setruntimesec=`upsc rphs | grep "battery.runtime:" | awk '{print $NF}'`
setruntimemin=`echo $(($setruntimesec / 60))`
setinputvolt=`upsc rphs | grep "input.voltage:" | awk '{print $NF}'`
setbatterycharge=`upsc rphs | grep "battery.charge:" | awk '{print $NF}'`

IDX_Voltage="219"
IDX_Runtime="220"
IDX_Input="221"
IDX_Battery="222"

curl -s "http://127.0.0.1:8080/json.htm?type=command&param=udevice&idx="$IDX_Voltage"&nvalue=0&svalue="$setvoltage""
curl -s "http://127.0.0.1:8080/json.htm?type=command&param=udevice&idx="$IDX_Runtime"&nvalue=0&svalue="$setruntimemin""
curl -s "http://127.0.0.1:8080/json.htm?type=command&param=udevice&idx="$IDX_Input"&nvalue=0&svalue="$setinputvolt""
curl -s "http://27.0.0.1:8080/json.htm?type=command&param=udevice&idx="$IDX_Battery"&nvalue=0&svalue="$setbatterycharge""

exit 0
and just run in cron every few mins

This lets me know the service is up and if there are any changes to the UPS.. then I control every device on my network from Domoticz.

So if battery level is down to 5 mins it then start shutting down systems like wifi (POE) and other systems, before turning itself off. Once all other systems are off the battery run time on the UPS goes up quite a lot and it will wait until the UPS get down to 3 mins before turning itself off. However the power does have to be off for some time before it shuts down.
User avatar
remb0
Posts: 499
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Remote UPS for Raspberry

Post by remb0 »

I have the same UPS and will use it for my nas and PI.
but I will lett domoticz be the server, en the synology the client.

by a power failure nas must shutdown, but my PI must be up as long as possible.
so I can control my home, and the PI can inform me.

other reason is that my Nas goes off in the night.

is that possible?
McMike
Posts: 3
Joined: Monday 12 October 2015 21:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Remote UPS for Raspberry

Post by McMike »

I need urgent help, please.

I installed the NUT client as shown some time ago. Everything was running fine so far. We had some short single power outages but the APC kept all systems alive. Now yesterday we had two outages within 10 minutes or so. Both times the APC backed up the NAS and all network equipment including my raspberry pi.

After the power came back on the second time, all my home control (running on pi) was dead. Tonight after many tests i figured out that the pi somehow thinks the battery is low and immediately after regular boot up I get an automated shutdown. I managed to log in via SSH just one time real fast and was able to see the broadcast messages:
Broadcast message from nut@nobodypi2 (somewhere) (Thu Oct 13 21:52:34 2016):

Executing automatic power-fail shutdown

Broadcast message from nut@nobodypi2 (somewhere) (Thu Oct 13 21:52:34 2016):

Communications with UPS [email protected] established

Broadcast message from nut@nobodypi2 (somewhere) (Thu Oct 13 21:52:34 2016):

Auto logout and shutdown proceeding
Now how can I disable the NUT client within the just two seconds or so after boot to fix that? I have no idea what happened since the battery is up and running and also the Synology works fine.

Thanks a lot.
Michael
User avatar
bizziebis
Posts: 182
Joined: Saturday 19 October 2013 14:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8805
Location: The Netherlands
Contact:

Re: Remote UPS for Raspberry

Post by bizziebis »

You can copy the command

Code: Select all

sudo service nut-client stop
Paste it quickly and press Enter

Some terminal programs give you the possibility to enter a command which will be executed automatically upon login. For example JuiceSSH for Android. You can run a 'Snippet' after login. You could cooy above command in it and try to connector a couple of times.
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Remote UPS for Raspberry

Post by jannl »

@rembo why control your home when having a power outage? My synology is the server here. Pi shutsdown first and nas later and kills the ups. Only problem is the pi does not reboot when the power returns before the nas does a shutdown.
McMike
Posts: 3
Joined: Monday 12 October 2015 21:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Remote UPS for Raspberry

Post by McMike »

jannl wrote:@rembo why control your home when having a power outage? My synology is the server here. Pi shutsdown first and nas later and kills the ups. Only problem is the pi does not reboot when the power returns before the nas does a shutdown.
I am also not controlling my home during power outage however would like the pi to perform certain things upon power outage (send push message etc.). I have same setup. Synology is NUT server. UPS is keeping the whole network-stuff alive (also the pi running as a home control center). Upon low batt the pi is supposed to shutdown first and on almost no batt the Synology will shut down. If power outage still goes on, the switch / router / etc. will simply switch off on empty UPS batt. So everything is supposed to be save. Same "problem"... pi would not come on again if power returns before total UPS shutdown but that would be ok.

However the double outage must have caused the NUT-Server (Synology) to send a "low batt warning" to the pi and the pi shut down. Now whenever the pi reboots (although network is operational) the pi still "thinks" that the batt is low and initiates an emergency shutdown right away. This afternoon I will try to reboot the NAS, maybe the NUT server on the Synology is stuck and sending low batt warnings although there is none. If that doesn't help I will try to stop the nut-service on pi during the few seconds I have before the shutdown starts... I just didn't know the exact command to do that.
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Remote UPS for Raspberry

Post by jannl »

Question: how do you send a push message when your neighbourhood has a poweroutage?

Just before mu Pi does its shutdown, I set the virtual switch that controls the automatic shutdown to the normal state, so that on a reboot the Pi first checks the NAS for UPS before shutting itself down.

Furthermore, I have the NAS kill the UPS, so everything gets power when the main is restored.

The Pi sends a pushover message and an e-mail upon ups offline and just before shutdown, I wonder if I also get those when the main is actually off in the neighbourhood, works when only the power in the house gets killed (router etc on ups).

May be you should not check on low-battery but on ups online or offline.
User avatar
remb0
Posts: 499
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Remote UPS for Raspberry

Post by remb0 »

I will try to send a pushnotification indeed. only when my power is down due my own fault :P
when the whole neighbourhood is down it is not possible, i understand.
PuckStar32
Posts: 2
Joined: Friday 07 October 2016 20:28
Target OS: -
Domoticz version:
Contact:

Re: Remote UPS for Raspberry

Post by PuckStar32 »

Can someone please help me?
I want to know:
1. Is the nut service automatically started again after a reboot of the pi? Or must I configure that somewhere?
2. How can I check (manually) if the nut service is currently running?
3. How can I setup that the pi shutsdown BEFORE the NAS. Because what I want is:
Power outage -> NAS sends signal to pi3 that UPS running on battery -> pi should shutdown immediately -> After 5minutes the NAS should shut down the UPS and go in Safe mode itself.

With what the topic starter mentions this is not possible now because the pi will just wait until the NAS goes into Safe Mode before shutting down, but then the UPS battery will be emtpy.

Can anyone help me with this please?
User avatar
D1M0N
Posts: 1
Joined: Tuesday 06 December 2016 9:35
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Ukraine
Contact:

Re: Remote UPS for Raspberry

Post by D1M0N »

PuckStar32 wrote:Can someone please help me?
I want to know:
1. Is the nut service automatically started again after a reboot of the pi? Or must I configure that somewhere?
2. How can I check (manually) if the nut service is currently running?
3. How can I setup that the pi shutsdown BEFORE the NAS. Because what I want is:
Power outage -> NAS sends signal to pi3 that UPS running on battery -> pi should shutdown immediately -> After 5minutes the NAS should shut down the UPS and go in Safe mode itself.

With what the topic starter mentions this is not possible now because the pi will just wait until the NAS goes into Safe Mode before shutting down, but then the UPS battery will be emtpy.

Can anyone help me with this please?
UP your question...

I have Nas4free + NUT service. If voltage is lost, my computer is turned off after 10 minutes WinNUT. after it is turned off the server over 20 min.
I want to monitoring voltage condition through DOMOTICZ.

ps sorry for bad english, im from Ukraine ))
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest