Python3 based Docker for Eagle to MQTT reader.
I only ported this to rPI4. Evanrich ported this into a dockerfile, All Original code (with one minor modification for XML root tag) is credit to Ted Drain - TD22057.
Clone the git repository to your Raspberry Pi, and change to that directory. Make sure dockler
is installed.
Check that docker works
docker run hello-world
Add our Docker/src/
to the python:3.8-slim
base image; install our dependencies (from Docker/requirements.txt
); specify the startup command and expose port 22042. Tag the image as py-eagle-mqtt
docker build -t py-eagle-mqtt Docker
docker images
Create a writable container on this Docker image
docker create \
--name=py-eagle-mqtt \
-e MQTT_BROKER_IP=<broker ip address> \
-e MQTT_BROKER_PORT=1883 \
-e KEEPALIVE=60 \
-e MQTT_USER=<username> \
-e MQTT_PASSWORD=<password> \
-p 22042:22042 \
py-eagle-mqtt
We use the systemd
service to create and run a Docker container on this Docker image. On the rPI, install the systemd service and configure its parameters
sudo cp systemd/py-eagle-mqtt.service /etc/systemd/system/
sudo systemctl enable py-eagle-mqtt
sudo systemctl start py-eagle-mqtt
systemctl status py-eagle-mqtt
Check that it is listening on port 22042 (sudo netstat -lnp4
). Note that netstat
incorrectly doesn't always show the tcp port, but shows the tcp6 port as listening.
Go to the Rainforest Portal, and add a custom upload destination. (When greeted with a bank page, with the console complaining the "Content-Security-Policy" header, then try Incognito mode)
- Protocol = HTTPS
- Hostname = your public hostname (use a referse proxy such as
nginx
orpound
on your access router to forward) - URL = /
- port = 443
- no username or password
- Format = XML (Raw)
A replacement for the rainforest_eagle
on Home Asistant.
First, configure your MQTT broker.
To use this with Home Assistant, expand configuration.yaml
with
sensor:
- platform: mqtt
name: "Total pwr"
state_topic: "power/elec/Home/power"
unit_of_measurement: 'W'
device_class: power
value_template: "{{ value_json.power }}"
- platform: mqtt
name: "Total kWh"
state_topic: "power/elec/Home/energy"
unit_of_measurement: 'kWh'
device_class: power
value_template: "{{ value_json.consumed }}"
- platform: mqtt
name: "Price per kWh"
state_topic: "power/elec/Home/price"
unit_of_measurement: '$'
device_class: power
value_template: "Tier {{ value_json.tier }} at {{ value_json.price }}"
FYI I host both the py-eagle-mqtt
and hassio
on a Raspberry Pi 4 (link) running of an external NVMe.
2020-03-23: Updated astral to 2.1, bumped version to 1.6.4
2020-03-23: Just wanted to say, I hope everyone is hanging in there with the #coronavirus pandemic going on. This project is still maintained, but I haven't had a lot of free time to work on it lately. Now that I'm permanently working from home (until the virus goes away), I'll try and dedicate more time to updating this! Thanks for your support, and stay safe!
2020-01-02: Rebase to python:alpine (currently 3.8.1-alpine3.11) to make future builds easier)
2019-12-11: Rebase to python 3.8.0-alpine3.10, update bottle to 0.12.18 and paho-mqtt to 1.5.0
2019-07-24: Rebase to python 3.7.4-alpine3.10, update bottle to 0.12.17
2019-04-12: Rebase to python 3.7.3-alpine3.9
2019-03-08: Rebase to python 3.7.2-alpine3.9, update bottle and astral versions to latest
2019-01-03: Rebase to python 3.7.2-alpine3.8, changed logging level to Info (should output to /var/log/tHome/eagle.log)
2018-09-10: Ported to Python3, Added pricing info. Merged into master branch
docker create \
--name=py-eagle-mqtt \
-e MQTT_BROKER_IP=<broker ip address> \
-e MQTT_BROKER_PORT=<broker port number> \
-e KEEPALIVE=<keepalive time in seconds> \
-e MQTT_USER=<username>
-e MQTT_PASSWORD=<password>
-p 22042:22042 \
evanrich/py-eagle-mqtt
Parameter | Function |
---|---|
-e MQTT_BROKER_IP |
The IP address of your MQTT Broker |
-e MQTT_BROKER_PORT |
The PORT your MQTT Broker listens on. Defaults to 1883 if not specified |
Parameter | Function |
---|---|
-e KEEPALIVE |
Keepalive time in seconds. Defaults to 60 seconds if not specified |
-e MQTT_USER |
The User Name for your MQTT Broker if you use one. Defaults to None if not specified |
-e MQTT_PASSWORD |
The Password for your MQTT Broker if you use one. Defaults to None if not specified |
snippet from my MQTT Broker showing container connecting and dissconnecting when I start/stop it:
{"pid":1,"hostname":"mqtt-867c776494-6rc57","name":"mosca","level":30,"time":1535955884767,"msg":"client connected","client":"","v":1}
{"pid":1,"hostname":"mqtt-867c776494-6rc57","name":"mosca","level":30,"time":1535955905640,"msg":"closed","client":"","v":1}
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Original Readme as follows from creator, Ted Drain. You can view the original repo this is based on here: https://github.com/TD22057/T-Home
A collection of scripts and utilities for various home automation projects.
- bin/ Command line tools
- conf/ Sample config files
- init.d/ Init.d style Linux start up scripts
- python/ Main scripting library
- systemd/ Systemd (latest Raspian) start up scripts
- upstart/ Upstart (Ubuntu 14.04) style start up scripts
Currently most of the scripts read data from various sources and translate the data into JSON'ed dictionaries which get published to a MQTT message broker.
http://rainforestautomation.com/rfa-z109-eagle/
python/tHome/eagle contains code for reading data directly from an Eagle energy monitor. Use bin/tHome-eagle.py to start a small web server and set the address as the "cloud provider" in the Eagle. The Eagle will publish energy data to the server which will converts it into a message and publishes that as a MQTT messages.