Alert notification from esp 32 even the app is closed

I want to make fire alert message even if the app is closed . ESP 32 should send the alert message to the app . And I get the error that attempt to get item number 2 of a list of length 0. please help me with the blocks and if there is any more ideas include it . please help
alert.aia (32.5 KB)


Dear @lightning_got_struck,
I've not entered in detail your .aia, but as a general hint, before acessing a list it's always better to check whether the list is empty or whether it has enough elements.
To accomplish this you can use the following blocks.

image

Moreover, instead of nesting three lists and a dictionary, which is elegant, I admit, for the time being, with the aim at verifying which is the list that causes the error, it's better to assign to variables the "inner" results of the pointers, and display those results into three labels, just for debug purposes. After you'll get rid of the issue you can return to the condensed form.
Best wishes.

if you provide what are you receiving in responseContent, it would be easier to help you.

Thank you for your valuable reply . My problem is not solved can you open my .aia file and edit it to solve the error . please help

anybody please help with the .aia file , edit the file so to resolve the error and give the .aia file . please help me out

Please answer to @Ramon : it's difficult to help you without the detail of the data you want to assign to the lists.

I'm helping you....display you responseContent in a label...you will see that 'feeds' is empty.

1 Like

Please find annexed an .aia NOT TESTED.
It's just to (try to) explain what I said in my first post.
alert_01.aia (33.9 KB).
My assumption is: list A is generated by the dictionary (which is the split of the json), list B is the second element of list A, list C is the third element of list B, and finally, field_1 is the second element of list C. If the json file does not generate these nested 3 lists, everything I've written is not what you need, therefore please consider it as a suggestion only.

{"channel":{"id":2453926,"name":"drowning alert","latitude":"0.0","longitude":"0.0","field1":"Field Label 1","created_at":"2024-03-02T15:08:02Z","updated_at":"2024-03-02T15:08:02Z","last_entry_id":null},"feeds":}
this is the json data from the ThinkSpeak api the feeds is empty . Should use this URL in my Arduino code to make an HTTP request to send the data to your ThingSpeak channel . please suggest what to do .

You are receiving this:
{
"channel": {
"id": 2453926,
"name": "drowning alert",
"latitude": "0.0",
"longitude": "0.0",
"field1": "Field Label 1",
"created_at": "2024-03-02T15:08:02Z",
"updated_at": "2024-03-02T15:08:02Z",
"last_entry_id": null
},
"feeds":
}

if you want the value of "field1" then:

thank you so much for your valuable answer . Now I can open the application but it shows list A is empty . i have provided the json url
{"channel":{"id":2453926,"name":"drowning alert","latitude":"0.0","longitude":"0.0","field1":"Field Label 1","created_at":"2024-03-02T15:08:02Z","updated_at":"2024-03-02T15:08:02Z","last_entry_id":null},"feeds":}

This makes the pair to which @Ramon has already said: the "feed" is empty.
Until you don't populate that field of the json, you couldn't unpack it correctly.
I apologise, but since I'm not familiar with ThingSpeak I have to leave some other user (maybe @Ramon :grimacing: ?), more clever than me, to help you.
Best wishes.

thank u for the valuable answer would you please edit my .aia file to resolve the error

I think you are able to do it with the example I showed you....anyway, your problem is that you're trying to get filed1 inside the feeds field.... are you sure you have populated correctly the data?

I want to send a alert message to my app from esp 32 and I need to use this thinkspeak url in my esp 32 code to make an hhtp request and need to send data from the esp 32 to thinkspeak channel . I am sending a message drowning or detected with the longitude and lattitude (location details ) to the app in real time data from the esp 32 and the sensors so can you please edit the .aia file accordingly . please edit the .aia file .

This is the data you are getting from your channel. What do you want to do with them?

Hello,

I can show you some examples relative to how get the values you need from the received data.

If you want the values of all the fields "field1" inside the feeds parameter:

how to get from "channel" the las entry id:

and how to use the last_entry_id obtained previously to get the value of the "field1" for that entry (entry_id =4 in your example):

And please, stop writing to me privately... I will assist you when I can and always through the public topics.

Check if the value is greater than 0.95

Then you need to use an extension like this:

Guidelines for using Itoo

  • First get your background functionality running in the foreground. Like this, you can find errors much easier. And as soon as you got it working in the foreground, then test it in the background.
  • Read the complete Itoo to leaarn how Itoo works and try the example projects, See also the battery checker tutorial and notification listener and itoo tutorial.
  • Do not use global variables while in the background, use local variables instead
  • Do not use any user-visible or UI components in the background
  • In the background, use the Itoo StoreProperty/FetchProperty methods rather than TinyDB. TinyDB relies on SharedPreferences which will not ensure data synchronization across background processes.

Taifun

can you forward the picture of the full block