Pull data from a URL in various formats and pushes the data to an MQTT broker
661
This image runs a python script named data2mqtt which, based on a YAML configuration file, pulls data from URLs (http, https and local file read supported), detects the format automatically (JSON, XML, CSV and YAML are currently supported), parses the data and sends it to an MQTT broker.
Most home automation platforms offer an MQTT broker plugin/integration/adapter and this tool allows to feed data from most RESTful APIs or other sources into these systems without requiring a dedicated adapter.
The container requires a mapping for the configuration file (/opt/config.yaml) and supports various log levels which can be defined with the LOGLEVEL environment variable.
In the newest version, this image contains a web based configuration editor which is started automatically with the data2mqtt program. Per default it listens on port 8833, this can be changed by specifying the port in a WEBPORT environment variable. Please ensure that you map the port if you want to access the (simple) web UI.
The configuration file used in this image is defined as /opt/config.yaml and therefore a mapping needs to exist that provides at least this file (or the whole /opt directory for the container).
The configuration file format looks like this:
configurations:
- name: "default"
url: "https://example.com/data.json"
mqtt_server: "192.168.1.100"
mqtt_port: 1883
prefix: "my/prefix"
username: "user"
password: "pass"
mqttuser: "mqtt_user"
mqttpassword: "mqtt_pass"
verify: "/path/to/ca_bundle.pem"
interval: 10
- name: "backup"
url: "https://backup.example.com/data.json"
mqtt_server: "192.168.1.101"
mqtt_port: 1884
prefix: "backup/prefix"
interval: 20
The configuration file starts with a "configurations:" line. A file can hold multiple configuration sets, each starts with a "- name:" and needs to be indented as required by YAML.
Each configuration set must have the following mandatory "field: value" pairs:
Additional optional parameters are:
It is required to map the configuration file to /opt/config.yaml (or map a directory to /opt).
The TCP port for the configuration editor requires a port mapping, if it should be made accessible. There is currently no security implemented, i.e. no password required to access and change configuration. It is recommended to change the configuration file using an editor or temporarily map the port, edit the configuration and then, before restarting the container, remove the mapping again.
WEBPORT defines the port on which the configuration editor is running (configeditor.py), default is 8833. CFGFILE defines the path to the configuration file used in the container, default here is "/opt/config.yaml". LOGLEVEL defines the log verbosity.
The following log levels are supported:
Everything after 3 can result in a log of log entries and should be avoided until necessary. In production mode, a loglevel of 1 should be used to avoid creating log entries for every request.
Content type
Image
Digest
sha256:b9db55659…
Size
67.1 MB
Last updated
almost 2 years ago
docker pull hgerstung/data2mqtt