A small web server to send data from Ecowitt devices to an MQTT Broker
Project description
🔘 ecowitt2mqtt: Send Ecowitt device data to an MQTT broker
ecowitt2mqtt
is a small CLI/web server that allows Ecowitt
device data to be sent to an MQTT broker.
Installation
pip install ecowitt2mqtt
Python Versions
ecowitt2mqtt
is currently supported on:
- Python 3.6
- Python 3.7
- Python 3.8
Usage
Command Line Interface
The library is controlled via an ecowitt2mqtt
executable:
usage: ecowitt2mqtt [-h] --mqtt-broker MQTT_BROKER --mqtt-topic MQTT_TOPIC [--mqtt-port MQTT_PORT] [--mqtt-username MQTT_USERNAME]
[--mqtt-password MQTT_PASSWORD] [--endpoint ENDPOINT] [--port PORT] [-l LOG_LEVEL]
Send data from Ecowitt devices to an MQTT broker
optional arguments:
-h, --help show this help message and exit
--mqtt-broker MQTT_BROKER
The hostname or IP address of the MQTT broker
--mqtt-topic MQTT_TOPIC
The MQTT topic to publish the device's data to
--mqtt-port MQTT_PORT
The port of the MQTT broker (default: 1883)
--mqtt-username MQTT_USERNAME
The username to use with the MQTT broker (default: None)
--mqtt-password MQTT_PASSWORD
The password to use with the MQTT broker (default: None)
--endpoint ENDPOINT The relative endpoint/path to serve the web app on (default: /data/report)
--port PORT The port to serve the web app on (default: 8080)
-l LOG_LEVEL, --log-level LOG_LEVEL
The logging level (default: INFO)
When run with the appropriate parameters, the executable will launch a web server with a
single endpoint (with the default parameters, this endpoint will live at
http://0.0.0.0:8080/data/report
).
When configured as a custom weather service in the WS View app, this endpoint will receive data from the Ecowitt device and publish it to the defined MQTT broker.
(TODO: flesh out these docs more)
Run in the Background
ecowitt2mqtt
doesn't, itself, provide any sort of daemonization mechanism. The suggested
route is to use something like supervisord
:
[supervisord]
nodaemon=true
loglevel=info
user=root
[program:ecowitt2mqtt]
command=ecowitt2mqtt --mqtt-broker=192.168.1.100 --mqtt-topic=My/topic
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
redirect_stderr=true
Docker
The library is available via a Docker image (bachya/ecowitt2mqtt
). It is configured by
a handful of environment variables that correspond to the command line parameters listed
above:
LOG_LEVEL:
the log level to use (default:INFO
)ENDPOINT:
the relative endpoint/path to serve the web app on (default:/data/report
)PORT:
the port to serve the web app on (default:8080
)MQTT_BROKER:
the hostname or IP address of the MQTT brokerMQTT_PORT:
the port of the MQTT broker (default:1883
)MQTT_PASSWORD:
the password to use with the MQTT broker (default:None
)MQTT_USERNAME:
the password to use with the MQTT broker (default:None
)MQTT_TOPIC:
the MQTT topic to publish the device's data to
An example docker-compose
usage can be found in docker-compose.dist.yml
.
Contributing
- Check for open features/bugs or initiate a discussion on one.
- Fork the repository.
- (optional, but highly recommended) Create a virtual environment:
python3 -m venv .venv
- (optional, but highly recommended) Enter the virtual environment:
source ./.venv/bin/activate
- Install the dev environment:
script/setup
- Code your new feature or bug fix.
- Write tests that cover your new functionality.
- Run tests and ensure 100% code coverage:
script/test
- Update
README.md
with any new documentation. - Add yourself to
AUTHORS.md
. - Submit a pull request!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ecowitt2mqtt-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5c3a062d24391d72b387e7d4e31cf768e6f0ee8cfa03d9398649bdff15c471c |
|
MD5 | 109857a71137fdc48a382c7f4066f10f |
|
BLAKE2b-256 | cd6773d452dfd70c8649d9e8bf37f54a8207c3353f01f37dd5dec6572a5152bf |