UPS Nut Client Sensor

This would probably be best as a component but for the time being I am using the nut-client to pull the status from my UPS connected to a Synology disk station.

the command line sensors look like

  - platform: command_line
    name: ups_status
    command: upsc [email protected]:3493 ups.status > /dev/stdout 2> /dev/null
  - platform: command_line
    name: ups_charge
    command: upsc [email protected]:3493 battery.charge > /dev/stdout 2> /dev/null
    unit_of_measurement: '%'
  - platform: command_line
    name: ups_runtime
    command: upsc [email protected]:3493 battery.runtime > /dev/stdout 2> /dev/null
    unit_of_measurement: sec

All options from the upsc command are:

battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 20
battery.mfr.date: CPS
battery.runtime: 1076
battery.runtime.low: 300
battery.type: PbAcid
battery.voltage: 13.9
battery.voltage.nominal: 12
device.mfr: CPS
device.model:  CP 1500C
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 5
driver.parameter.port: auto
driver.version: SDS6-0-8445-factory-repack-8445-160817
driver.version.data: CyberPower HID 0.3
driver.version.internal: 0.38
input.transfer.high: 140
input.transfer.low: 90
input.voltage: 123.0
input.voltage.nominal: 120
output.voltage: 123.0
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.delay.start: 30
ups.load: 30
ups.mfr: CPS
ups.model:  CP 1500C
ups.productid: 0501
ups.realpower.nominal: 388
ups.status: OL
ups.test.result: Done and warning
ups.timer.shutdown: -60
ups.timer.start: 0
ups.vendorid: 0764
2 Likes

What do you do with this information?

I have NUT, but couldnā€™t think of anything to do besides displaying the information.

I am now setting up an automation to alert me when the power goes out.

For me I have a few lights and switches that default to ā€œonā€ after a power outage.
So I am creating an automation that way after a power outage I can turn those devices off.

I had my synology configured to email alerts when it went on battery (ie power fail) and also when it recovered.

Nut is now a component.

2 Likes

if you have a power cut in your house. Pretty helpful sensor to have

Oh, but I already have NUT alerting me.

which type, and how?

See NOTIFYCMD in upsmon.conf

So is there a way using the NUT sensor to calculate the current wattage used based on the max wattage of the apc unit and the load percentage. I can manually do the math but just wondering if there is a way to create a sensor that shows this info and tracks the history.

If you have the math a template sensor could do it.

Template sensor? Can you explain or share a link?

See here
https://github.com/SilvrrGIT/HomeAssistant/blob/master/sensors.yaml#L61

This matches the display on the front of my UPS for wattage and I think the actual UPS uses similar math. It seems to only report values that fit within this math.

One issue with this it adds a ton of extra decimal places to certain load values. Havenā€™t taken the time yet to figure out how to limit it.

1 Like

Awesome! That worked thanks!.. Only thing now is it would be cool to have it show in homeassistant as a dial instead of just a numberā€¦ something kind of like thisā€¦ image

I have problem.

I did have R Pi 3B, and changed to R Pi 3B+. Everything was working fine before. After restore from backup to the new Pi 3B+ NUT sensor stopped working, before on old Pi 3B was working fineā€¦

So, do anybody has any clue what Iā€™m doing wrong? Is there any change in 0.86.4 so that NUT sensor would not work?

Configuration:
Image1

QNAP NAS settings, before when was working was the same:

Errors on HA:
Image3

1 Like

For me the nut sensor is running fine in 0.86.4. No changes there. I compared your config with mine. I donā€™t use the host parameter since my nut server is running as an add-on in HA (so itā€™s the default (=localhost) for me).

My 2 cents for you:

  • Is the IP address of your nut server still 192.168.3.71? Maybe it has changed because of your hardware change?
  • Is your nut server running fine? If you also use the ā€˜Network UPS Toolsā€™ add-on for the nut server, it should be installed and running.

My NAS has static IP, so yes, itā€™s still 192.168.3.71ā€¦ here is no changeā€¦ everything on NAS is also still the same - nothing changed hereā€¦

So, everything was working fine before, after restore from backup (because of Raspberry Pi 3 B+ change) everything regarding NUT is brokenā€¦

I will try to enable ā€œdebugā€ logging to see what is wrong with more detailed info and report it backā€¦

I did manage to fix itā€¦

The good start is:
https://forum.qnap.com/viewtopic.php?t=60166

Also have in mind that settings for QNAP must be the same as in QNAP NASā€¦
SENSOR:

  - platform: nut
    name: qnapups
    host: 192.168.3.71
    username: admin
    password: 123456
    resources:
      - ups.load
      - ups.realpower.nominal
      - input.voltage
      - battery.runtime
      - battery.charge
      - ups.status.display

And also in QNAP I edit:
upsd.users

So that I allowed my client_1 (IP of my HA) that can not only read but also manage and send data to NAS, but this is just future work - in case as client mode this is not necessaryā€¦

2 Likes

@kslb

I have the UPS - Nut working on a couple of PCā€™s on the network with the UPS on my QNAP and would like to monitor it from HA.

On the QNAP side, is the upsd.users file the only one you made changes in?

[admin]
password = 123456
allowfrom = 10.0.0.59 (Hass box IP)
actions = SET
instcmds = ALL
upsmon slave (slave or master??)
I have tried several settings, and run into the same errors that you where reporting earlier.

Any help would be appreciatedā€¦ Thanks
Anything else you changed? I followed your Config.yaml settings as well.

########### FIgured it out ā€¦ Thanks

Great, so you find out what was wrong?