-
-
Notifications
You must be signed in to change notification settings - Fork 425
Building NUT integration for Home Assistant
Originally posted by @DaftHonk at https://github.com/networkupstools/nut/issues/590#issuecomment-966777679
I built my own container for Home Assistant from NUT master branch.
Clone https://github.com/hassio-addons/addon-nut.git into the addons folder and change nut/Dockerfile to:
ARG BUILD_FROM=ghcr.io/hassio-addons/debian-base/amd64:4.2.0
# hadolint ignore=DL3006
FROM ${BUILD_FROM} as builder
# Setup builder
# hadolint ignore=DL3003
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
git \
python \
autoconf \
automake \
libtool \
libneon27-dev \
libsnmp-dev \
libusb-dev \
libltdl-dev
RUN git clone https://github.com/networkupstools/nut.git \
&& cd nut \
&& ./autogen.sh \
&& ./configure \
--prefix=/usr \
--libexecdir=/usr/lib/nut \
--without-wrap \
--with-user=root \
--with-group=root \
--disable-static \
--with-serial \
--with-usb \
--without-avahi \
--with-snmp \
--with-neon \
--without-powerman \
--without-ipmi \
--without-freeipmi \
--with-libltdl \
--without-cgi \
--with-drvpath=/usr/lib/nut \
--datadir=/usr/share/nut \
--sysconfdir=/etc/nut \
--with-statepath=/var/run/nut \
--with-altpidpath=/var/run/nut \
&& make DESTDIR=/app install \
&& make DESTDIR=/app install-conf
FROM ${BUILD_FROM}
# Setup base
# hadolint ignore=DL3003
RUN \
apt-get update \
&& apt-get install -y --no-install-recommends \
usbutils \
libtool \
openssl \
libsnmp30 \
libneon27-gnutls \
libfreeipmi17 \
libipmimonitoring6 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy root filesystem
COPY rootfs /
COPY --from=builder /app /
# Build arguments
ARG BUILD_ARCH
ARG BUILD_DATE
ARG BUILD_DESCRIPTION
ARG BUILD_NAME
ARG BUILD_REF
ARG BUILD_REPOSITORY
ARG BUILD_VERSION
# Labels
LABEL \
io.hass.name="${BUILD_NAME}" \
io.hass.description="${BUILD_DESCRIPTION}" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="addon" \
io.hass.version=${BUILD_VERSION} \
maintainer="Dale Higgs <dale3h@addons.community>" \
org.opencontainers.image.title="${BUILD_NAME}" \
org.opencontainers.image.description="${BUILD_DESCRIPTION}" \
org.opencontainers.image.vendor="Home Assistant Community Add-ons" \
org.opencontainers.image.authors="Dale Higgs <dale3h@addons.community>" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.url="https://addons.community" \
org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \
org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REF} \
org.opencontainers.image.version=${BUILD_VERSION}
You can likely update to the latest base image, I haven't gotten around to it yet and it's been working just fine. I haven't changed any other values or labels as I haven't published it anywhere. It should then show up as a local addon and you can build it. You may also need to change it obviously if you are using a different arch.
Overall, you need to create a copy of the nut add-on in your addons folder then replace the Dockerfile. The add-on store should see it the n and you can build it from the store the same way you install a normal add-on.
For further questions, check with HA project -- it has some decent docs on developing addons that should help.
Later discussion in #590 suggested this example Dockerfile for the integration: https://github.com/networkupstools/nut/files/7525735/Dockerfile.txt
Article https://telefoncek.si/2022/09/2022-09-21-priklop-ups-na-homeassistant/ (may need Google Translate) details HA setup to pass notifications about NUT events to the mobile app.
Welcome to the Network UPS Tools (NUT) project Wiki, and feel free to contribute tricks and insights.
While there are several good entries in the menu, ones referenced most frequently in issue discussions include:
- Finding recent development iteration artifacts
- Building NUT for in-place upgrades or non-disruptive tests (including the build prerequisites for different platforms in-tree or as a rendered page on NUT website) and Using NIT (NUT Integration Test suite) sandbox
- Technicalities: Customizing (NUT) config files and scripts delivered by packaging
- Links to distribution packaging recipes and repository sections
- Troubleshooting
upsdrvctldrivers not starting ("insufficient permissions on everything" or "Can't claim USB device [VVVV:PPPP]@0/0: Entity not found") possibly due to nut-driver-enumerator (NDE) services having been there before you with NUT 2.8.x, and "insufficient permissions" when starting USB drivers for a different PoV on this; see also an example unit deployment detailed in NUT systemd service units page - Changing NUT daemon debug verbosity
- Building NUT integration for Home Assistant
- Running NUT in an LXC container
- Troubleshooting eventual disconnections (Data stale) and CyberPower Systems (CPS) know-how
- NUT for Windows
- NUT HCL and DDL
- Code contributions, PRs, PGP and DCO
- NUT CI farm
Also keep in mind the documentation links from NUT website and the FAQ in particular.