Air Raid Siren (UA)
Air Raid Siren status through siren.pp.ua api
About this flow
| System | AWTRIX NG Scripts |
|---|---|
| AWTRIX version | AWTRIX NG |
| Topic | Miscellaneous |
| Built by | Set |
| File | wZUz9Gn30hm0.ax · 4.2 KB |
| Icons | 2 |
| Published | 24 Aug 2026 · updated 25 Aug 2026 |
| Downloads | 40 |
Is this your flow?
If you created this flow, open your saved edit link to add it to your account. You can then manage it whenever you sign in. Adding it to your account replaces the edit link.
Flow description
Air Raid Siren status through siren.pp.ua api with manual region selecting.
If status of alert is not working you can use my proxy api http://pda.in.ua/api/gate.php?rid=
It's because our devices can have problem with decoding GZIPed content from origin API and state parser can't solve regular expression.
wZUz9Gn30hm0.ax
# @name Air Raid Siren (UA)
# @desc Статус повітряної тривоги. Наші пристрої мають проблему з декодуванням GZIP тож я зробив своє проксі http://pda.in.ua/api/gate.php?rid=
# @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
log(body)
# Перевірка відповіді: очікуємо 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)
log(full_url)
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
Add this flow to your AWTRIX NG. It will start appearing on your display after installation.
Unable to connect? Download the flow and add it in the Scripts section of your AWTRIX. Advanced users can also use this command:
This flow uses the following icons. Add them to your AWTRIX along with the flow.
8×8 px
8×8 px
Sign in to download these icons or send them to your AWTRIX.
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.