Chris Dzombak

Ship electricity usage data from an Energy Bridge to InfluxDB

A while back, I signed up for DTE Energy’s Insight feature, which lets you monitor your home’s electricity usage in real time (and natural gas usage, but only at one-day resolution). To make this work, they ship you a little device called an Energy Bridge, made by a company called Powerley, which connects to your home network and communicates with your smart meter to make energy usage data available.

I had known for a while that it was possible to get real-time electrical usage data via MQTT, and I finally got around to working on this project. I wanted to ship this usage data to a local InfluxDB instance and graph it using Grafana (I have both tools running on a local server already for other purposes). With some pointers from my friend Brandon, I finally got it working, and I made a small open-source Go program for others to use.

First off, you can use the mosquitto_sub CLI tool to preview this data like so. It took me a while to get this working; it seems like the topic name has changed over time, so a lot of info online is out of date; and I didn’t realize I needed to pass a client ID, which is what -i "$(hostname)" is doing in this command:

brew install mosquitto  # (if you don’t have mosquitto available already)
mosquitto_sub -h YOUR_ENERGYBRIDE_IP -p 2883 -t 'event/metering/instantaneous_demand' -i "$(hostname)"

You should see output like this:

{"time":1614009412018,"demand":1493}
{"time":1614009415009,"demand":1461}
# ...

time is the epoch time, in milliseconds, of the measurement; demand is your instantaneous electrical usage measured in watts.

My program energybridge_to_influxdb subscribes to this topic and writes the measurements to InfluxDB. Data points are written to the measurement named instantaneous_usage, under the field watts. The measurements are tagged with the tag energy_bridge_name, which is customizable via the tool’s CLI interface, allowing you to distinguish between multiple Energy Bridges or between test and production instances of energybridge_to_influxdb.

The README covers usage of the tool and includes instructions for deploying it on a Linux system with systemd.

My friend Andy also added Docker support, including automated builds pushed to Docker Hub via GitHub Actions. This is the first time I’ve used GitHub Actions or pushed anything to Docker Hub, but/and I think it’s working smoothly.

You should be able to pull the image from Docker Hub via docker pull cdzombak/energybridge_to_influxdb, and the tool is configurable with environment variables when deployed this way. Let me know if this seems not to work for you.