In this article, I will show you how to install and configure WebNUT in Docker and then integrate it into HomeAssistant. WebNUT is a web interface for Network UPS Tools (NUT) that allows you to monitor UPS devices (uninterruptible power supplies) in your network. The integration with HomeAssistant allows you to integrate the UPS data directly into your smart home system, giving you even more control and overview.

What is WebNUT and why should you use it? 🤔

WebNUT is a practical tool for anyone who has a UPS in their network. With WebNUT, you can:

  • Monitor the status of your UPS in real time.
  • Receive alerts and notifications in the event of power outages or other problems.
  • Have centralized management for multiple UPSs.

Through integration with HomeAssistant, you can also create automated actions based on UPS status, such as shutting down devices during power outages or sending notifications.

Preparation: What you need 🛠️

Before we get started, make sure you have the following things:

  • A Docker-enabled server (e.g. a Raspberry Pi or a Raspberry Pi).e.g. a Raspberry Pi or a NAS)
  • An installed and working Docker environment.
  • HomeAssistant (already installed and configured).

Install WebNUT in Docker 🐳

Step 1: Create a Docker container for WebNUT

Create a new Docker container for WebNUT. To do this, open a terminal and execute the following command:

docker run -d \
  --name=webnut \
  -e TZ=Europe/Berlin \
  -p 80:80 \
  --restart unless-stopped \
  --cap-add=NET_ADMIN \
  christronyxyocum/webnut

This command starts a new Docker container for WebNUT with the necessary settings. Make sure that port 80 is available or adjust the port forwarding accordingly.

Step 2: Configure WebNUT

After the container has started, you should edit the configuration file to add your UPS devices. You can find the configuration file under /etc/nut/ups.conf. You can enter the container and edit the file with an editor such as nano:

docker exec -it webnut /bin/bash
nano /etc/nut/ups.conf

Add the information about your UPS to the file, e.g.:

[myups]
    driver = usbhid-ups
    port = auto
    desc = "My UPS"

Save the file and exit the editor. Restart the NUT service for the changes to take effect.

Integrate WebNUT in HomeAssistant 🏠

Step 1: Add NUT integration in HomeAssistant

Open your HomeAssistant instance and go to the integrations. Add a new integration and search for "Network UPS Tools (NUT)". Select it and configure it with the appropriate settings:

  • Host: IP address_your_WebNUT_container
  • Port: 3493
  • Username: Your_NUT_username (if configured)
  • Password: Your_NUT_password (if configured)

Step 2: Use WebNUT in HomeAssistant

After successful configuration, the UPS data should be available in HomeAssistant. You can now create sensors, notifications and automations based on the UPS status. Example of an automation:

alias: 'Notification in case of power failure'
trigger:
  - platform: state
    entity_id: sensor.myups_status
    to: 'OB Discharging'
action:
  - service: notify.notify
    data:
      message: "Attention! Power failure detected. UPS is running on battery power."

Conclusion 🎉

With WebNUT and Docker, you can monitor your UPS easily and effectively. Integration with HomeAssistant also gives you the opportunity to make your smart home even smarter by setting up automated actions based on the UPS status. Have fun setting it up and trying it out!

Why a UPS is essential

An uninterruptible power supply (UPS) protects your hardware from data loss and damage caused by power outages. For home servers, NAS systems, and network infrastructure, a UPS is essential. Without one, a sudden power outage can lead to corrupted file systems, damaged RAID arrays, or loss of unsaved data.

Choosing the right UPS

When selecting a UPS, you should know the total power consumption of your connected devices. A rule of thumb: the UPS should be able to handle at least 130% of the maximum load. For a typical homelab with NAS and switch, 700-1000VA is usually sufficient. Also pay attention to the form factor – rack UPS units are ideal for server cabinets, while tower UPS units offer more flexible placement.

Integration into Home Assistant via WebNUT enables automated responses during power outages: shutting down servers, turning off non-essential consumers, and sending notifications – all before the battery runs out.

Further reading

If you enjoyed this article, you might also find these interesting:

Unraid: The ultimate tool for your home servers 🚀
Discover Unraid: Flexible operating system for home servers, supports Docker & VMs. Easy to install, cost-efficient and perfect for your data management. 🚀
Monitoring non-smart devices 💡
I show you how you can make normal devices smart in a relatively simple way in the article ☝️
Uptime Kuma: Monitor and track the uptime of services 🔎
Learn how to install Uptime Kuma, integrate it into Home Assistant and actively monitor websites! 🔔

Artikel teilen:Share article: