3tc / efergy2mqtt

Publish energy measurements from an Efergy E2 to an MQTT topic.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Efergy2MQTT

When we purchased our new home (in Australia), I discovered a curious white device (photo below) in the meter box. After doing a google image search, I discovered it was an Efergy energy meter (https://efergy.com/efergy-transmitter/), which sounds pretty handy even though the wireless display was nowhere to be found. Efergy E2

Given this was 433Mhz device, I replaced the batteries and started exploring the 433Mhz band with my RTL-SDR dongle, surprisingly I found it's signal, as well as other useful devices owned by my neighbours :)

Thanks to Nathaniel Elijah's work to decode the data sent from an Efergy E2 using the RTL-SDRe, I created this simple (well very rough) python wrapper that creates a json payload from the output of the EfergyRPI_log binary and produces a mqtt message for consumption by HomeAssitant, NodeRed etc...

I have included Nathaniel's source code and a pre-compiled ELF 64binary as a convenience, as the link to the source on his blog is broken. Compilation instructions and the code can be found on Gough Lui's Techzone blog

Parts list

Optional

  • HomeAssistant - For home automation I am using HomeAssistant (aka hassio) on a RaspberryPi 3+ using hassos
  • Grafana
  • InfluxDB

Running

git clone https://github.com/3tc/efergy2mqtt.git
cd efergy2mqtt

# Populate required environment envs into .env
#  pipenv will load .env into the virtual environment 
echo 'EFERGY_BINARY=/path/to/EfergyRPI_log' >> .env
echo 'MQTT_HOST=mqtt.host' >> .env
echo 'MQTT_USER=myMqttUsername' >> .env
echo 'MQTT_PASS=myMqttPassword' >> .env

# Install pipenv
python3 -m pip --user pipenv

# Setup the virtualenv and install dependencies
pipenv install

# Run using pipenv run
./run.sh

# Subscribe to topic
➜ pipenv shell
Loading .env environment variables...
Launching subshell in virtual environment...

(efergy2mqtt) ➜ mosquitto_sub -h $MQTT_HOST -t 'house/energy' -u $MQTT_USER -P $MQTT_PASS -v
house/energy {"consumption_watts": 1320.0}
house/energy {"consumption_watts": 1320.0}

Grafana

Grafana dashboard I already had HomeAssistant pushing temperature readings from the home into InfluxDB to chart temperature readings in Grafana. Adding the energy consumption data to influx was a simple config change in HomeAsssitant, and once the data was being populated in Infux, setting up a dashboard was trivial.

About

Publish energy measurements from an Efergy E2 to an MQTT topic.


Languages

Language:C 93.9%Language:Python 5.8%Language:Shell 0.2%