Air Raid Siren (UA)
Air Raid Siren status through siren.pp.ua api
| System | AWTRIX NG Scripts |
|---|---|
| Firmware | AWTRIX NG |
| Topic | Miscellaneous |
| Built by | Set |
| File | wZUz9Gn30hm0.ax · 4.0 KB |
| Icons | 2 |
| Published | 24 Aug 2026 · updated 24 Aug 2026 |
| Downloads | 2 |
Air Raid Siren status through siren.pp.ua api with manual region selecting.
wZUz9Gn30hm0.ax
# @name Air Raid Siren (UA)
# @desc Статус повітряної тривоги
# @author Set
# @version 16.0
# @config api_url text "URL API/Проксі" default="https://siren.pp.ua/api/v3/alerts/" help="Базовий URL API (після нього додається ID регіону)"
# @config region_id text "ID регіону" default="353" help="ID з siren.pp.ua/api/v3/regions"
# @config text_alarm text "Текст тривоги" default="ТРИВОГА"
# @config text_clear text "Текст відбою" default="ЧИСТО"
# @config ic_alarm text "Іконка тривоги" default="608" help="ID іконки при тривозі"
# @config ic_clear text "Іконка відбою" default="1221" help="ID іконки коли чисто"
# @config color_alarm color "Колір тривоги" default=#FF0000
# @config color_clear color "Колір відбою" default=#00FF00
class AirRaidSiren
var text_alarm, text_clear, ic_alarm, ic_clear, color_alarm, color_clear
var label, tcol, wic, is_alarm
var ticks, age
def init()
self.text_alarm = store.get("text_alarm")
if self.text_alarm == nil || self.text_alarm == "" self.text_alarm = "ТРИВОГА" end
self.text_clear = store.get("text_clear")
if self.text_clear == nil || self.text_clear == "" self.text_clear = "ЧИСТО" end
self.ic_alarm = store.get("ic_alarm")
if self.ic_alarm == nil || self.ic_alarm == "" self.ic_alarm = "608" end
self.ic_clear = store.get("ic_clear")
if self.ic_clear == nil || self.ic_clear == "" self.ic_clear = "1221" end
self.color_alarm = store.get("color_alarm")
if self.color_alarm == nil self.color_alarm = 0xFF0000 end
self.color_clear = store.get("color_clear")
if self.color_clear == nil self.color_clear = 0x00FF00 end
self.is_alarm = store.get("is_alarm", false)
self.label = store.get("label", self.text_clear)
self.tcol = store.get("tcol", self.color_clear)
self.wic = store.get("wic", self.ic_clear)
self.ticks = 0
self.age = 0
end
def on_body(body, status)
if status != 200 || body == nil return end
# Перевірка відповіді: очікуємо 1 або 0 від проксі (або застарілий "type")
var state = false
if body == "1" || re.search("^\\s*1\\s*$", body) != nil || re.search("\"type\"", body) != nil
state = true
end
self.is_alarm = state
if self.is_alarm
self.label = self.text_alarm
self.tcol = self.color_alarm
self.wic = self.ic_alarm
else
self.label = self.text_clear
self.tcol = self.color_clear
self.wic = self.ic_clear
end
self.age = 0
store.set("label", self.label)
store.set("tcol", self.tcol)
store.set("wic", self.wic)
store.set("is_alarm", self.is_alarm)
end
def loop()
self.age += 1
if self.ticks <= 0
self.ticks = 30 # Опитування кожні 30 секунд
var base_url = store.get("api_url")
if base_url == nil || base_url == "" base_url = "https://siren.pp.ua/api/v3/alerts/" end
var rid = store.get("region_id")
if rid == nil || rid == "" rid = "353" end
var full_url = base_url + str(rid)
http.get(full_url, / b, st -> self.on_body(b, st))
end
self.ticks -= 1
end
def draw()
clear()
# Малюємо іконку або фолбек-коло
if !icon(self.wic, 0, 0)
circle_fill(4, 4, 3, self.tcol)
end
# Основний текст
scroll_text(9, 6, width() - 9, self.label, self.tcol)
# Червоний піксель помилки [31, 7], якщо немає відповіді понад 3 хвилини
if self.age > 180
pixel(31, 7, 0xFF0000)
end
end
def on_button(btn)
if btn == "select" self.ticks = 0 end
end
end
return AirRaidSiren()
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
More flows for AWTRIX NG Scripts or Miscellaneous
Something wrong with this flow? Report it.