APC UPS and Synology NAS integration for Home assistant

I don’t know how that ever worked for you. That will always return 0, no matter what. You’re casting a state object as an int. Then you you it again. This is a state object, it is not the ‘state’. That syntax in all versions of home assistant is invalid. It only would have have worked if you added .state at the end.

{% set time = states.sensor.apc_pro_rs900g_battery_runtime.state | int %}
                                                             ^
                                                             ^
                                                             ^

OK, thank you for your info.

using a slightly different technique to get the time in a “readable format”:

- platform: template
  sensors:
    desktop_ups_battery_runtime_hhmmss:
      value_template: "{{ states('sensor.desktop_ups_battery_runtime')|int | timestamp_custom('%H:%M:%S',false) }}"

For anyone interested, I’ve got my setup working with my APC Smart-UPS plugged in to HA and then Synology as the slave, rather than the other way around.

This configuration approach should also work when connecting to any other NUT.

Here are my configs with an example IP address:

First install NUT via Hassio Add-On Store: https://github.com/hassio-addons/addon-nut

NUT: (Synology requires the name “ups”, and defaults to “monuser”)

users:
  - username: monuser
    password: apcups123
    instcmds:
      - all
    actions: []
devices:
  - name: ups
    driver: usbhid-ups
    port: auto
    config:
      - vendorid = 051d
mode: netserver
shutdown_host: 'true'

Make sure you add host port 3493 under “Network”.

Then SSH in to your DiskStation and then in /usr/syno/etc/ups:

Edit upsd.users, changing master to slave and set the password to match the config above:

[monuser]
                password = apcups123
                upsman slave

Edit upsd.conf and add your HA IP Address. Eg:

LISTEN 192.168.1.95

Then set your HA IP address in the Synology UPS interface:

Synology UPS Settings

9 Likes

Does anyone know how to get the NUT UPS Device Info into a sensor so that I can display it in lovelace? I have the NUT integration configure and while I see it on the NUT devices page as shown below, i just dont have it in a sensor for display elsewhere. I was wondering if I should manually add NUT and then specifiy all the attributes you can pull from NUT in the manual config if that woul do it? Any help would be appreciated.
Screen Shot 2022-03-02 at 12.09.29 AM

Are you sure the entities are not disabled? Also make sure that in the Synology DSM you have enabled access for HASS to the NAS.

image

I was able to set up my HA as a slave connected to my Synology master UPS server which is connected to my APC via USB. Once you add your HA device IP to the Permitted Synology NAS Devices, you can configure HA NUT as follows:

devices:
  - config: []
    driver: usbhid-ups
    name: ups
    port: auto
mode: netclient
shutdown_host: 'true'
users:
  - actions: []
    instcmds:
      - all
    password: <synology ups password>
    username: <synology ups user>
    upsmon: slave
remote_ups_name: ups
remote_ups_host: <synology IP>
remote_ups_user: <synology ups user>
remote_ups_password: <synology ups password>

You can set your UPS user and password in your Synology /usr/syno/etc/ups/upsd.users, something like this:

[monuser]
                password = secret
                upsmon master

Hello,
could you please explain differences between remote_ups_name and remote_ups_user fields?
are both “master” as of your example?

Login on UPS [[email protected] failed - got [ERR ACCESS-DENIED]

Hi, does not work for me…

43.383353 UPS [[email protected]]: connect failed: Connection failure: No route to host
48.383604 [D1] Trying to connect to UPS [[email protected]]

I’m pretty sure my configuration is ok