Skip to content

Commit

Permalink
Add support for nut's powervalue config per-device (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
lozzd authored Jun 14, 2023
1 parent 1d09c70 commit eb23aec
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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

0 comments on commit eb23aec

Please sign in to comment.