Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for nut's powervalue config per-device #292

Merged
merged 2 commits into from
Jun 14, 2023

Conversation

lozzd
Copy link
Contributor

@lozzd lozzd commented Mar 31, 2023

Proposed Changes

I'm monitoring a couple of UPS that don't have any relation to supplying power to the rPI where HA is running, so I want to prevent the battery going flat on those UPS from shutting down the rPI unneccessarily (while also keeping the one UPS that does supply power being able to shut down the rPI)

nut has a concept for this, an option called the "powervalue" in the list of MONITOR configs in upsmon.conf

That value is currently hardcoded to 1, so all UPS that are configured will trigger shutdown if the battery gets low.

From the docs:

# <powervalue> is an integer - the number of power supplies that this UPS
# feeds on this system.  Most computers only have one power supply, so this
# is normally set to 1.  You need a pretty big or special box to have any
# other value here.
#
# You can also set this to 0 for a system that doesn't supply any power,
# but you still want to monitor.  Use this when you want to hear about
# changes for a given UPS without shutting down when it goes critical,
# unless <powervalue> is 0.

This is my attempt to allow that to optionally be set. Since it's not related to the items commonly placed in to the config array on each device, I put it at the top level of teh device, (e.g. like port or driver)

Docs update is in the PR also.

Note that this value does also allow people to introduce the concept of controlled shutdowns if they have two power supplies on their HA host. I assume there are very few people doing this, but it's an option.

I am not experienced in how add-ons are written and tested, so I must admit this is an untested PR.

Thanks!

Related Issues

N/A

nut/config.yaml Outdated Show resolved Hide resolved
@lozzd lozzd requested a review from frenck April 7, 2023 21:31
@github-actions
Copy link

github-actions bot commented May 8, 2023

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label May 8, 2023
@lozzd
Copy link
Contributor Author

lozzd commented May 8, 2023

Boop

@github-actions github-actions bot removed the stale There has not been activity on this issue or PR for quite some time. label May 9, 2023
@github-actions
Copy link

github-actions bot commented Jun 9, 2023

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Jun 9, 2023
@lozzd
Copy link
Contributor Author

lozzd commented Jun 9, 2023

boop

@github-actions github-actions bot removed the stale There has not been activity on this issue or PR for quite some time. label Jun 10, 2023
@frenck frenck added the new-feature New features or options. label Jun 14, 2023
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks @lozzd 👍

../Frenck

@frenck frenck merged commit eb23aec into hassio-addons:main Jun 14, 2023
13 checks passed
@lozzd
Copy link
Contributor Author

lozzd commented Jun 15, 2023

Perfect!

[14:16:19] INFO: Starting the UPS monitor and shutdown controller...
   0.000000	fopen /run/nut/upsmon.pid: No such file or directory
   0.000073	Could not find PID file to see if previous upsmon instance is already running!
   0.000511	Using power down flag file /etc/killpower
   0.000732	UPS: ups-rack@localhost (primary) (power value 1)
   0.000787	UPS: ups-garage@localhost (monitoring only)

Thanks for the merge.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-feature New features or options.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants