How to configure NUT?

I have the following in the configuration.yaml:

sensor:
  - platform: nut
    username: !secret nut_username
    password: !secret nut_password
    resources:
      - ups.load
      - input.voltage
      - battery.voltage
      - battery.charge

It was previously working but I haven’t been using it for a while. Now I am trying to set it up again, but it doesn’t work. The log says:

The nut platform for the sensor integration does not support platform setup. Please remove it from your config.

I looked at the documentation (Network UPS Tools (NUT) - Home Assistant), and it says nothing about how to configure it in configuration.yaml. Instead, it says that I can do it from the Settings / Integrations menu. I don’t have that, supposedly because I am using configuration.yaml. Is there really no way I can configure NUT from configuration.yaml?

Yes there really is no way to do it using yaml now. Delete your NUT yaml config and restart.

Go to your Configuration / Devices & Services page, click the Add Integration button (lower right) and search for NUT. Use the GUI to set it up.

This is not good. Why was the previously working configuration option removed? Is something like this being done for other integrations too?

This is being done to most integrations.

You missed out on complaining by about two years:

1 Like

So, given the NUT add-on in Home Assistant Core is installed and working (mine is) and has a username and password configured, why doesn’t the HA NUT integration allow logging in via the username and password configured in the add-on?

1 Like

If you have it set up previously using yaml, most likely configuration was migrated to UI and parts that you do once (user, password) are hidden from you, as integration is considered to be set up already. Have you tried to completely remove the integration (from UI and from yaml) and set it up again from scratch? First start process should give you opportunity to configure necessary paramenetrs.
Screenshot 2022-03-06 at 11.18.11

1 Like

Thank you, @mirekmal. That is exactly what I did to attempt to get it working. I backed up my configuration YAML from the add-on UI. Then I deleted the NUT add-on, and then deleted the NUT integration. Following this, I added back the add-on, configured the add-on, and then attempted to add the integration. Unfortunately, it still refuses to login/connect. :frowning:

So seems at least you are able to configure it completely?
If this is log in failure there are other options to investigate:

  • are your credentials right? Have you checked any other NUT client with your UPS?
  • is UPS NUT server running? Myself I use NUT server on Synology NAS and I found that periodically it stops to work and need to be disabled and re-enabled again to be able to connect to.

It seems my Cyber-Power 1500 UPS powered down, and does not communicate over USB when powered down. After powering the UPS back ON, and stopping and restarting the NUT add-in, it shows the user being configured as contained in the add-on Configuration UI:

[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] nut.sh: executing... 
[13:39:42] INFO: Setting mode to netserver...
[13:39:42] INFO: Generating /etc/nut/upsd.users...
[13:39:42] INFO: Configuring user: fred
[13:39:42] DEBUG: Password SHA1: --some very long hex string--

Still, when attempting to configure the HA Integration, the login/connect fails. I cannot be certain, but I strongly suspect the NUT add-on isn’t mapping a TCP/IP port out to the host system as expected:

fred@hassio:~$ sudo docker container ls
CONTAINER ID   IMAGE                                                      COMMAND                  CREATED         STATUS         PORTS                                                                                                                          NAMES
52b69b5b2ce9   ghcr.io/hassio-addons/nut/amd64:0.9.1                      "/init"                  9 minutes ago   Up 9 minutes                                                                                                                                  addon_a0d7b954_nut
4a28f51c5e3f   ghcr.io/home-assistant/qemux86-64-homeassistant:2022.3.1   "/init"                  2 days ago      Up 2 days                                                                                                                                     homeassistant
f3aec4b5be6b   esphome/esphome-hassio-amd64:2022.2.6                      "/init"                  4 days ago      Up 4 days                                                                                                                                     addon_a0d7b954_esphome
1 Like

@FredTheFrog did you manage to get it working?

I can’t seem to get the integration to talk to the add-on either:

Integration screen: (I tried with the HA IP address and localhost)
image

When I try to enter the IP of the HA server below, it cuts it back to just 3 digits… I tried leaving at ‘localhost’ but that didn’t work either.
image

Add-on config:

devices:
  - config:
      - vendorid = 0665
    driver: blazer_usb
    name: ups
    port: auto
mode: netserver
shutdown_host: 'false'
users:
  - actions: []
    instcmds:
      - all
    password: redacted
    username: homeassistant
1 Like

I have the exact same issue as @sparkydave Has anyone found a solution?

Nope, no resolution. :frowning:

@tom_l , sorry to tag you here but I noticed one of your screenshots included the NUT add-on so I was wondering if you might have some knowledge that may help us here…?

It’s ages since I set mine up and after reading your issues I’m a bit reluctant to delete the integration and set it up again. My NUT integration is configured to use localhost port 3493.

Looking through the issues on github others have had success using a0d7b954-nut instead of localhost as the host.

Settings in case it is any use:

Screenshot 2022-04-17 at 13-22-48 Configuration – Home Assistant

The reason I don’t allow the shutdown host command is that I have replaced the 7Ah battery of my UPS with an 18Ah model and there is no way to tell the el-cheap-o UPS this. So the capacity remaining calculations are way off and NUT shuts my server down too soon if I allow it.

5 Likes

Yeah, I definitely wouldn’t risk it!

Cheers for the info. Looks like it’s a bug for sure then so I’ll log it and see where we get to.

@FredTheFrog , @7zzzzzzzzzzzzzzz7

Ok guys, we have a solution!

I looked at the existing issues posted against the NUT Integration (Core HA one, not the Add-on) and found someone had posted the fix.

We need to use the add-on slug rather than ‘localhost’ when setting up the Integration. In the case of this add-on the slug is a0d7b954-nut. Use the rest of the settings you used in the add-on config such as the default port 3493 and the username and password you entered.

image

I’ve just submitted a PR for the HA docs to include this detail.

10 Likes

This fixed it for me. :partying_face:

That’s exactly what I said!

2 Likes

I must have glanced over that 🤦 sorry mate!

1 Like

Heh. No worries, glad you got it working.