Nut Commands (upscmd)

It would be great if the nut integration could send commands.

I guess right know the nut integration is calling “upsc” command to retrieve info.

Could we implement somehow functionality to call “upscmd” to send commands?

It would be useful to send commands to the ups kind of quicktest or beeper on/off.

So the integration should be able to retrieve a commands list:

root@PROXMOX:~# upscmd -u admin -p mypassword -l [email protected]:3494
Instant commands supported on UPS [salicru]:

beeper.disable - Disable the UPS beeper
beeper.enable - Enable the UPS beeper
beeper.mute - Temporarily mute the UPS beeper
beeper.off - Obsolete (use beeper.disable or beeper.mute)
beeper.on - Obsolete (use beeper.enable)
test.battery.start.deep - Start a deep battery test
test.battery.start.quick - Start a quick battery test
test.battery.stop - Stop the battery test

Then append the switches to the UI kind of:

And finally send the command is some switch is checked, i.e.:

/upscmd -u admin -p mypassword [email protected]:3494 test.battery.start.quick

It would be also interesting if the integration could read the current state of the switches.

Don’t forget to vote for your own request.

1 Like

I was reviewing the code, it looks like this integrations doesn’t use upsc and upscmd like I thought but telnet. Anyways it is using a library which already has implemented the instant commands functionality so it should be easy to implement it.

I will try to find time to collaborate with a fork but I need to learn first some things about homeassistnat for the UI part.

this would be a great addition indeed

I saw that some users use the SSH addon to make NUT run the commands with the help of automations, even if this solution uses way more steps than I’d like to (an automation that tells an addon to run a script that tells another addon to send a command)

This is something I am also missing. upscmd can give you list of possible commands and the calling of these commands through NUT integration should not be really hard to do.
Has anybody contacted developer to get his feedback on this?

1 Like

You are right, there should be a way to run the upscmd command with this addon, maybe through the integration or with a service call.

Right now I’m sending the commands through SSH:

docker exec addon_a0d7b954_nut upscmd -u username -p password [email protected] command

Hmm, I am looking at the same thing, to control the beeper.

I have protected mode off and when I execute the command in the console I get “No such container: addon_a0d7b954_nut”

➜  /config sudo docker exec addon_a0d7b954_nut /usr/bin/upscmd -u monuser -p xxx -l eatonElipse
Error: No such container: addon_a0d7b954_nut

does the nut integration always use this container ID and how can I find the container ID of an integration, I see nothing in the logs that shows this unique id ?

OK, I can see that there is no addon “addon_a0d7b954_nut” by running docker container list | grep "addon_"

but I have the nut integration working and it is monitoring my nut server ?

1 Like

The nut integration is used when you want HA to become a client of an existing NUT server. It pulls info from it into sensors and such so you can use that info in automations.

The NUT addon is a NUT server. It’s used when you have a UPS attached to the HA machine. Then HA can use the NUT integration to talk to the addon and pull in info from that UPS.

Also in general integrations are part of HA. They don’t run in a separate container or even a separate process, they’re just HA. If you use them the code is loaded, if not then it’s not.

Addons are entirely separate software. They run in their own docker container. It’s often possible to load/configure an integration in HA which then talks to them (Mqtt, nut, influx, etc). Sometimes they only talk to HA (nginx ssl proxy, node red, studio code server, etc). Sometimes they just completely do their own thing alongside HA (let’s encrypt, duckdns, bitwarden, bookstacks, etc). It varies.

2 Likes

Thanks so much for helping.

Yes I just figured that out :slight_smile:

nut is running in proxmox host, just figured out how to ssh into the prox host and execute a command.

1 Like

I submitted a pull request to add a new service to run the commands. Let’s see if it makes it to the next release.

In the next iteration I can add a sensor with the available commands.

My Cyber Power unit was displaying that the battery was healthy but in reality it was not. The unit failed a couple of times when we lost power, so I decided to run a self test and it failed again. With the new service I can run periodic self tests and be alerted about when it is time to replace the battery again.

2 Likes

That is really nice to hear! Could you inform us when it will be released?

Just one question - how it will be possible then to issue commands? If you are able to provide some examples/how to’s, it would really be nice.

I believe in the release of April 2023, since it looks like we just missed the cutoff date for the March one (the pull request is still open).

The commands will show up as device actions, meaning that you can use them in automations. My initial idea was to use services, but after some discussion we agreed that device actions were a better fit.

I am attaching a screenshot from my local dev environment. Apologies for the delayed response, somehow I had missed your comment.

2 Likes

I also created a separate feature request to include a new section under Developer Tools to run device actions easily.

2 Likes

Is this locked down for the April release? Thanks!

The PR has not had activity for some time and is still pending approval, so I guess it won’t be included in the April release. I just pinged the reviewer to see if there is anything else required from my end.

1 Like

Here’s hoping @bdraco can move this forward soon.

Thanks for all your work so far, @pmestevez :muscle:

1 Like

The wait is over :tada:. The ability to run commands as device actions made it to the May 2023 release. The NUT integration now includes a section dedicated to Device Actions.

3 Likes

can this be used to change battery.date or other variables? and how do I execute the commands. in your link it shows upscmd -l and and example, but I don’t know where to input the commands.