Wetter Script
Wetter, 15-Stunden-Prognose und Mondphase
| System | AWTRIX NG Scripts |
|---|---|
| Firmware | AWTRIX NG |
| Topic | Miscellaneous |
| Built by | Hank_the_Tank |
| File | fGEhP0cZZd6E.ax · 4.4 KB |
| Icons | 22 |
| Published | 31 Jul 2026 · updated 31 Jul 2026 |
Weather 3.0 for AWTRIX NG
A compact and memory-optimized weather app for AWTRIX NG. The script displays the current outdoor temperature, current weather conditions, a color-coded 15-hour temperature forecast, and the current moon phase on a 32×8 pixel matrix.
Weather data is provided by Open-Meteo. No user account or API key is required.
Display layout
The display is divided into four areas:
- left: icon for the current weather conditions
- center: current temperature rounded to a whole degree
- right: icon for the current moon phase
- below the temperature: 15 colored pixels showing the temperature trend for the next 15 hours
Each forecast pixel represents approximately one hour. Its color indicates the expected temperature range:
- Purple and dark blue: very cold
- Light blue: cool
- Green: mild
- Yellow: warm
- Orange and red: hot
The current temperature is also shown in a color matching its value.
Features
- current outdoor temperature
- current conditions based on the WMO weather code
- 15-hour temperature forecast
- automatically calculated moon phase
- weather updates approximately every five minutes
- manual refresh using the middle button
- storage of the last known temperature label, color, and weather icon
- immediate display of the last known values after a restart
- red status pixel for previously loaded weather data that has become outdated
- no API key required
- particularly low RAM usage
Memory optimization
The script has been optimized specifically for the limited memory available on AWTRIX NG devices.
Instead of loading the complete Open-Meteo response and converting it into a large JSON object tree, it keeps only a small response window of up to 640 bytes. The required values are then extracted using regular expressions.
This significantly reduces memory usage and allows the script to run more reliably alongside other scripts, particularly on devices without PSRAM.
Updates and data age
Weather data is requested from Open-Meteo approximately every five minutes.
After a successful request, the data-age counter is reset. If the last successfully loaded data is more than approximately 20 minutes old, a red pixel appears in the bottom-right corner.
The red pixel indicates that the displayed values may no longer be current. In this case, check the Wi-Fi connection, internet access, and the AWTRIX device log.
Note: If no weather data has ever been loaded or stored successfully, the script only displays
.... The red pixel is not drawn in this initial state. It appears only when existing weather data later becomes outdated.
Controls
Pressing the middle button on the AWTRIX NG immediately requests fresh weather data.
The app otherwise uses the global app duration and rotation settings configured on the AWTRIX NG.
Changing the location
Before sharing or installing the script, the coordinates should be changed to the user's location.
The relevant line is located in the section marked Standort hier setzen:
"?latitude=52.52&longitude=13.40"
latitudeis the geographic latitude.longitudeis the geographic longitude.
The included values 52.52, 13.40 point to the Berlin area in Germany. Other users must replace them with their own coordinates.
Coordinates can be found using OpenStreetMap or another mapping service.
Required weather icons
The following icon IDs are used for the current weather conditions:
53386– clear sky2286– partly cloudy53384– overcast17055– fog2720– rain or drizzle2289– snow49300– rain showers29839– thunderstorm36637– unknown or unmapped weather condition
If the selected weather icon is unavailable, the script draws a small yellow sun as a fallback.
Required moon-phase icons
The following icon IDs are used for the moon phases:
23182319232023212314231523162317
These icons must be stored on the AWTRIX NG before the script is used. There is currently no drawn fallback for a missing moon-phase icon.
After saving, the script automatically requests its first weather data. Until the first successful request completes, the display shows ....
Requirements
- AWTRIX NG with scripting enabled
- working Wi-Fi and internet connection
- access to
https://api.open-meteo.com - required weather and moon-phase icons stored on the device
- tested with AWTRIX NG firmware
1.0.9-dev
Privacy
The script sends only the configured geographic coordinates to Open-Meteo.
It requires:
- no user account
- no API key
- no personal credentials
- no Home Assistant or MQTT connection
The HTTPS connection is encrypted. As is standard for AWTRIX NG scripts, the firmware does not verify the remote certificate.
Troubleshooting
The display only shows ...
The AWTRIX NG has not yet received valid weather data. Check the following:
- Is the device connected to Wi-Fi?
- Does it have internet access?
- Is
api.open-meteo.comreachable? - Are the configured coordinates valid?
- Is the script included in the app rotation?
A red pixel appears in the bottom-right corner
The last successfully loaded weather data is more than approximately 20 minutes old. The rest of the display continues to show the last known values.
The weather icon is missing
Check whether the required icon ID is stored on the AWTRIX NG. If a weather icon is missing, the script should draw a small yellow sun as a fallback.
The moon phase is missing
The corresponding moon-phase icon is probably not stored on the device.
The display shows ERR:Weather or ERR:Wetter
The script encountered a syntax or runtime error. The full error message is shown next to the script in the web interface and in the device log.
Credits
- Weather data: Open-Meteo
- Firmware and scripting system: Blueforcer / AWTRIX NG
- Weather app: Hank_the_Tank / Codex
- Memory optimization: with support from the AWTRIX NG developer
fGEhP0cZZd6E.ax
# @name Wetter
# @desc Wetter, 15-Stunden-Prognose und Mondphase
# @author Hank_the_Tank / Codex
# @version 3.0
class Weather
var st, fc, label, tcol, wic, mic, mday, ticks, busy, age
def init()
# Farbstufen: Untergrenze, Farbe - dazwischen wird interpoliert
self.st = [-12, 0xD977DF, -6, 0x9545BC, -1, 0x4B379C, 0, 0xFEC4FF,
4, 0x31B8DB, 10, 0x31DB8B, 15, 0x6ED228, 21, 0xFFFF28,
27, 0xF87E27, 32, 0xCF3927, 38, 0xA12527]
self.fc = []
self.label = store.get("label")
self.tcol = store.get("col", 0x666666)
self.wic = store.get("icon", "")
self.mic = ""
self.mday = -1
self.ticks = 0
self.busy = false
self.age = 9999
end
def on_body(w, status)
self.busy = false
if w == nil return end
var m = re.search("_2m\":([-0-9.]+)", w)
var c = re.search("code\":(\\d+)", w)
var h = re.search("_2m\":\\[([^\\]]*)", w)
if m == nil || c == nil || h == nil return end
var t = num(m[1])
if t == nil return end
# i == 0 ist die aktuelle Temperatur, danach die Stundenwerte
var s = self.st
var vals = re.matchall("[-0-9.]+", h[1])
var n = size(vals)
if n > 15 n = 15 end
var fc = []
var i = 0
while i <= n
var v = i == 0 ? t : num(vals[i - 1])
var col = s[1]
if v > s[0]
var j = 0
while j < 20 && v >= s[j + 2]
j += 2
end
if j >= 20
col = s[21]
else
var a = s[j + 1]
var b = s[j + 3]
var f = (v - s[j]) * 1.0 / (s[j + 2] - s[j])
col = rgb(int(a / 65536 % 256 + (b / 65536 % 256 - a / 65536 % 256) * f),
int(a / 256 % 256 + (b / 256 % 256 - a / 256 % 256) * f),
int(a % 256 + (b % 256 - a % 256) * f))
end
end
if i == 0
self.tcol = col
else
fc.push(col)
end
i += 1
end
self.fc = fc
self.label = str(int(t + (t >= 0 ? 0.5 : -0.5))) + "°"
var k = int(num(c[1]))
var ic = "36637"
if k == 0 ic = "53386"
elif k <= 2 ic = "2286"
elif k == 3 ic = "53384"
elif k <= 48 ic = "17055"
elif k <= 67 ic = "2720"
elif k <= 77 ic = "2289"
elif k <= 82 ic = "49300"
elif k <= 86 ic = "2289"
elif k >= 95 ic = "29839"
end
self.wic = ic
self.age = 0
store.set("label", self.label)
store.set("col", self.tcol)
store.set("icon", ic)
end
def loop()
var d = day()
if d != self.mday
self.mday = d
var mo = month()
var a = int((14 - mo) / 12)
var yy = year() + 4800 - a
var mm = mo + 12 * a - 3
var f = (d + int((153 * mm + 2) / 5) + 365 * yy + int(yy / 4) -
int(yy / 100) + int(yy / 400) - 2483595) / 29.53058867
f -= int(f)
var ic = "2317"
if f < 0.03 || f >= 0.97 ic = "2318"
elif f < 0.22 ic = "2319"
elif f < 0.28 ic = "2320"
elif f < 0.48 ic = "2321"
elif f < 0.52 ic = "2314"
elif f < 0.72 ic = "2315"
elif f < 0.78 ic = "2316"
end
self.mic = ic
end
self.age += 1
if self.ticks <= 0
self.ticks = 300
if !self.busy
self.busy = true
http.get("https://api.open-meteo.com/v1/forecast" +
# ---- Standort hier setzen ----
"?latitude=52.52&longitude=13.40" +
# ------------------------------
"¤t=temperature_2m,weather_code&hourly=temperature_2m" +
"&forecast_hours=15&timeformat=unixtime&timezone=auto",
/ b, st -> self.on_body(b, st),
{'find': "\"current\":", 'keep': 640})
end
end
self.ticks -= 1
end
def draw()
clear()
if self.label == nil
text(6, 6, "...", 0x666666)
return
end
if !icon(self.wic, 0, 0)
circle_fill(4, 4, 3, 0xFFCC00)
end
text(9 + int((14 - text_ink_width(self.label)) / 2), 6, self.label, self.tcol)
icon(self.mic, 23, 0)
var i = 0
var n = size(self.fc)
while i < n
pixel(8 + i, 7, self.fc[i])
i += 1
end
if self.age > 1200
pixel(width() - 1, height() - 1, 0xFF0000)
end
end
def on_button(btn)
if btn == "select" self.ticks = 0 end
end
end
return Weather()
Install it on your AWTRIX NG
Your browser writes the script straight to the device on your network. It joins the app rotation right away.
Some browsers refuse to talk to a device on your network from a public page. Download the flow and paste it into the Scripts tab of your device, or install it from a terminal:
These icons belong on the device, in /ICONS. Each one is at
most 32×8
pixels — shown here magnified, at their real proportions.
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
8×8 px
More flows for AWTRIX NG Scripts or Miscellaneous
Something wrong with this flow? Report it.