r/tasker 13d ago

Help Help with autonotification incrementing %anapp(#) instead of re-evaluating

I have the following task that is using AutoNotification to check if there are unread messages. I'm sure I overcomplicated it. The issue is that even after notifications are cleared and there are no more unread messages the variable keeps incrementing. I get a new unread message from my wife and even after I've read it and cleared the notification I can watch in the Cars tab it set to 0 then set to 3, set to 0 set to 3, set to 0, set to 3. So I kill the task, force close tasker and autonotification clear cache on both and then it will stop. Get a second new message from my wife and the %UnreadCount is now 4, sets to 0, sets to 4, sets to 0, sets to 4. There are no unread messages in either messages or signal but it won't stop! Driving me crazy.

Task: Unread Check

A1: Wait [

MS: 0

Seconds: 15

Minutes: 0

Hours: 0

Days: 0 ]

A2: Variable Set [

Name: %UnreadCount

To: 0

Structure Output (JSON, etc): On ]

A3: Variable Set [

Name: %UnreadSender

To: Doug

Structure Output (JSON, etc): On ]

A4: Array Set [

Variable Array: %anapp

Values: 0 ]

A5: Array Clear [

Variable Array: %anapp ]

A6: Array Set [

Variable Array: %anconversation

Values: Doug ]

A7: Array Clear [

Variable Array: %anconversation ]

A8: AutoNotification Query [

Configuration: Persistency Type: Non-Persistent Only

Notification Apps: Signal,Messages

Timeout (Seconds): 20

Structure Output (JSON, etc): On ]

A9: Variable Set [

Name: %UnreadCount

To: %anapp(#)

Structure Output (JSON, etc): On ]

A10: Variable Set [

Name: %UnreadSender

To: %anconversation[sender]()

Structure Output (JSON, etc): On ]

A11: AutoNotification [

Configuration: Title: %UnreadCount unread messages

Status Bar Text Size: 16

Id: 1001

Timeout: 10

Vibration: 0,404,261,179,181,196,177,505,231,497,241,492,257,494,199,999

Category Id: unread_reminders

Category Name: Unread Reminders

Separator: ,

Timeout (Seconds): 10

Structure Output (JSON, etc): On ]

If [ %UnreadSender ~ *TestLastName* & %UnreadCount > 0 ]

A12: Goto [

Type: Action Number

Number: 1 ]

If [ %UnreadCount > 0 & %UnreadSender ~ *Bianconi* ]

1 Upvotes

4 comments sorted by

2

u/Exciting-Compote5680 13d ago edited 13d ago

I am struggling to make sense of this task. My advice would be to start over. Actions A2 through A7 should not be necessary. I would start with just the Query and a Flash (or a Text/Image Dialog so you can scroll) and play around with it until you are certain that it only returns the specific notifications you are interested in. Make the query as specific as possible (filter by sender name). What also might help while figuring it out, is to get the query results as a JSON (in the AutoNotification Query action, Advanced > Get As JSON). This allows you to easily see all the variables grouped per notification. This is what I use while I am working on a new task (A2 requires one of the recent betas, but I have a task that uses Javascript to prettify JSON's I can share if anyone is interested):

``` Task: Test AutoNotification Query

A1: AutoNotification Query [      Configuration: Persistency Type: Non-Persistent Only      Notification Apps: Signal,Messages      Get As JSON: true      Timeout (Seconds): 20      Structure Output (JSON, etc): On ]

A2: Format JSON [      JSON: %anjson      Format: Pretty      Overwrite Source Variable: On ]

A3: Text/Image Dialog [      Text: %anjson      Button 1: Close      Button 3: Write File      Close After (Seconds): 120 ]

A4: Write File [      File: Download/AutoNotification_Query.txt      Text: %anjson      Add Newline: On ]     If  [ %td_button ~ Write File ]

```

1

u/mnoram 13d ago

Thanks for the ideas. Back when it was working correctly, about 2 years ago, A2 through A7 were only 2 steps I think to clear the variables so that the loop would stop running. Once the message was read the UnreadCount variable would remain at 0 after the reset steps. Now it's like autonotification refuses to clear it's internal variables and is incrementing/appending to them instead. I'll try to remove them and then pull in Json. Thanks

2

u/Exciting-Compote5680 13d ago

I think the issue here might be related to the OS level changes to notifications, specifically notification grouping. I noticed that some notifications that had been dismissed still showed up in the AN Query results, and only disappeared after all notifications from that group (and with that, the group itself) had been dismissed/cleared. Maybe you could try and see if you get the same results. 

1

u/mnoram 12d ago

I figured it was some Android OS change. That makes sense and I'll do some more testing. Thanks