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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions nut/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ specific drivers.
This is the serial port where the UPS is connected. The first serial port
usually is `/dev/ttyS0`. Use `auto` to automatically detect the port.

#### Sub-option: `powervalue`

Optionally lets you set whether this particular UPS provides power to the
device this add-on is running on. Useful if you have multiple UPS that you
wish to monitor, but you don't want low battery on some of them to shut down
this host. Acceptable values are `1` for "providing power to this host" or `0`
for "monitor only". Defaults to `1`

#### Sub-option: `config`

A list of additional [options][ups-fields] to configure for this UPS. The common
Expand Down
1 change: 1 addition & 0 deletions nut/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ schema:
- name: str
driver: str
port: str
powervalue: int?
config:
- str
mode: list(netserver|netclient)
Expand Down
7 changes: 6 additions & 1 deletion nut/rootfs/etc/cont-init.d/nut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ if bashio::config.equals 'mode' 'netserver' ;then
upsname=$(bashio::config "devices[${device}].name")
upsdriver=$(bashio::config "devices[${device}].driver")
upsport=$(bashio::config "devices[${device}].port")
if bashio::config.has_value "devices[${device}].powervalue"; then
upspowervalue=$(bashio::config "devices[${device}].powervalue")
else
upspowervalue="1"
fi

bashio::log.info "Configuring Device named ${upsname}..."
{
Expand All @@ -96,7 +101,7 @@ if bashio::config.equals 'mode' 'netserver' ;then
done
IFS="$OIFS"

echo "MONITOR ${upsname}@localhost 1 upsmonmaster ${upsmonpwd} master" \
echo "MONITOR ${upsname}@localhost ${upspowervalue} upsmonmaster ${upsmonpwd} master" \
>> /etc/nut/upsmon.conf
done

Expand Down