Skip to content

A recent change to the layout of my house (aka I moved the office to a different room) got me redoing much of my homelab. It also got me thinking, as I unplugged the Nth server from the UPS, that I have what some might consider 'too many' servers.

That, in turn, got me thinking about things like power usage, the gobs of heat these things generate, and the cost of it all running near 24/7. At least from the standpoint of electricity costs.

Looking About the Internet

After poking about on the internet looking for information about measuring power usage, I kept finding info about doing it with a 'Kill A Watt' electricity usage monitor.

That just seemed too easy! I mean, why spend money on this when I can spend time and effort figuring out how to do it with the tools I already have?! (because...you know...my time isn't worth money... 😅 )

I have a pretty snazzy UPS already...and most of my servers are plugged into it. Why not just use that? With that thought in mind whilst searching the web, I stumbled on this lovely post from the blog "technicalramblings.com"

This got me a good jumping off point. Problem was I don't use Unraid.

Can I Do This With Home Assistant?

I had never written an add-on for Home Assistant before. So I had that going against me a bit. That said, I did already have the InfluxDB add-on installed and running in my Home Assistant. I just had to marry things together.

To cut a long story short here, I did it.

APCUPSD InfluxDB Exporter
Screenshot of the add-on in development

I created a Home Assistant Add-on Repository and pushed it to a repo on Codeberg. Right now there are no pre-baked images for it, so if you add this repository to your Home Assistant, Home Assistant will have to build the Docker image. According to some upstream docs for Home Assistant, this adds some wear and tear if you are running Home Assistant on an SD Card. ⚠

If you want to use it, you can add this as a Repository in Home Assistant.

https://codeberg.org/TheQueasle/theterminallife-ha-addon-repo

Or if this magical button works, you can use this instead!

Open your Home Assistant instance and show the add add-on repository dialog
with a specific repository URL
pre-filled.

Add-on Configuration and Prerequisites

The add-on will need some configuration and some prerequisites before you start it up.

You will need to have:

  • An InfluxDB server running and reachable from Home Assistant
    • I just used the InfluxDB add-on within Home Assistant for this
  • An InfluxDB database and user that you can write to the database
    • Again, I'm just leveraging the InfluxDB add-on here
  • An APCUPSD server running and reachable from Home Assistant
    • I did this by adding the APCUPSD plugin to my OPNSense server
    • The OPNSense server has my UPS attached to it via the data cable that came with it.

For configuration of the add-on, each option is documented in the add-on README.

Adding in Grafana to the Mix

The blog post that was an inspiration for this add-on mentions a Grafana dashboard that you can use alongside all of this.

What I did was installed and configured the Grafana Add-on within Home Assistant, connected up InfluxDB to it as a datasource, and imported the dashboard. After all that, I got this lovely dashboard and I can now look at pretty graphs representing my power usage and cost...and still find that it's cheaper to host all this on-site. No cloud for me yet... ☁

Grafana Dashboard
Juicy JUICY Data!

Comments