I am using ESP8266 with firmware Build: ESP_Easy_mega_20221105_normal_ESP8266_4M1M Nov 5 2022
A relay is connected to GPIO 12, which turns on a red or green light depending on the received RULES command:
Code: Select all
On gled do
gpio,12,1
endon
On rled do
gpio,12,2
endon
The script every minute makes an API request https://api.alerts.in.ua/v1/alerts/acti ... _APP_TOKEN> and receives a response of the type
If the answer contains: "location_oblast":"м. Київ" - the rled command is sent, respectively, if it does not contain - gled.{"alerts":[{"id":8757,"location_title":"Луганська область","location_type":"oblast","started_at":"2022-04-04T16:45:39.000Z","finished_at":null,"updated_at":"2022-04-08T08:04:26.316Z","alert_type":"air_raid","location_oblast":"Луганська область","location_uid":"16","notes":null,"calculated":null,"location_oblast_uid":16},{"id":28288,"location_title":"Автономна Республіка Крим","location_type":"oblast","started_at":"2022-12-10T22:22:00.000Z","finished_at":null,"updated_at":"2022-12-12T12:20:11.900Z","alert_type":"air_raid","location_oblast":"Автономна Республіка Крим","location_uid":"29","notes":"Згідно інформації з Офіційних карт тривог","calculated":null,"location_oblast_uid":29},{"id":51842,"location_title":"м. Нікополь","location_type":"city","started_at":"2023-10-18T09:21:02.000Z","finished_at":null,"updated_at":"2023-10-18T09:21:07.261Z","alert_type":"artillery_shelling","location_oblast":"Дніпропетровська область","location_uid":"5351","notes":null,"calculated":null,"location_oblast_uid":9},{"id":51843,"location_title":"Нікопольська територіальна громада","location_type":"hromada","started_at":"2023-10-18T09:21:02.000Z","finished_at":null,"updated_at":"2023-10-18T09:21:07.269Z","alert_type":"artillery_shelling","location_oblast":"Дніпропетровська область","location_uid":"351","notes":null,"calculated":null,"location_raion":"Нікопольський район","location_oblast_uid":9},{"id":51844,"location_title":"Донецька область","location_type":"oblast","started_at":"2023-10-18T09:36:20.000Z","finished_at":null,"updated_at":"2023-10-18T09:36:23.245Z","alert_type":"air_raid","location_oblast":"Донецька область","location_uid":"28","notes":null,"calculated":null,"location_oblast_uid":28},{"id":51845,"location_title":"Дніпропетровська область","location_type":"oblast","started_at":"2023-10-18T09:36:59.000Z","finished_at":null,"updated_at":"2023-10-18T09:37:03.242Z","alert_type":"air_raid","location_oblast":"Дніпропетровська область","location_uid":"9","notes":null,"calculated":null,"location_oblast_uid":9},{"id":51846,"location_title":"м. Дніпро","location_type":"city","started_at":"2023-10-18T09:37:10.000Z","finished_at":null,"updated_at":"2023-10-18T09:37:13.225Z","alert_type":"air_raid","location_oblast":"Дніпропетровська область","location_uid":"5332","notes":null,"calculated":null,"location_oblast_uid":9},{"id":51847,"location_title":"Дніпровська територіальна громада","location_type":"hromada","started_at":"2023-10-18T09:37:10.000Z","finished_at":null,"updated_at":"2023-10-18T09:37:13.234Z","alert_type":"air_raid","location_oblast":"Дніпропетровська область","location_uid":"332","notes":null,"calculated":null,"location_raion":"Дніпровський район","location_oblast_uid":9},{"id":51848,"location_title":"Полтавська область","location_type":"oblast","started_at":"2023-10-18T09:37:23.000Z","finished_at":null,"updated_at":"2023-10-18T09:37:27.546Z","alert_type":"air_raid","location_oblast":"Полтавська область","location_uid":"19","notes":null,"calculated":null,"location_oblast_uid":19},{"id":51849,"location_title":"Харківська область","location_type":"oblast","started_at":"2023-10-18T09:37:24.000Z","finished_at":null,"updated_at":"2023-10-18T09:37:27.558Z","alert_type":"air_raid","location_oblast":"Харківська область","location_uid":"22","notes":null,"calculated":null,"location_oblast_uid":22},{"id":51850,"location_title":"Запорізька область","location_type":"oblast","started_at":"2023-10-18T09:37:30.000Z","finished_at":null,"updated_at":"2023-10-18T09:37:33.238Z","alert_type":"air_raid","location_oblast":"Запорізька область","location_uid":"12","notes":null,"calculated":null,"location_oblast_uid":12},{"id":51851,"location_title":"м. Кривий Ріг","location_type":"city","started_at":"2023-10-18T09:37:35.000Z","finished_at":null,"updated_at":"2023-10-18T09:37:36.127Z","alert_type":"air_raid","location_oblast":"Дніпропетровська область","location_uid":"5279","notes":null,"calculated":null,"location_oblast_uid":9},{"id":51852,"location_title":"Криворізька територіальна громада","location_type":"hromada","started_at":"2023-10-18T09:37:35.000Z","finished_at":null,"updated_at":"2023-10-18T09:37:36.133Z","alert_type":"air_raid","location_oblast":"Дніпропетровська область","location_uid":"279","notes":null,"calculated":null,"location_raion":"Криворізький район","location_oblast_uid":9},{"id":51853,"location_title":"м. Світловодськ","location_type":"city","started_at":"2023-10-18T09:38:00.000Z","finished_at":null,"updated_at":"2023-10-18T09:38:03.305Z","alert_type":"air_raid","location_oblast":"Кіровоградська область","location_uid":"5786","notes":null,"calculated":null,"location_oblast_uid":15},{"id":51854,"location_title":"Світловодська територіальна громада","location_type":"hromada","started_at":"2023-10-18T09:38:00.000Z","finished_at":null,"updated_at":"2023-10-18T09:38:03.310Z","alert_type":"air_raid","location_oblast":"Кіровоградська область","location_uid":"786","notes":null,"calculated":null,"location_raion":"Олександрійський район","location_oblast_uid":15},{"id":51855,"location_title":"Сумська область","location_type":"oblast","started_at":"2023-10-18T09:39:02.000Z","finished_at":null,"updated_at":"2023-10-18T09:39:03.323Z","alert_type":"air_raid","location_oblast":"Сумська область","location_uid":"20","notes":null,"calculated":null,"location_oblast_uid":20}],"meta":{"last_updated_at":"2023/10/18 09:52:24 +0000","type":"full"},"disclaimer":"If you use python try our official alerts_in_ua PiP package."}
Perhaps someone knows how to make and analyze an API request directly through RULES, and send the appropriate command to the relay? Couldn't find any documentation on how I can make an API request via Rules.