[GH-ISSUE #31] Android automation apps integration (Tasker, MacroDroid, Automate, ...) #25

Closed
opened 2026-05-07 00:18:50 +02:00 by BreizhHardware · 11 comments

Originally created by @FrameXX on GitHub (Dec 4, 2021).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/31

Hi! I am the guy from Reddit!

Android automation apps are tools that helps you automate your android smartphone. They are like simple automation programming. There's a lot of them. Most known is Tasker, but also MacroDroid and Auomate too and there's also lot of other.

I see big potential in communicating between devices throught ntfy.sh. Of course many of these apps have their own solution, for example MacroDroid runs its own webhook server and there's a lot of other solutions for Tasker, but one more option is always good and your service seems to have a lot of more options. SO NOW TO THE POINT.

HOW TO INTEGRATE NFTY WITH AUTOMATIZATION APPS

As I mentioned before MacroDroid is able to use curl, but I don't know Tasker or any else, but they propably should also be able to.

There are 2 best ways how to integrate nfty with automatization apps

  • via Tasker plugin (which also MacroDroid and Automate suppports)
  • via broadcasting intents (which I think is better and simpler for this kind of thing)

Here is official video on how to create a Tasker pugin
https://piped.kavin.rocks/watch?v=48IVJgDtu6Y

However in this case I think intent solution would be much more simple and also more could make use of it. Tasker plugin is good for advanced triggers and actions, with a lot of data, but for something simple like messages it's not propably needed. Also more apps that doesn't work with Tasker plugins could make use of it.

let me give an EXAMPLE OF BROADCAST intent after message is received. I am an amateur so forgive me any mistakes. I am not writing in code, just showing what should intent contain.

Action: io.heckel.ntfy.messageReceived
Extra 'topic': my_custom_topic
Extra 'title': my_custom_title
Extra 'priority': 3
Extra 'tags': warning,skull
Extra 'message': my_custom_message

One note. There should be a ability to turn this intent broadcasting on and off, so any unwanted apps couldn't catch or send intents and misuse the ability.

Originally created by @FrameXX on GitHub (Dec 4, 2021). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/31 Hi! I am the guy from Reddit! Android automation apps are tools that helps you automate your android smartphone. They are like simple automation programming. There's a lot of them. Most known is Tasker, but also MacroDroid and Auomate too and there's also lot of other. I see big potential in communicating between devices throught ntfy.sh. Of course many of these apps have their own solution, for example MacroDroid runs its own webhook server and there's a lot of other solutions for Tasker, but one more option is always good and your service seems to have a lot of more options. SO NOW TO THE POINT. **HOW TO INTEGRATE NFTY WITH AUTOMATIZATION APPS** As I mentioned before MacroDroid is able to use curl, but I don't know Tasker or any else, but they propably should also be able to. There are 2 best ways how to integrate nfty with automatization apps - via Tasker plugin (which also MacroDroid and Automate suppports) - via broadcasting intents (which I think is better and simpler for this kind of thing) Here is official video on how to create a Tasker pugin https://piped.kavin.rocks/watch?v=48IVJgDtu6Y However in this case I think intent solution would be much more simple and also more could make use of it. Tasker plugin is good for advanced triggers and actions, with a lot of data, but for something simple like messages it's not propably needed. Also more apps that doesn't work with Tasker plugins could make use of it. let me give an EXAMPLE OF BROADCAST intent after message is received. I am an amateur so forgive me any mistakes. I am not writing in code, just showing what should intent contain. Action: io.heckel.ntfy.messageReceived Extra 'topic': my_custom_topic Extra 'title': my_custom_title Extra 'priority': 3 Extra 'tags': warning,skull Extra 'message': my_custom_message **One note. There should be a ability to turn this intent broadcasting on and off, so any unwanted apps couldn't catch or send intents and misuse the ability.**
Author
Owner

@FrameXX commented on GitHub (Dec 4, 2021):

Also. I personally wanted to not use app, but just fetch for messages every 5 min or so with curl, because that's enough for my purpose and I don't need instant delivery (but some users might want, that's why I opened this issue). So I tryed curl:

curl -s "ntfy.sh/mytopic/json?since=all"

but it won't return me any data. (No, I didn't forgot to change mytopic to my real topic.) I also tryed changing json to raw but it didn't helped. Am I doing something wrong?

EDIT: It was MacroDroid fault. Your command works, I tryed it in another shell app.

<!-- gh-comment-id:985996626 --> @FrameXX commented on GitHub (Dec 4, 2021): Also. I personally wanted to not use app, but just fetch for messages every 5 min or so with curl, because that's enough for my purpose and I don't need instant delivery (but some users might want, that's why I opened this issue). So I tryed curl: `curl -s "ntfy.sh/mytopic/json?since=all"` but it won't return me any data. (No, I didn't forgot to change mytopic to my real topic.) I also tryed changing json to raw but it didn't helped. Am I doing something wrong? **EDIT: It was MacroDroid fault. Your command works, I tryed it in another shell app.**
Author
Owner

@binwiederhier commented on GitHub (Dec 4, 2021):

Thank you very much for the write-up and the fantastic explanation.

Broadcasting intents

I love the idea of just broadcasting an intent and thereby integrating with other apps. It's easy and gets the job done.
I'll certainly do that when I get to it. Sounds like a fantastic feature!

I personally wanted to not use app,

😢 May I ask what the reason is? You don't like the foreground service?

but just fetch for messages every 5 min

The smallest possible interval that Android allows (without a foreground service) is 15 minutes (via WorkManager). I had plans to allow people to configure an interval to let them choose:

  • instant (requires foreground service)
  • 1min (requires foreground service)
  • 5min (requires foreground service)
  • 15min (does NOT require foreground service)
  • ..

But I haven't gotten to that yet. (Edit: Just created a ticket: https://github.com/binwiederhier/ntfy/issues/32)

So I tryed curl: curl -s "ntfy.sh/mytopic/json?since=all"

This will keep the connection open forever, so unless you send messages to the topic it won't return anything other than the open message and the other messages already in the channel:

{"id":"4nMJJOYQYP","time":1638625810,"event":"open","topic":"mytopic"}
{"id":"1rN1nTNVWf","time":1638611014,"event":"message","topic":"mytopic","message":"long process is done"}
(connection stays open)

If you want the connection to terminate after, you can add poll=1, like this:

curl -s "ntfy.sh/mytopic/json?since=all&poll=1"
{"id":"1rN1nTNVWf","time":1638611014,"event":"message","topic":"mytopic","message":"long process is done"}

Or are you saying you're not receiving ANY output from the curl? May I suggest you drop the -s and maybe do a curl -v, like this:

curl -v "ntfy.sh/mytopic/json?since=all&poll=1"
*   Trying 46.163.76.87...
* TCP_NODELAY set
* Connected to ntfy.sh (46.163.76.87) port 80 (#0)
> GET /mytopic/json?since=all&poll=1 HTTP/1.1
> Host: ntfy.sh
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Sat, 04 Dec 2021 13:51:59 GMT
< Server: Apache/2.4.41 (Ubuntu)
< Access-Control-Allow-Origin: *
< Content-Type: application/x-ndjson; charset=utf-8
< Transfer-Encoding: chunked
< 
{"id":"1rN1nTNVWf","time":1638611014,"event":"message","topic":"mytopic","message":"long process is done"}
* Connection #0 to host ntfy.sh left intact

That'll show any errors.

<!-- gh-comment-id:986030567 --> @binwiederhier commented on GitHub (Dec 4, 2021): Thank you very much for the write-up and the fantastic explanation. > Broadcasting intents I love the idea of just broadcasting an intent and thereby integrating with other apps. It's easy and gets the job done. I'll certainly do that when I get to it. Sounds like a fantastic feature! > I personally wanted to not use app, :cry: May I ask what the reason is? You don't like the foreground service? > but just fetch for messages every 5 min The smallest possible interval that Android allows (without a foreground service) is 15 minutes (via `WorkManager`). I had plans to allow people to configure an interval to let them choose: * instant (requires foreground service) * 1min (requires foreground service) * 5min (requires foreground service) * 15min (does NOT require foreground service) * .. But I haven't gotten to that yet. (Edit: Just created a ticket: https://github.com/binwiederhier/ntfy/issues/32) > So I tryed curl: curl -s "ntfy.sh/mytopic/json?since=all" This will keep the connection open forever, so unless you send messages to the topic it won't return anything other than the open message and the other messages already in the channel: ```curl "ntfy.sh/mytopic/json?since=all" {"id":"4nMJJOYQYP","time":1638625810,"event":"open","topic":"mytopic"} {"id":"1rN1nTNVWf","time":1638611014,"event":"message","topic":"mytopic","message":"long process is done"} (connection stays open) ``` If you want the connection to terminate after, you can add `poll=1`, like this: ``` curl -s "ntfy.sh/mytopic/json?since=all&poll=1" {"id":"1rN1nTNVWf","time":1638611014,"event":"message","topic":"mytopic","message":"long process is done"} ``` Or are you saying you're not receiving ANY output from the `curl`? May I suggest you drop the `-s` and maybe do a `curl -v`, like this: ``` curl -v "ntfy.sh/mytopic/json?since=all&poll=1" * Trying 46.163.76.87... * TCP_NODELAY set * Connected to ntfy.sh (46.163.76.87) port 80 (#0) > GET /mytopic/json?since=all&poll=1 HTTP/1.1 > Host: ntfy.sh > User-Agent: curl/7.58.0 > Accept: */* > < HTTP/1.1 200 OK < Date: Sat, 04 Dec 2021 13:51:59 GMT < Server: Apache/2.4.41 (Ubuntu) < Access-Control-Allow-Origin: * < Content-Type: application/x-ndjson; charset=utf-8 < Transfer-Encoding: chunked < {"id":"1rN1nTNVWf","time":1638611014,"event":"message","topic":"mytopic","message":"long process is done"} * Connection #0 to host ntfy.sh left intact ``` That'll show any errors.
Author
Owner

@FrameXX commented on GitHub (Dec 4, 2021):

May I ask what the reason is? You don't like the foreground service?

Your app is totally fine (just f-droid version seems to be a little broken). I have budget phone from 2018 and I have already some apps using foreground services, so I searched for an option without another foreground service. I may still use the app, I will see, but it's always good to know what all options I have. I was just discovering if this is a possibility. Also polling for messages like this doesn't require Google Play services (,which I have on my phone, but some people may not).

If you want the connection to terminate after, you can add poll=1

Thank you! Adding poll=1 helped and I get the output.

<!-- gh-comment-id:986036775 --> @FrameXX commented on GitHub (Dec 4, 2021): > May I ask what the reason is? You don't like the foreground service? Your app is totally fine (just f-droid version seems to be a little broken). I have budget phone from 2018 and I have already some apps using foreground services, so I searched for an option without another foreground service. I may still use the app, I will see, but it's always good to know what all options I have. I was just discovering if this is a possibility. Also polling for messages like this doesn't require Google Play services (,which I have on my phone, but some people may not). > If you want the connection to terminate after, you can add poll=1 Thank you! Adding poll=1 helped and I get the output.
Author
Owner

@binwiederhier commented on GitHub (Dec 6, 2021):

just f-droid version seems to be a little broken

Oh no. I just remembered this, sorry it took so long.
Can you elaborate on how it is broken? Can you maybe describe or take a video. I'd love to fix this if this is an issue.

option without another foreground service

So the only option to do this without another foreground service and without FCM is with polling every X minutes. With WorkManager (which is the only approved way these days), you can check only every 15 minutes. That's the shortest interval that you can set. Everything else won't work.

My plan is to do this as part of https://github.com/binwiederhier/ntfy/issues/10 is this:

Per subscription, allow you to set:

(x) Instant delivery
( ) Check every minute (requires foreground service)
( ) Check 5 minutes (requires foreground service)
( ) Check 10 minutes (requires foreground service)
( ) Check 15 minutes
( ) Check 30 minutes

I can imagine that even the "Check every 5 minutes" option will likely consume almost no battery, since the majority of the time we're just sleeping.

<!-- gh-comment-id:987113837 --> @binwiederhier commented on GitHub (Dec 6, 2021): > just f-droid version seems to be a little broken Oh no. I just remembered this, sorry it took so long. Can you elaborate on how it is broken? Can you maybe describe or take a video. I'd love to fix this if this is an issue. > option without another foreground service So the only option to do this without another foreground service and without FCM is with polling every X minutes. With `WorkManager` (which is the only approved way these days), you can check only every 15 minutes. That's the shortest interval that you can set. Everything else won't work. My plan is to do this as part of https://github.com/binwiederhier/ntfy/issues/10 is this: Per subscription, allow you to set: ``` (x) Instant delivery ( ) Check every minute (requires foreground service) ( ) Check 5 minutes (requires foreground service) ( ) Check 10 minutes (requires foreground service) ( ) Check 15 minutes ( ) Check 30 minutes ``` I can imagine that even the "Check every 5 minutes" option will likely consume almost no battery, since the majority of the time we're just sleeping.
Author
Owner

@FrameXX commented on GitHub (Dec 7, 2021):

Oh no. I just remembered this, sorry it took so long.
Can you elaborate on how it is broken? Can you maybe describe or take a video. I'd love to fix this if this is an issue.

It's missing an option of instant delivery when adding a topic, which I would understand (I presume it's because it does not use Google Play Services), but after creating a subscription it shows a persistent notification that states 'You are subscribed to one instant delivery topic', which is kind of confusing because I know delivery should not be instant. But what I don't know is that there will be no notification delivery at all. I don't know what poll time is used by default if any, but I send message to topic, waited 5 minutes and nothing happened. It won't send me the notification and I need to open the app to see the message and even after opening the

OKAY, so notifications started suddenly working and they are instant.

I swear they didn't worked before. (My bad. I am suspicious that I had do not disturb mode on, which bloked notifications from showing up).

But still there are some weird things. As I stated there's missing an option on instant delivery and it seems to be instant by default. When I am on topic messages page and tap on lightning icon in top menu it does nothing and just says that instant delivery is enabled. Overally f-droid version has less options? Why? Is it that you updated the app, but f-droid repository didn't updated since?

So this all seems to be just my own stupidity after all. Sorry for wasting your time with this.

With WorkManager (which is the only approved way these days), you can check only every 15 minutes. That's the shortest interval that you can set. Everything else won't work.

Totally understand

<!-- gh-comment-id:988218107 --> @FrameXX commented on GitHub (Dec 7, 2021): > Oh no. I just remembered this, sorry it took so long. Can you elaborate on how it is broken? Can you maybe describe or take a video. I'd love to fix this if this is an issue. It's missing an option of instant delivery when adding a topic, ~~which I would understand (I presume it's because it does not use Google Play Services), but after creating a subscription it shows a persistent notification that states 'You are subscribed to one instant delivery topic', which is kind of confusing because I know delivery should not be instant. But what I don't know is that there will be no notification delivery at all. I don't know what poll time is used by default if any, but I send message to topic, waited 5 minutes and nothing happened. It won't send me the notification and I need to open the app to see the message and even after opening the~~ OKAY, so notifications started suddenly working and they are instant. ~~I swear they didn't worked before.~~ (My bad. I am suspicious that I had do not disturb mode on, which bloked notifications from showing up). But still there are some weird things. As I stated there's missing an option on instant delivery and it seems to be instant by default. When I am on topic messages page and tap on lightning icon in top menu it does nothing and just says that instant delivery is enabled. Overally f-droid version has less options? Why? Is it that you updated the app, but f-droid repository didn't updated since? So this all seems to be just my own stupidity after all. Sorry for wasting your time with this. > With WorkManager (which is the only approved way these days), you can check only every 15 minutes. That's the shortest interval that you can set. Everything else won't work. Totally understand
Author
Owner

@binwiederhier commented on GitHub (Dec 7, 2021):

I am suspicious that I had do not disturb mode on, which bloked notifications from showing up

Oh this is a clue. I will investigate that.

I also had the suspicion that if you mess with the "Subscription Service" notification channel as described here (https://ntfy.sh/docs/subscribe/phone/#instant-delivery), ie. when you toggle the "Subscription Service" off, that that actually messes with the foreground service. But it's only a suspicion.

OKAY, so notifications started suddenly working and they are instant.

Yey :-D

But still there are some weird things. As I stated there's missing an option on instant delivery and it seems to be instant by default. When I am on topic messages page and tap on lightning icon in top menu it does nothing and just says that instant delivery is enabled. Overally f-droid version has less options? Why? Is it that you updated the app, but f-droid repository didn't updated since?

Okay so this is a UI issue that knew may cause confusion, but I wanted the F-Droid version out, ...

The thing is this:

On Google Play, if you use ntfy.sh, you have the choice between instant or not, because of Firebase, so the "[ ] Instant delivery" checkbox is there.

On F-Droid, even when using ntfy.sh, because we don't have Firebase, the "[ ] Instant delivery" is not there, because ALL subscriptions are "instant delivery".

Bottom line: I agree that this is terribly confusing, and I will revamp this when I get to https://github.com/binwiederhier/ntfy/issues/32, i.e. what I described here: https://github.com/binwiederhier/ntfy/issues/31#issuecomment-987113837

<!-- gh-comment-id:988267907 --> @binwiederhier commented on GitHub (Dec 7, 2021): > I am suspicious that I had do not disturb mode on, which bloked notifications from showing up Oh this is a clue. I will investigate that. I also had the suspicion that if you mess with the "Subscription Service" notification channel as described here (https://ntfy.sh/docs/subscribe/phone/#instant-delivery), ie. when you toggle the "Subscription Service" off, that that actually messes with the foreground service. But it's only a suspicion. > OKAY, so notifications started suddenly working and they are instant. Yey :-D > But still there are some weird things. As I stated there's missing an option on instant delivery and it seems to be instant by default. When I am on topic messages page and tap on lightning icon in top menu it does nothing and just says that instant delivery is enabled. Overally f-droid version has less options? Why? Is it that you updated the app, but f-droid repository didn't updated since? Okay so this is a UI issue that knew may cause confusion, but I wanted the F-Droid version out, ... The thing is this: On Google Play, if you use ntfy.sh, you have the choice between instant or not, because of Firebase, so the "[ ] Instant delivery" checkbox is there. On F-Droid, even when using ntfy.sh, because we don't have Firebase, the "[ ] Instant delivery" is not there, because ALL subscriptions are "instant delivery". Bottom line: **I agree that this is terribly confusing, and I will revamp this when I get to https://github.com/binwiederhier/ntfy/issues/32**, i.e. what I described here: https://github.com/binwiederhier/ntfy/issues/31#issuecomment-987113837
Author
Owner

@binwiederhier commented on GitHub (Dec 10, 2021):

As per the conversation in https://www.macrodroidforum.com/index.php?threads/ntfy-sh-update-post.1531/, I'm reposting what was discussed there:

Alright, that all sounds reasonable I think, and not that hard to do. Let me know if I got that right:

  1. MD -> ntfy.sh: Publish messages via GET, something like, like: GET /mytopic/send?title=abc&tags=tag1,tag2&priority=5&... --- This is highly unorthodox, since GET requests are supposed to be idempotent. I don't like this a ton, but if it's absolutely needed ....

  2. MD -> Ntfy app: Publish messages via broadcast intents to Ntfy: So MD could broadcast an intent and Ntfy would catch it and do the PUT/POST request to send the message. This sounds like an alternative to (1). Is this better or worse than (1) in your opinion?

  3. ntfy.sh -> Ntfy -> MD: Ntfy app should broadcast all received messages as intents so that MD can catch it. Correct?

I'll check out pushbullet.

<!-- gh-comment-id:990445438 --> @binwiederhier commented on GitHub (Dec 10, 2021): As per the conversation in https://www.macrodroidforum.com/index.php?threads/ntfy-sh-update-post.1531/, I'm reposting what was discussed there: > > Alright, that all sounds reasonable I think, and not that hard to do. Let me know if I got that right: > > 1. MD -> ntfy.sh: Publish messages via GET, something like, like: GET /mytopic/send?title=abc&tags=tag1,tag2&priority=5&... --- This is highly unorthodox, since GET requests are supposed to be idempotent. I don't like this a ton, but if it's absolutely needed .... > > 2. MD -> Ntfy app: Publish messages via broadcast intents to Ntfy: So MD could broadcast an intent and Ntfy would catch it and do the PUT/POST request to send the message. This sounds like an alternative to (1). Is this better or worse than (1) in your opinion? > > 3. ntfy.sh -> Ntfy -> MD: Ntfy app should broadcast all received messages as intents so that MD can catch it. Correct? > > I'll check out pushbullet.
Author
Owner

@binwiederhier commented on GitHub (Dec 11, 2021):

Pretty much done: github.com/binwiederhier/ntfy-android@323e013391

<!-- gh-comment-id:991771563 --> @binwiederhier commented on GitHub (Dec 11, 2021): Pretty much done: https://github.com/binwiederhier/ntfy-android/commit/323e013391981d09c18d7821915ec9b3e65eaf85
Author
Owner

@binwiederhier commented on GitHub (Dec 11, 2021):

I'll leave this open until it's released and tested

<!-- gh-comment-id:991771637 --> @binwiederhier commented on GitHub (Dec 11, 2021): I'll leave this open until it's released and tested
Author
Owner

@binwiederhier commented on GitHub (Dec 13, 2021):

Done in 1.4.0

<!-- gh-comment-id:992036376 --> @binwiederhier commented on GitHub (Dec 13, 2021): Done in 1.4.0
Author
Owner

@lhtdung commented on GitHub (Mar 30, 2024):

Good

<!-- gh-comment-id:2028045202 --> @lhtdung commented on GitHub (Mar 30, 2024): Good
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#25
No description provided.