Author Topic: PLUGIN: UPS status monitor  (Read 957 times)

Offline reneboer

  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +61/-30
PLUGIN: UPS status monitor
« on: January 06, 2017, 08:29:47 am »
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    https://github.com/reneboer/vera-UPSSensor
   variables possible    http://networkupstools.org/docs/user-manual.chunked/apcs01.html
   status details APC    http://www.mathstat.dal.ca/~selinger/ups/backups.html

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 http://forum.micasaverde.com/index.php/topic,7845.msg50156.html#msg50156.

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

Cheers Rene
« Last Edit: January 21, 2017, 11:19:26 am by reneboer »
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline abhinavkhandka

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Re: PLUGIN: UPS status monitor
« Reply #1 on: February 15, 2017, 02:01:28 pm »
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

Offline reneboer

  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +61/-30
Re: PLUGIN: UPS status monitor
« Reply #2 on: February 15, 2017, 04:55:26 pm »
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
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline abhinavkhandka

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Re: PLUGIN: UPS status monitor
« Reply #3 on: February 15, 2017, 11:54:38 pm »
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

Offline reneboer

  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +61/-30
Re: PLUGIN: UPS status monitor
« Reply #4 on: February 17, 2017, 07:14:02 am »
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
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline abhinavkhandka

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Re: PLUGIN: UPS status monitor
« Reply #5 on: February 18, 2017, 02:18:35 am »
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: <span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12.48px; background-color: rgb(231, 234, 239);">tlsv1</span> now: <span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12.48px; background-color: rgb(231, 234, 239);">any</span> #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: <span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12.48px; background-color: rgb(231, 234, 239);">any</span> now: <span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12.48px; background-color: rgb(231, 234, 239);">any</span><span style="font-family: monospace; font-size: 13px;">sslv3</span> #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: <span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12.48px; background-color: rgb(231, 234, 239);">any</span><span style="font-family: monospace; font-size: 13px;">sslv3</span> now: <span style="font-family: monospace; font-size: 13px;">sslv3</span> #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>

Offline reneboer

  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +61/-30
Re: PLUGIN: UPS status monitor
« Reply #6 on: February 18, 2017, 03:49:32 pm »
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
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2364
  • Karma: +33/-45
  • Life Moves Pretty Fast....
    • Node Central
Re: PLUGIN: UPS status monitor
« Reply #7 on: September 05, 2017, 03:13:23 pm »
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?
« Last Edit: September 06, 2017, 07:46:59 am by parkerc »

Offline reneboer

  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +61/-30
Re: PLUGIN: UPS status monitor
« Reply #8 on: September 06, 2017, 04:50:39 am »
Hi Parkerc,

You can find information on http://networkupstools.org/ 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. https://www.snbforums.com/threads/using-qnap-ups-server-to-signal-other-devices.17551/.

Let me know if you get it working.

Cheers Rene
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.