this post was submitted on 23 Aug 2023
1 points (100.0% liked)

Tasker: Total Automation for Android

52 readers
0 users here now

The tasker community on Reddit. Reddit gives you the best of the internet in one place.

founded 2 years ago
MODERATORS
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/tasker by /u/Rich_D_sr on 2023-08-23 02:06:33.


I have been working with u/Nirmitlamed trying to get Telegram notifications to play nice with Tasker to be able to make a simple "Respond When Driving" project. Telegram Has a fairly complex notification system that makes it difficult to itercept there notifications. They have the normal Grouping issues that the Autonotification "Ignore Group Summaries" cures for the most part. However you will still get multiple activations for the same message for other reasons. One of these is a strange issue when you recieve a message from "Channels". I have seen other posters push the notifications to an array and simply skip any consecutive notifications with the same Text and Title.

The approach we came up with is much simpler and Handles all of the multi triggering issues. By using AutoNotifications %anwhentime variable you can test the exact epoch milliseconds when this notification was created. Any duplicate notifications will have the exact same or lower value. So simply testing the value of %anwhentime in the current notification against the value of %anwhentime from the last notification will allow for a very simple filter. So a simple set of actions like this is all that is neededdd..

Task: Telegram Filter

A1: Stop [ ]
    If  [ %anwhentime < %Last_when_time | %anwhentime = %Last_when_time ]

A2: Variable Set [
     Name: %Last_when_time
     To: %anwhentime
     Structure Output (JSON, etc): On ]

For this type of project where you are dealing with the notifications as they come in I prefer to Queu up Task iterations instead of trying to push to an array. Some of these notifications trigger so fast that pushing to the Array will fail. This approach is explained here in section 8

Here is a very simple example of this working.

Project: Telegram Stop Multi Notification Activation

Profiles
    Profile: Telegram Test Notification
        Event: AutoNotification Intercept [ Configuration:Event Behaviour: true
    Notification Type: Only Created Notifications
    Persistency Type: Non-Persistent Only
    Notification Apps: Telegram ]

    Enter Task: Telegram Filter
    Settings: Run Both Together

    A1: Stop [ ]
        If  [ %anwhentime < %Last_when_time | %anwhentime = %Last_when_time ]

    A2: Variable Set [
         Name: %Last_when_time
         To: %anwhentime
         Structure Output (JSON, etc): On ]

    A3: Notify [
         Title: Telegram Notification Received %TIMEMS
         Text: Title   -   %antitle
         Text   -  %antext
         Number: 0
         Priority: 3
         LED Colour: Red
         LED Rate: 0 ]

    A4: Flash [
         Text: Telegram Notification

         Title   -   %antitle
         Text   -  %antext
         Dismiss On Click: On ]

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here