PLUGIN: UPS status monitor

Hi,

With this plugin you can monitor the status of your Uninterruptable Power Supply (UPS). Incase of a power outage or low battery the sensor will trip.

The device is a default door/windows sensor so it will behave as such. This means when using in Scenes the tripped status matched a door being open.

Variables will be set like Tripped, ArmedTripped, Battery level, Watts, and all variables read from the UPS, just have a look.

The only configuration required is to set the IP address for the web server running the script in the ip attribute.
When running local on openLuup you must enter the IP address of your NAS and set the Remote variable to 0.
This is tested with an APC UPS attached to a Synology NAS

Some more background information
GitHub repository [url=https://github.com/reneboer/vera-UPSSensor]https://github.com/reneboer/vera-UPSSensor[/url]
variables possible [url=http://networkupstools.org/docs/user-manual.chunked/apcs01.html]http://networkupstools.org/docs/user-manual.chunked/apcs01.html[/url]
status details APC [url=http://www.mathstat.dal.ca/~selinger/ups/backups.html]http://www.mathstat.dal.ca/~selinger/ups/backups.html[/url]

This plugin does not support communication via SSL, so if you turned that on on your UPS server it won’t work. Also if you have a different server than a Synology NAS you may need to change the UPSName variable and add the correct port to the ip attribute. The default port number is 3493.

BTW, tested on UI7 and openLuup. I do not do UI5 anymore.

I got my inspiration from the discussions in this thread [url=http://forum.micasaverde.com/index.php/topic,7845.msg50156.html#msg50156]http://forum.micasaverde.com/index.php/topic,7845.msg50156.html#msg50156[/url].

This 2.0 version is on the Vera App Market, in the ALTUI App Store and can install via this URL http://:3480/data_request?id=action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=CreatePlugin&PluginNum=8866&Version=32866.

Cheers Rene

Hi,
I am unable to get it to work
I see on top of the screen it in Veraedge UI it gives Message saying UPS Sensor : Configure IP Address
and on the device configuration page i have UPS Sensor.Can’t Detect Device

i tried with 192.168.1.2 and 192.168.1.2:3943 under param->ip even UPS name is populated as apc

When i check upsc on the server I get the below output
abhinav@baseserver:~$ sudo upsc apc@192.168.1.2
[sudo] password for abhinav:
Init SSL without certificate database
battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 50
battery.date: 2001/09/25
battery.mfr.date: 2000/07/31
battery.runtime: 3540
battery.runtime.low: 120
battery.temperature: 29.2
battery.type: PbAc
battery.voltage: 27.3
battery.voltage.nominal: 24.0
device.mfr: American Power Conversion
device.model: Back-UPS BR 800

could you please help

Hi,

It your upsc output it says : SSL without certificate. I have not implemented SSL support. Maybe once I find the time, but it will not be soon I fear.

Maybe you can configure your NAS not to use SSL as it is only local traffic.

Cheers Rene

Hi,
Thanks for quick response. I suspected it to be SSL issue and you have mentioned it in documentation will not support SSL. Unfortunately I am not sure how to turn it off. I have nut installed on a Ubuntu 16.04 virtual server and not using NAS. I checked my upsd.conf and all CERT configs are commented. Google searches are available on how to enable SSL but not on how to disable it. Would you know how to turn off SSL?

Cheers

Abhinav

Hi Abhinav,

I have a completely untested version you can give a try. I added a variable SSLProtocol. When that is blank it will not try SSL, i.e. work as V2.0.

For SSL you must set the correct protocol in SSLProtocol. First try; any, then tlsv1 and last sslv3. If they don’t work. I don’t know.

As I do not have SSL for the UPS status on my Synology NAS I have not been able to test if it at all works. But as the examples are looking so simple it may be worth a shot.

Upload the attached to your Vera and configure the protocol. You can look at the Vera LUAPnP.log file to see if any errors are reported in case it does not work.

Cheers Rene

Hi
I tried updating this file however still no go. some of the logs, its giving me status as configure ip address. I tried both with ip address and ip:port

06 02/18/17 12:24:46.116 Device_Variable::m_szValue_set device: 68 service: urn:micasaverde-com:serviceId:SecuritySensor1 variable: Armed was: 0 now: 1 #hooks: 0 upnp: 0 skip: 0 v:0x9001a0/NONE duplicate:0 <0x75c2a520>
06 02/18/17 12:34:05.298 Device_Variable::m_szValue_set device: 68 service: urn:rboer-com:serviceId:UpsSensor variable: UPSName was: apc now: ups1 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x7480e520>
06 02/18/17 12:34:10.245 Device_Variable::m_szValue_set device: 68 service: urn:rboer-com:serviceId:UpsSensor variable: SSLProtocol was: tlsv1 now: any #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x74a2a520>
02/18/17 12:35:31.849 Device_Variable::m_szValue_set device: 68 service: urn:rboer-com:serviceId:UpsSensor variable: UPSName was: ups1 now: apc #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x75c2a520>
148735487908 02/18/17 12:36:25.533 JobHandler_LuaUPnP::HandleActionRequest device: 68 service: urn:micasaverde-com:serviceId:SecuritySensor1 action: SetArmed <0x74a2a520>
06 02/18/17 12:36:25.535 Device_Variable::m_szValue_set device: 68 service: urn:micasaverde-com:serviceId:SecuritySensor1 variable: Armed was: 1 now: 0 #hooks: 0 upnp: 0 skip: 0 v:0x9001a0/NONE duplicate:0 <0x74a2a520>
06 02/18/17 12:38:13.405 Device_Variable::m_szValue_set device: 68 service: urn:rboer-com:serviceId:UpsSensor variable: UPSName was: apc now: apc #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:1 <0x75c2a520>
06 02/18/17 12:40:13.780 Device_Variable::m_szValue_set device: 68 service: urn:rboer-com:serviceId:UpsSensor variable: SSLProtocol was: any now: anysslv3 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x7460e520>
06 02/18/17 12:40:47.205 Device_Variable::m_szValue_set device: 68 service: urn:rboer-com:serviceId:UpsSensor variable: SSLProtocol was: anysslv3 now: sslv3 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x75c2a520>
06 02/18/17 12:44:46.683 Device_Variable::m_szValue_set device: 68 service: urn:rboer-com:serviceId:UpsSensor variable: Status was: Configure IP Address. now: Configure IP Address. #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:1 <0x75c2a520>

Hi Abhinav,

Looking at the log there is some extra text in the SSLProtocol field. When you enter the value, can you check the option for “switch to input type text” that shows underneath and make sure it indeed just reads any, tlsv1, or sslv3?

Also make sure the UPS server IP address is properly filled in in the ip field on the Params tab. The log should not include that Configure IP Address in the Status variable.

Cheers Rene

Hi

Im sorry if this is a silly questions, but its not clear to me what I would need to install on the device the ups is connected to ?

I do not have a Synology NAS, but I do I have a QNAP, also do you think this could work via a UPS connected to a Raspberry Pi?

Hi Parkerc,

You can find information on [url=http://networkupstools.org/]http://networkupstools.org/[/url] on the NUT protocol used. You can also install something on a PI running python for example to make a NUT server this plugin can then talk to.

For QNAP I found this link on how to enable the NUT server so this plugin should work. [url=https://www.snbforums.com/threads/using-qnap-ups-server-to-signal-other-devices.17551/]https://www.snbforums.com/threads/using-qnap-ups-server-to-signal-other-devices.17551/[/url].

Let me know if you get it working.

Cheers Rene

[quote=“abhinavkhandka, post:6, topic:195043”]Hi
I tried updating this file however still no go. some of the logs, its giving me status as configure ip address. I tried both with ip address and ip:port

06 02/18/17 12:24:46.116 Device_Variable::m_szValue_set device: 68 service: urn:micasaverde-com:serviceId:SecuritySensor1 variable: Armed was: 0 now: 1 #hooks: 0 upnp: 0 skip: 0 v:0x9001a0/NONE duplicate:0 <0x75c2a520>
06 02/18/17 12:34:05.298 Device_Variable::m_szValue_set device: 68 service: urn:rboer-com:serviceId:UpsSensor variable: UPSName was: apc now: ups1 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x7480e520>
06 02/18/17 12:34:10.245 Device_Variable::m_szValue_set device: 68 service: urn:rboer-com:serviceId:UpsSensor variable: SSLProtocol was: tlsv1 now: any #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x74a2a520>
02/18/17 12:35:31.849 Device_Variable::m_szValue_set device: 68 service: urn:rboer-com:serviceId:UpsSensor variable: UPSName was: ups1 now: apc #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x75c2a520>
148735487908 02/18/17 12:36:25.533 JobHandler_LuaUPnP::HandleActionRequest device: 68 service: urn:micasaverde-com:serviceId:SecuritySensor1 action: SetArmed <0x74a2a520>
06 02/18/17 12:36:25.535 Device_Variable::m_szValue_set device: 68 service: urn:micasaverde-com:serviceId:SecuritySensor1 variable: Armed was: 1 now: 0 #hooks: 0 upnp: 0 skip: 0 v:0x9001a0/NONE duplicate:0 <0x74a2a520>
06 02/18/17 12:38:13.405 Device_Variable::m_szValue_set device: 68 service: urn:rboer-com:serviceId:UpsSensor variable: UPSName was: apc now: apc #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:1 <0x75c2a520>
06 02/18/17 12:40:13.780 Device_Variable::m_szValue_set device: 68 service: urn:rboer-com:serviceId:UpsSensor variable: SSLProtocol was: any now: anysslv3 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x7460e520>
06 02/18/17 12:40:47.205 Device_Variable::m_szValue_set device: 68 service: urn:rboer-com:serviceId:UpsSensor variable: SSLProtocol was: anysslv3 now: sslv3 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x75c2a520>
06 02/18/17 12:44:46.683 Device_Variable::m_szValue_set device: 68 service: urn:rboer-com:serviceId:UpsSensor variable: Status was: Configure IP Address. now: Configure IP Address. #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:1 <0x75c2a520>[/quote]

[quote=“reneboer, post:7, topic:195043”]Hi Abhinav,

Looking at the log there is some extra text in the SSLProtocol field. When you enter the value, can you check the option for “switch to input type text” that shows underneath and make sure it indeed just reads any, tlsv1, or sslv3?

Also make sure the UPS server IP address is properly filled in in the ip field on the Params tab. The log should not include that Configure IP Address in the Status variable.

Cheers Rene[/quote]

I’m not sure if you’re still supporting this, but I found an oversight in the code that will cause this not to work with a traditional NUT setup.

I setup a Raspberry PI to monitor my UPS and used NUT. I named it “networkups” and for some reason the plugin wasn’t working even when setting that. Here is why:

It queries for the variables by sending the configured UPS name correctly on line 123 and finds the BEGIN LIST VAR on 125

sock:send('LIST VAR '..[b]upsName[/b]..'\n') local ret, _, _ = sock:receive() if ret == 'BEGIN LIST VAR '..[b]upsName[/b] then

It loops through the variables and matches like so on line 132:

var, val = ret:match('VAR [b]ups[/b] ([%w%.]+) "(.+)"') 

Notice that it’s hard coded for looping for “ups” instead of using the variable upsName. My variables return like this:

BEGIN LIST VAR networkups VAR [b]networkups[/b] battery.charge "100" VAR networkups battery.charge.low "10" VAR networkups battery.charge.warning "50" ...

My guess is that your NAS just named it UPS and this was your code before you built the plugin to handle other names.

If the author doesn’t update this, you can simply change the name of your UPS in ups.conf (NUT) to “ups” and it should work. I didn’t have to change any settings in NUT with SSL, by default that is not setup and luup can reach out to it.

Hi,

I will have a look at the plugin code in the near future. Thanks for finding the issue.

Cheers Rene

Hello. I am using Synolgy NAS as NUT server. After update DSM to version 6.2.2 is required login (name/pass) to access data from NAS. With SSH on NAS, login data can be found here: /usr/syno/etc/ups/ups.conf
Can you add new parameters for login data?
Sorry for my bad english :slight_smile:

Hi husty84,

I have the same setup as yours So I’d better look if it is still working :thinking:. i will let you know.

Cheers Rene