This is a Hackergarden project, started during 50th Hackergarden 2025-04-01 at codecentric AG, IndustriestraĂźe 3, 70565 Stuttgart, Germany.
Maintained by: Michael Oberdorf IT-Consulting
Source code: GitHub
Container image: DockerHub
The application will make an Open Meteo free weather API call to get weather information for the configured geo coordinates.
There are currently two MODES specified:
current: will get the current weathertomorrow: will get the weather for tomorrow
The results will be parsed, formatted in JSON and published via MQTT.
{
"location": {
"latitude": 48.779998779296875,
"longitude": 8.940000534057617,
"elevation": 409
},
"timezone": {
"name": "Europe/Berlin",
"abbreviation": "GMT+1",
"utc_offset_seconds": 3600
},
"current": {
"time": "2026-01-06T09:45:00+01:00",
"temperature_2m": -6.849999904632568,
"relative_humidity_2m": 89,
"is_day": 1,
"rain": 0,
"showers": 0,
"snowfall": 0,
"weather_code": 71,
"cloud_cover": 100,
"surface_pressure": 967.1641845703125,
"wind_speed_10m": 2.0364675521850586,
"wind_direction_10m": 224.99989318847656,
"wind_gusts_10m": 4.320000171661377,
"weather_code_text": "Snow fall: Slight intensity"
},
"message_timestamp": "2026-01-06T09:59:13.119176+01:00"
}{
"location": {
"latitude": 48.779998779296875,
"longitude": 8.940000534057617,
"elevation": 409
},
"timezone": {
"name": "Europe/Berlin",
"abbreviation": "GMT+1",
"utc_offset_seconds": 3600
},
"tomorrow": {
"date": "2026-01-07",
"temperature_2m_mean": -5.241146087646484,
"temperature_2m_min": -8.211000442504883,
"temperature_2m_max": -3.510999917984009,
"rain_sum": 0,
"showers_sum": 0,
"snowfall_sum": 0,
"weather_code": 3,
"wind_speed_10m_mean": 6.99040412902832,
"wind_speed_10m_min": 1.9386591911315918,
"wind_speed_10m_max": 13.10419750213623,
"wind_direction_10m_dominant": 194.28439331054688,
"wind_gusts_10m_mean": 13.739999771118164,
"wind_gusts_10m_min": 5.039999961853027,
"wind_gusts_10m_max": 25.559999465942383,
"sunrise": 0,
"sunset": 0,
"daylight_duration": 30511.171875,
"sunshine_duration": 23594.3828125,
"surface_pressure_mean": 964.9620971679688,
"surface_pressure_min": 961.7695922851562,
"surface_pressure_max": 968.2794189453125,
"relative_humidity_2m_mean": 80.78125,
"relative_humidity_2m_min": 69,
"relative_humidity_2m_max": 89,
"weather_code_text": "Cloudy"
},
"message_timestamp": "2026-01-06T09:57:42.813048+01:00"
}The container grab some configuration via environment variables.
| Environment variable name | Description | Required | Default value |
|---|---|---|---|
MODE |
The weather selection mode. Currently supported is current and tomorow. |
optional | current |
LATITUDE |
The geo coordinate latitude from where we want to have the weather. | optional | 48.72592 |
LONGITUDE |
The geo coordinate longitude from where we want to have the weather. | optional | 9.11446 |
ELEVATION |
The ground elevation from where we want to have the weather. | optional | |
WEATHER_MODELS |
The weather model to use. | optional | |
TZ |
The time zone to use to provide timestamps. | optional | UTC |
MQTT_CLIENT_ID |
A MQTT client identifier. | optional | |
MQTT_PROTOCOL_VERSION |
The MQTT protocol version to use. Currently supported 3 (means 3.1.1) and 5. |
optional | 3 |
MQTT_TLS |
Use TLS encrypted connection to MQTT broker. | optional | false |
MQTT_TLS_INSECURE |
Disable TLS certificate and hostname verification. | optional | false |
REQUESTS_CA_BUNDLE |
Path to certificates of trusted certificate authorities. | optional | /etc/ssl/certs/ca-certificates.crt |
MQTT_USERNAME |
Username to authenticate to MQTT broker. | optional | |
MQTT_PASSWORD |
Password to authenticate to MQTT broker. | optional | |
MQTT_PASSWORD_FILE |
File that contains the password to authenticate to MQTT broker. | optional | |
MQTT_SERVER |
MQTT broker hostname to connect to. | optional | test.mosquitto.org |
MQTT_PORT |
MQTT broker TCP port to connect to. | optional | 1883 |
MQTT_RETAIN |
Publish MQTT message in retain mode fpr persistance. | optional | false |
MQTT_TOPIC |
The MQTT topic to publish the weather data. | optional | com/github/cybcon/docker.weather2mqtt.git/weather |
CACHE_DIR |
Directory used for API request caching. | optional | /app/cache |
CACHE_EXPIRY_AFTER_SEC |
Cache expiration time in seconds. | optional | 600 |
DEBUG |
Enable debug output log. | optional | false |
If you use direnv to load your environment automatically.
export TZ="Europe/Berlin"
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
export DEBUG="true"
export MODE="current"
export LATITUDE="48.72592"
export LONGITUDE="9.11446"
export WEATHER_MODELS="icon_d2"
export MQTT_SERVER="test.mosquitto.org"
export MQTT_PORT="8883"
export MQTT_TLS="true"
export MQTT_TLS_INSECURE="true"
export MQTT_CLIENT_ID="acd2b765-e289-49c1-9884-28826f619d2b"
export MQTT_PROTOCOL_VERSION="5"
export MQTT_TOPIC="github.com/cybcon/docker.weather2mqtt.git/weather"
export CACHE_DIR="../cache"
export CACHE_EXPIRY_AFTER_SEC="600"The modes (current and tomorrow) are defined in configuration files. That can be found here:
| Mode | Configuration file in GIT | Location in the container image |
|---|---|---|
current |
./src/app/etc/current.json |
/app/etc/current.json |
tomorrow |
./src/app/etc/tomorrow.json |
/app/etc/tomorrow.json |
The files specifies the API call request body for Open Mateo. A documentation of the free weather API can be found here: https://open-meteo.com/en/docs.
To trigger the Python unit tests please follow following instrructions after checkout the git repository.
pip install -r src/requirements.txt
pip install -r test/requirements.txtpython -m unittest
pytest
ruff check --select=E9,F63,F7,F82 --target-version=py312 .
ruff check --target-version=py312 .I would appreciate a small donation to support the further development of my open source projects.
Copyright (c) 2025-2026 Michael Oberdorf IT-Consulting
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
