initial commit
This commit is contained in:
17
upsmon/Dockerfile
Normal file
17
upsmon/Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
||||
ARG BUILD_FROM
|
||||
FROM $BUILD_FROM
|
||||
|
||||
ENV LANG C.UTF-8
|
||||
|
||||
RUN apk add --no-cache jq
|
||||
RUN apk add nut --update-cache --repository http://nl.alpinelinux.org/alpine/edge/testing/
|
||||
|
||||
RUN mkdir /var/run/nut
|
||||
RUN chown root:nut /var/run/nut
|
||||
RUN chmod 770 /var/run/nut
|
||||
|
||||
# Copy data for add-on
|
||||
COPY run.sh /
|
||||
RUN chmod a+x /run.sh
|
||||
|
||||
CMD [ "/run.sh" ]
|
||||
21
upsmon/README.md
Normal file
21
upsmon/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
## Network UPS Tools for Hass.io
|
||||
|
||||
[Network UPS Tools](http://networkupstools.org/) can be used to control and manage several power devices like [Uninterruptible Power Supplies](https://en.wikipedia.org/wiki/Uninterruptible_power_supply). This [Hass.io](https://home-assistant.io/hassio/) plugin provides the nessecary daemon to make use of the [Home Assistant NUT Sensor](https://home-assistant.io/components/sensor.nut/).
|
||||
|
||||
The default configuration should work with any [usbhid-ups](http://networkupstools.org/docs/man/usbhid-ups.html) compatible UPS. They can be added to `configuration.yaml` by adding:
|
||||
|
||||
|
||||
```
|
||||
sensor
|
||||
- platform: nut
|
||||
username: nut
|
||||
password: nut
|
||||
resources:
|
||||
- ups.load
|
||||
- ups.status
|
||||
[...]
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
26
upsmon/config.json
Normal file
26
upsmon/config.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "Network UPS Tools - netclient",
|
||||
"version": "0.1",
|
||||
"slug": "upsmon",
|
||||
"description": "Connect to a remote NUT server",
|
||||
"startup": "before",
|
||||
"boot": "auto",
|
||||
"options": {
|
||||
"credentials": [
|
||||
{ "user": "monuser", "pass": "secret" }
|
||||
],
|
||||
"ups": [
|
||||
{ "upsname": "ups", "host": "IPADDR" }
|
||||
],
|
||||
"delay": "5"
|
||||
},
|
||||
"schema": {
|
||||
"credentials": [
|
||||
{ "user": "str", "pass": "str" }
|
||||
],
|
||||
"ups": [
|
||||
{ "upsname": "str", "host": "str" }
|
||||
],
|
||||
"delay": "int"
|
||||
}
|
||||
}
|
||||
31
upsmon/run.sh
Normal file
31
upsmon/run.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
CONFIG_PATH=/data/options.json
|
||||
|
||||
UPSNAME=$(jq --raw-output ".upsname" $CONFIG_PATH)
|
||||
HOST=$(jq --raw-output ".host" $CONFIG_PATH)
|
||||
USER=$(jq --raw-output ".user" $CONFIG_PATH)
|
||||
PASS=$(jq --raw-output ".pass" $CONFIG_PATH)
|
||||
DELAY=$(jq --raw-output ".delay" $CONFIG_PATH)
|
||||
|
||||
echo "
|
||||
MONITOR ${UPSNAME}@${HOST} 1 ${USER} ${PASS} slave
|
||||
MINSUPPLIES 1
|
||||
SHUTDOWNCMD \"/sbin/shutdown -h +0\"
|
||||
POLLFREQ 5
|
||||
POLLFREQALERT 5
|
||||
HOSTSYNC 15
|
||||
DEADTIME 15
|
||||
POWERDOWNFLAG /etc/killpower
|
||||
RBWARNTIME 43200
|
||||
NOCOMMWARNTIME 300
|
||||
FINALDELAY ${DELAY}
|
||||
" > /etc/nut/upsmon.conf
|
||||
|
||||
echo "MODE=netclient" > /etc/nut/nut.conf
|
||||
|
||||
# change perms on config files
|
||||
chmod 660 /etc/nut/*
|
||||
|
||||
upsmon -D
|
||||
Reference in New Issue
Block a user