How to trigger alarm from a notification

Post your questions and help other users.

Moderator: Martin

Post Reply
caler
Posts: 5
Joined: 22 Feb 2020 17:55

How to trigger alarm from a notification

Post by caler » 02 Apr 2020 02:12

Can anyone help me setup an alarm trigger for my phone.

I have the Ring security system which sends my phone a notification to the lock screen when a security device is triggered.

I want to use that notification on the lock screen to cause my phones alarm clock to go off, or any loud audible ring that is loud enough to wake me up.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: How to trigger alarm from a notification

Post by Desmanto » 02 Apr 2020 06:23

Use Trigger Notification on Statusbar Displayed, choose the package name which show the notification. You might need to put in text filter so it doesn't mistrigger on wrong notification from the same app. Then use Action sound, choose any sound file or alarm sound. You might need to add action set audio volume first, set the channel you use to the maximum before action sound.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

caler
Posts: 5
Joined: 22 Feb 2020 17:55

Re: How to trigger alarm from a notification

Post by caler » 06 Apr 2020 23:45

Thank you Desmanto!
That seemed to work Just the way I was hoping when I followed your steps exactly. You're a hero.
Another question you may be able to help on this:


How do I best use the Expression Condidtion to check if the notification alarm has already been activated so it doesn't play multiple sound files on top of each other?

Also what is the proper way to code the alarm to have a stop function so it can be turned off?

caler
Posts: 5
Joined: 22 Feb 2020 17:55

Re: How to trigger alarm from a notification

Post by caler » 07 Apr 2020 00:00

As for turning the sound off all I'm doing right now is calling:

'Sleep 30s' at the end of the actions and then 'Stop Action Sound'

I dont know if this is the proper way to do it or not but it seems to work at least

caler
Posts: 5
Joined: 22 Feb 2020 17:55

Re: How to trigger alarm from a notification

Post by caler » 07 Apr 2020 00:11

Actually, I think having the 'Sleep' call in the flow is now stopping it from playing multiple iterations of the sound file on top of each other.

One problem seems to be if my sound file is longer then the Sleep call then the 'Stop Action Sound' doesn't seem to want to turn it off. :(

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: How to trigger alarm from a notification

Post by Desmanto » 11 Apr 2020 18:33

Just change the flow execution policy to "Skip". At the flow > 3 dot menu > Options > Skip (2nd one). This way, if the sound is playing, even though another same notification appear, it will be skipped (ignored).

To stop the alarm, you can tick "Show status bar notification to stop sound". But in your case, this is for security, so you don't want any other to stop the stop sound easily, so this option can't be used. You might want to add some security, such as input dialog with short password. It is a bit longer. You need to create another ongoing notification with certain text. Better to disguise it as something else, such as "Weather is good". Then create another flow with trigger Notification on Statusbar selected. Add action input dialog, password or pin. Then use expression to check the password is correct, example

Code: Select all

value == "123"
True, go to action stop action sound and remove the ongoing notification. So only correct password will stop the sound. Of course use you own password.


For the sound file longer thant the set sleep, you can adjust so the sleep before the stop action sound match the length of the audio. Use action init variable media metadata to get the info of the sound file you use. Then add media_duration with 500 or 1000 (ms), use it as the sleep variable. This way, your stop action sound always happen at the end. But this should be not needed, as when sound action play until finish, it should stop by itself already.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

caler
Posts: 5
Joined: 22 Feb 2020 17:55

Re: How to trigger alarm from a notification

Post by caler » 13 Apr 2020 23:18

Thank you very much for all the help Desmanto!

Post Reply