diff --git a/nut/DOCS.md b/nut/DOCS.md index e0943be..8dec81c 100644 --- a/nut/DOCS.md +++ b/nut/DOCS.md @@ -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 diff --git a/nut/config.yaml b/nut/config.yaml index a8f3c1c..e3b9146 100644 --- a/nut/config.yaml +++ b/nut/config.yaml @@ -51,6 +51,7 @@ schema: - name: str driver: str port: str + powervalue: int? config: - str mode: list(netserver|netclient) diff --git a/nut/rootfs/etc/cont-init.d/nut.sh b/nut/rootfs/etc/cont-init.d/nut.sh index 2a5387c..775d5bd 100755 --- a/nut/rootfs/etc/cont-init.d/nut.sh +++ b/nut/rootfs/etc/cont-init.d/nut.sh @@ -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}..." { @@ -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