Weather Script
Weather Script
| System | AWTRIX NG Scripts |
|---|---|
| Firmware | AWTRIX NG |
| Topic | Miscellaneous |
| Built by | bagrue |
| File | QZ0sO0JQb7ut.ax · 10.4 KB |
| Icons | 22 |
| Published | 20 Aug 2026 |
| Downloads | 5 |
A compact and memory-optimized weather app for AWTRIX NG. The script displays the current outdoor temperature, current weather conditions
Weather data is provided by Open-Meteo. No user account or API key is required.
Credits
Weather data: Open-Meteo
Weather app: Hank_the_Tank / Codex
QZ0sO0JQb7ut.ax
# @name Alta Weather 2.3
# @desc Current weather and temperature for Alta Norway
# @author Hank_the_Tank / bagrue
# @version 2.3
# @config latitude number "Latitude" default=69.97 min=-90 max=90 step=0.01
# @config longitude number "Longitude" default=23.27 min=-180 max=180 step=0.01
# @config refresh number "Refresh" default=5 min=1 max=60 unit=min
# @config unit select "Temperature" default=C options=C,F
class Weather
var label
var tcol
var wic
var ticks
var age
var url
var period
var temp_value
var temp_negative
def init()
self.label = "..."
self.tcol = 0x666666
self.wic = "36637"
self.ticks = 0
self.age = 9999
self.temp_value = 0
self.temp_negative = false
self.period = store.get("refresh") * 60
self.url = "https://api.open-meteo.com/v1/forecast" +
"?latitude=" + str(store.get("latitude")) +
"&longitude=" + str(store.get("longitude")) +
"¤t=temperature_2m,weather_code" +
"&timezone=auto"
end
# --------------------------------------------------
# PIXEL
# --------------------------------------------------
def p(x, y)
pixel(x, y, self.tcol)
end
# --------------------------------------------------
# DIGIT
# 6 x 7 pixel font
# --------------------------------------------------
def digit(x, n)
# 0
if n == 0
self.p(x+1, 0)
self.p(x+2, 0)
self.p(x+3, 0)
self.p(x+4, 0)
self.p(x, 1)
self.p(x+1, 1)
self.p(x+4, 1)
self.p(x+5, 1)
self.p(x, 2)
self.p(x+1, 2)
self.p(x+4, 2)
self.p(x+5, 2)
self.p(x, 3)
self.p(x+1, 3)
self.p(x+4, 3)
self.p(x+5, 3)
self.p(x, 4)
self.p(x+1, 4)
self.p(x+4, 4)
self.p(x+5, 4)
self.p(x, 5)
self.p(x+1, 5)
self.p(x+4, 5)
self.p(x+5, 5)
self.p(x+1, 6)
self.p(x+2, 6)
self.p(x+3, 6)
self.p(x+4, 6)
# 1
elif n == 1
self.p(x+2, 0)
self.p(x+3, 0)
self.p(x+1, 1)
self.p(x+2, 1)
self.p(x+3, 1)
self.p(x+2, 2)
self.p(x+3, 2)
self.p(x+2, 3)
self.p(x+3, 3)
self.p(x+2, 4)
self.p(x+3, 4)
self.p(x+2, 5)
self.p(x+3, 5)
self.p(x, 6)
self.p(x+1, 6)
self.p(x+2, 6)
self.p(x+3, 6)
self.p(x+4, 6)
self.p(x+5, 6)
# 2
elif n == 2
self.p(x,1)
self.p(x+1,0)
self.p(x+1,1)
self.p(x+1,4)
self.p(x+2,0)
self.p(x+2,4)
self.p(x+3,0)
self.p(x+4,0)
self.p(x+4,1)
self.p(x+4,2)
self.p(x+5,1)
self.p(x+5,2)
self.p(x+2,3)
self.p(x+3,3)
self.p(x+4,3)
self.p(x,5)
self.p(x,6)
self.p(x+1,5)
self.p(x+1,6)
self.p(x+2,6)
self.p(x+3,6)
self.p(x+4,5)
self.p(x+4,6)
self.p(x+5,5)
self.p(x+5,6)
# 3
elif n == 3
self.p(x+1, 0)
self.p(x+2, 0)
self.p(x+3, 0)
self.p(x+4, 0)
self.p(x, 1)
self.p(x+1, 1)
self.p(x+4, 1)
self.p(x+5, 1)
self.p(x+4, 2)
self.p(x+5, 2)
self.p(x+2, 3)
self.p(x+3, 3)
self.p(x+4, 3)
self.p(x+4, 4)
self.p(x+5, 4)
self.p(x, 5)
self.p(x+1, 5)
self.p(x+4, 5)
self.p(x+5, 5)
self.p(x+1, 6)
self.p(x+2, 6)
self.p(x+3, 6)
self.p(x+4, 6)
# 4
elif n == 4
self.p(x+3, 0)
self.p(x+4, 0)
self.p(x+2, 1)
self.p(x+3, 1)
self.p(x+4, 1)
self.p(x+1, 2)
self.p(x+3, 2)
self.p(x+4, 2)
self.p(x, 3)
self.p(x+3, 3)
self.p(x+4, 3)
self.p(x, 4)
self.p(x+1, 4)
self.p(x+2, 4)
self.p(x+3, 4)
self.p(x+4, 4)
self.p(x+5, 4)
self.p(x+3, 5)
self.p(x+4, 5)
self.p(x+3, 6)
self.p(x+4, 6)
self.p(x+5, 6)
# 5
elif n == 5
self.p(x, 0)
self.p(x+1, 0)
self.p(x+2, 0)
self.p(x+3, 0)
self.p(x+4, 0)
self.p(x+5, 0)
self.p(x, 1)
self.p(x+1, 1)
self.p(x, 2)
self.p(x+1, 2)
self.p(x+2, 2)
self.p(x+3, 2)
self.p(x+4, 2)
self.p(x+4, 3)
self.p(x+5, 3)
self.p(x+4, 4)
self.p(x+5, 4)
self.p(x, 5)
self.p(x+1, 5)
self.p(x+4, 5)
self.p(x+5, 5)
self.p(x+1, 6)
self.p(x+2, 6)
self.p(x+3, 6)
self.p(x+4, 6)
# 6
elif n == 6
self.p(x+2, 0)
self.p(x+3, 0)
self.p(x+4, 0)
self.p(x+1, 1)
self.p(x+2, 1)
self.p(x, 2)
self.p(x+1, 2)
self.p(x, 3)
self.p(x+1, 3)
self.p(x+2, 3)
self.p(x+3, 3)
self.p(x+4, 3)
self.p(x, 4)
self.p(x+1, 4)
self.p(x+4, 4)
self.p(x+5, 4)
self.p(x, 5)
self.p(x+1, 5)
self.p(x+4, 5)
self.p(x+5, 5)
self.p(x+1, 6)
self.p(x+2, 6)
self.p(x+3, 6)
self.p(x+4, 6)
# 7
elif n == 7
self.p(x, 0)
self.p(x+1, 0)
self.p(x+2, 0)
self.p(x+3, 0)
self.p(x+4, 0)
self.p(x+5, 0)
self.p(x, 1)
self.p(x+1, 1)
self.p(x+4, 1)
self.p(x+5, 1)
self.p(x+4, 2)
self.p(x+5, 2)
self.p(x+3, 3)
self.p(x+4, 3)
self.p(x+2, 4)
self.p(x+3, 4)
self.p(x+2, 5)
self.p(x+3, 5)
self.p(x+2, 6)
self.p(x+3, 6)
# 8
elif n == 8
self.p(x+1, 0)
self.p(x+2, 0)
self.p(x+3, 0)
self.p(x+4, 0)
self.p(x, 1)
self.p(x+1, 1)
self.p(x+4, 1)
self.p(x+5, 1)
self.p(x, 2)
self.p(x+1, 2)
self.p(x+4, 2)
self.p(x+5, 2)
self.p(x+1, 3)
self.p(x+2, 3)
self.p(x+3, 3)
self.p(x+4, 3)
self.p(x, 4)
self.p(x+1, 4)
self.p(x+4, 4)
self.p(x+5, 4)
self.p(x, 5)
self.p(x+1, 5)
self.p(x+4, 5)
self.p(x+5, 5)
self.p(x+1, 6)
self.p(x+2, 6)
self.p(x+3, 6)
self.p(x+4, 6)
# 9
elif n == 9
self.p(x+1, 0)
self.p(x+2, 0)
self.p(x+3, 0)
self.p(x+4, 0)
self.p(x, 1)
self.p(x+1, 1)
self.p(x+4, 1)
self.p(x+5, 1)
self.p(x, 2)
self.p(x+1, 2)
self.p(x+4, 2)
self.p(x+5, 2)
self.p(x+1, 3)
self.p(x+2, 3)
self.p(x+3, 3)
self.p(x+4, 3)
self.p(x+5, 3)
self.p(x+4, 4)
self.p(x+5, 4)
self.p(x+3, 5)
self.p(x+4, 5)
self.p(x+1, 6)
self.p(x+2, 6)
self.p(x+3, 6)
end
end
# --------------------------------------------------
# MINUS
# --------------------------------------------------
def minus(x)
self.p(x,3)
self.p(x+1,3)
self.p(x+2,3)
self.p(x+3,3)
self.p(x+4,3)
end
# --------------------------------------------------
# GRADTEGN
# --------------------------------------------------
def degree(x)
self.p(x+2, 0)
self.p(x+3, 0)
self.p(x+1, 1)
self.p(x+4, 1)
self.p(x+1, 2)
self.p(x+4, 2)
self.p(x+2, 3)
self.p(x+3, 3)
end
# --------------------------------------------------
# DRAW TEMPERATURE
# --------------------------------------------------
def draw_temperature()
var t = self.temp_value
# Startposisjon
var x = 11
# Minus
if self.temp_negative
self.minus(x)
x += 7
end
# Temperatur 0-9
if t < 10
self.digit(x, t)
x += 7
# Temperatur 10-99
else
var tens = int(t / 10)
var ones = t - tens * 10
self.digit(x, tens)
x += 7
self.digit(x, ones)
x += 7
end
# Gradtegn
self.degree(x + 1)
end
# --------------------------------------------------
# WEATHER DATA
# --------------------------------------------------
def on_body(w, status)
if w == nil
return
end
# Aktuell temperatur
var m = re.search("temperature_2m\":([-0-9.]+)", w)
# Værkode
var c = re.search("weather_code\":([0-9]+)", w)
if m == nil || c == nil
return
end
var t = num(m[1])
if t == nil
return
end
# --------------------------------------------------
# TEMPERATURFARGE
# --------------------------------------------------
var col = 0xFFFFFF
if t > 20
col = 0xFF0000
elif t < 0
col = 0x0080FF
end
self.tcol = col
# --------------------------------------------------
# FAHRENHEIT
# --------------------------------------------------
var u = store.get("unit")
if u == "F"
t = t * 1.8 + 32
end
# --------------------------------------------------
# RUNDE TEMPERATUR
# --------------------------------------------------
var ti = int(t + (t >= 0 ? 0.5 : -0.5))
# --------------------------------------------------
# HÅNDTER MINUS UTEN abs()
# --------------------------------------------------
if ti < 0
self.temp_negative = true
self.temp_value = 0 - ti
else
self.temp_negative = false
self.temp_value = ti
end
# --------------------------------------------------
# LABEL
# --------------------------------------------------
if u == "F"
self.label = str(self.temp_value) + "F"
else
self.label = str(self.temp_value) + "°"
end
# --------------------------------------------------
# OPEN-METEO WEATHER CODE
# --------------------------------------------------
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
end
# --------------------------------------------------
# LOOP
# --------------------------------------------------
def loop()
self.age += 1
if self.ticks <= 0
self.ticks = self.period
http.get(
self.url,
/body, status -> self.on_body(body, status),
{
"find": "\"current\":",
"keep": 256
}
)
end
self.ticks -= 1
end
# --------------------------------------------------
# DISPLAY
# --------------------------------------------------
def draw()
clear()
# --------------------------------------------------
# VÆRIKON
# --------------------------------------------------
if !icon(self.wic, 0, 0)
circle_fill(4, 4, 3, 0xFFCC00)
end
# --------------------------------------------------
# TEMPERATUR
# --------------------------------------------------
if self.age < 9999
self.draw_temperature()
else
text(6, 6, "...", 0x666666)
end
# --------------------------------------------------
# GAMLE DATA
# --------------------------------------------------
if self.age > 1200
pixel(width() - 1, height() - 1, 0xFF0000)
end
end
# --------------------------------------------------
# BUTTON
# --------------------------------------------------
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.