Pentagon Pizza Alert

On your display
Pentagon Pizza Alert monitor
- Works with
- AWTRIX NG
- Topic
- Miscellaneous
- Includes
- Script
Choose your display in the next step.
Flow description
Shows the live Pentagon Pizza Alert level on your 32x8 matrix.
What it displays:
- Hand-drawn pizza slice icon on the left (always works, no icon download needed)
- Alert level 5 (green, NORMAL) down to 1 (red, CRITICAL)
- Age of the reading, e.g.
5 3'= level 5, updated 3 minutes ago. Turns orange if the data is older than 30 minutes.100m+folds to hours (2h, capped at99h).
Data source: https://pentagonpizzaalert.com/ (hero level text). Polls every 15 minutes with a tiny ranged request, plus 3 quick retries on failure so the first reading doesn't hang.
Setup:
- Open your AWTRIX web interface (device IP or http://awtrixng-xxxxxx.local).
- Go to the Scripts tab, create a new script named
pizza_alert. - Paste the full script and press Save.
- It joins the rotation automatically. No settings, no configuration needed.
- While it shows
...it is still fetching;No dataappears only after 4 failed attempts. Check the Scripts tab log (p:<level>=<status>) to verify polling.
Tested on AWTRIX NG 1.1.1.
QUsC0hwwSz7v.ax
# @name Pizza Alert
# @desc Pentagon Pizza Alert: pentagonpizzaalert.com
# @version 1.0
# @author EasyAwtrix
class PizzaAlert
var lvl
var col
var show
var tx
var ok
var upd
var busy
var fails
var rt
var wide
def init()
self.lvl = 0
self.col = 0xFFFFFF
self.show = "..."
self.tx = 8
self.ok = 0
self.upd = 0
self.busy = false
self.fails = 0
self.rt = 0
self.wide = false
end
def paint()
var c = 0x00FF00
if self.lvl == 1 c = 0xFF0000
elif self.lvl == 2 c = 0xFF4400
elif self.lvl == 3 c = 0xFF9800
elif self.lvl == 4 c = 0xFFE000
end
if self.lvl <= 0 || self.lvl > 5 return end
self.col = c
self.show = [[str(self.lvl) + " ", c], ["0'", 0x888888]]
self.tx = 8 + (24 - text_ink_width(self.show)) / 2
if self.tx < 8 self.tx = 8 end
end
def fetch()
if self.busy return end
self.busy = true
var rng = "bytes=4096-6999"
if self.wide rng = "bytes=0-9999" end
http.get("https://pentagonpizzaalert.com/", / b, st -> self.onfetch(b, st), {"headers": {"Range": rng}, "find": "Level ", "keep": 32})
end
def onfetch(body, status)
self.busy = false
var good = false
if (status == 200 || status == 206) && body != nil
var m = re.search("Level[^0-9]*?([1-5])", body)
if m != nil
self.lvl = num(m[1], self.lvl)
self.fails = 0
self.ok = now_ms()
self.paint()
good = true
else
self.fails += 1
self.wide = true
log("p:miss " + str(size(body)))
end
else
self.fails += 1
end
if good
self.rt = 0
self.upd = now_ms()
elif self.rt < 3
self.rt += 1
self.upd = now_ms() - 840000
log("p:retry " + str(self.rt))
else
self.rt = 0
self.upd = now_ms()
end
log("p:" + str(self.lvl) + "=" + str(status))
end
def loop()
var now = now_ms()
if self.ok > 0 && self.lvl > 0
var mins = (now - self.ok) / 60000
var agestr = str(mins) + "'"
if mins >= 100
var h = mins / 60
if h > 99 h = 99 end
agestr = str(h) + "h"
end
var ac = 0x888888
if now - self.ok > 1800000 ac = 0xFF9800 end
self.show = [[str(self.lvl) + " ", self.col], [agestr, ac]]
self.tx = 8 + (24 - text_ink_width(self.show)) / 2
if self.tx < 8 self.tx = 8 end
end
if !self.busy && (self.upd == 0 || now - self.upd >= 900000)
self.upd = now
self.fetch()
end
end
def draw()
clear()
if self.lvl <= 0
if self.fails >= 4
scroll_text("No data", 0x888888)
else
scroll_text("...")
end
return
end
rect_fill(0, 0, 8, 1, 0xC97B1A)
rect_fill(0, 1, 8, 1, 0xFFD23F)
rect_fill(1, 2, 6, 2, 0xFFD23F)
rect_fill(2, 4, 4, 2, 0xFFD23F)
rect_fill(3, 6, 2, 2, 0xFFD23F)
pixel(2, 2, 0xE03131)
pixel(5, 3, 0xE03131)
pixel(3, 5, 0xE03131)
text(self.tx, 6, self.show, self.col)
end
end
return PizzaAlert()
Discussion 0
Ask a question, suggest a change or share how you use it.
No comments yet. Start the conversation.
More flows for AWTRIX NG Scripts or Miscellaneous
Something wrong with this flow? Report it.
Have an idea?
Sign in to ask questions and join the conversation.