maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails (https://talk.maemo.org/showthread.php?t=101005)

Veraendert 2020-04-15 16:22

Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails
 
Hi, i'm a volunteer firefighter which is a pretty busy job right now with lots of alarms. I need help with having some kind of alarm sound on a phone running SFOS.
I also happen to have a Jolla Phone which i really like.
We have 2 means of alarms: An app running on Android or iOS and a bulky analogue device.
When i go out for work or jogging, i usually take only my phone with me. And i would prefer using my J1 and not one of my Android phones that i'd rather leave at home. I tried running the Android app on it for alarms but no luck getting it to work so far. So this is a dead end (the Android app is called aPager Pro if you need to know).
What i did manage to do is forwarding the messages by e-mail from the app to my J1 using an app called NotifyMe. The problem is: I get a lot of e-mails. So if i have to take my phone out every time i get an e-mail, i'm more or less unable to work.
So what i need is a solution that reads my mails (or just the sender as that would always be the same for the forwarded alarms) and plays a sound as loud as possible. But i'm way out of my depths here. Does anyone have any idea how to solve my problem?

inte 2020-04-15 16:34

Re: Please help a firefighter
 
What about a dedicated email account for your alarm emails?

Veraendert 2020-04-15 16:41

Re: Please help a firefighter
 
Wouldn't be a problem to set up- but i still wouldn't have an alarm?

rob_kouw 2020-04-15 18:42

Re: Please help a firefighter
 
My e-mail provider has a service to send sms (text) messages when e-mails come in according with filter settings. That would solve it, right? It will cost you a few cents per sms.

If not through your provider: the other day I was talking to a guy who had a Node-RED solution to keep an eye on his building. He used sms messages too, I think through Vonage. I don't know if there is a lot of programming involved.

rob_kouw 2020-04-15 18:49

Re: Please help a firefighter
 
Quote:

Originally Posted by Veraendert (Post 1566853)
Wouldn't be a problem to set up- but i still wouldn't have an alarm?

That would depend on the ringtone for incoming e-mails?

Veraendert 2020-04-15 20:15

Re: Please help a firefighter
 
Isn't the ringtone always the same? Problem is i need mails from my main account in the phone, top.

Veraendert 2020-04-15 20:17

Re: Please help a firefighter
 
I probably should mention that i run my own Mail server, if that helps.

juiceme 2020-04-15 20:23

Re: Please help a firefighter
 
Quote:

Originally Posted by Veraendert (Post 1566850)
Hi, i'm a volunteer firefighter which is a pretty busy job right now with lots of alarms. I need help with having some kind of alarm sound on a phone running SFOS.
I also happen to have a Jolla Phone which i really like.
We have 2 means of alarms: An app running on Android or iOS and a bulky analogue device.
When i go out for work or jogging, i usually take only my phone with me. And i would prefer using my J1 and not one of my Android phones that i'd rather leave at home. I tried running the Android app on it for alarms but no luck getting it to work so far. So this is a dead end (the Android app is called aPager Pro if you need to know).
What i did manage to do is forwarding the messages by e-mail from the app to my J1 using an app called NotifyMe. The problem is: I get a lot of e-mails. So if i have to take my phone out every time i get an e-mail, i'm more or less unable to work.
So what i need is a solution that reads my mails (or just the sender as that would always be the same for the forwarded alarms) and plays a sound as loud as possible. But i'm way out of my depths here. Does anyone have any idea how to solve my problem?

So can you describe how do you get the email from the alarm, does it work so that the android application sends the email when you are summoned? Or do you get the alarm email from the fire department?

Of course if the alarm backend system that "aPager Pro" uses had an open API then it would not be difficult to implement something in python that'd serve as alarm application on SFOS.

If this is not possible then indeed some filtering based on the emails is the next best thing.

ibins 2020-04-15 20:27

Re: Please help a firefighter
 
Quote:

Originally Posted by Veraendert (Post 1566861)
I probably should mention that i run my own Mail server, if that helps.

A quick solution would be to set up a separate mail account. Use only this one for push notifications and fetch the other mails only manually. You said, that you get a lot of mails anyways. Fetch these only then, when you are not running. :-)

Veraendert 2020-04-16 08:50

Re: Please help a firefighter
 
Thanks so far, i've set up a separate mail account, that probably helps a bit. There is no way to alter the sound of email notification i presume?

@juiceme: The application is closed source and as far as i can tell works with an encrypted message other than SMS/e-mail. This is sensible data so we don't want everybody to be able to see the messages. No way they'd open the API just for me to mess around. But when that message is displayed, a different Android app NotifyMe grabs the displayed message and forwards it via e-mail.

That's not perfect but still better than just hearing the siren from the first engine going out. We're short of firefighters so this is a rather pressing problem.

peterleinchen 2020-04-16 09:21

Re: Please help a firefighter
 
jI guess for now a separate mail account with push set and all others to manual is best option for you.

I am pretty sure that it should be possible with some coding (e.g. python):
dbus listening for new mails and filtering text, then with aplay or something else playing sound.
I am also sure similar have been done for N900 already but I cannot remember for SFOS...

claustn 2020-04-16 09:23

Re: Please help a firefighter
 
1 Attachment(s)
Quote:

Originally Posted by Veraendert (Post 1566872)
Thanks so far, i've set up a separate mail account, that probably helps a bit. There is no way to alter the sound of email notification i presume?

Of course you can! Go to Settings -> Sounds & feedback -> Email and set the loudest you want

Veraendert 2020-04-16 10:59

Re: Please help a firefighter
 
@claustn: Thanks, maybe i wasn't clear enough: I only have the option to edit the alarm sound for every e-mail, regardless of what account it was sent to. That way, if i check for mails from my "normal" account, there would be an alarm sound every time there's new mail. So while i could use some siren sound for e-mail alarms, this would probably not be a good idea e.g. at work.

Ideally, there would be a specific sound for that e-mail account overriding everything and playing at full volume.

But the setup i have now is already a lot better than what i had before thanks to everyone. I really appreciate it. Checking your email every 5 minutes on a 20km run sucked.

rob_kouw 2020-04-16 11:04

Re: Please help a firefighter
 
In case you are located in The Netherlands: dds.nl offers the sms service. An account is 32,50/year, text message 0,10-0,12 euro each.

Veraendert 2020-04-16 11:18

Re: Please help a firefighter
 
I'm in Germany. And this would still mean that i'd get an alarm sound every time i receive an SMS. Which isn't that often but still often enough.

claustn 2020-04-16 11:32

Re: Please help a firefighter
 
Quote:

Originally Posted by Veraendert (Post 1566882)
@claustn: Thanks, maybe i wasn't clear enough: I only have the option to edit the alarm sound for every e-mail, regardless of what account it was sent to. That way, if i check for mails from my "normal" account, there would be an alarm sound every time there's new mail. So while i could use some siren sound for e-mail alarms, this would probably not be a good idea e.g. at work.

Ideally, there would be a specific sound for that e-mail account overriding everything and playing at full volume.

But the setup i have now is already a lot better than what i had before thanks to everyone. I really appreciate it. Checking your email every 5 minutes on a 20km run sucked.

I agree that separate alarms for each account would be the best, but you can also have an Ambience for running with the loud email tone and another one for everything else. Or use the Situations app to change stuff according to where you are.

Halftux 2020-04-16 11:47

Re: Please help a firefighter
 
I would do it with dbus.
For sms you can look here:

https://talk.maemo.org/showthread.php?t=100848

And the email application has a session dbus interface (com.jolla.email.ui) maybe it is helpful.

https://together.jolla.com/question/...e-information/

https://talk.maemo.org/showthread.php?t=92303

Trzyzet 2020-04-16 12:14

Re: Please help a firefighter
 
You can quite easily connect some kind of prototype board with modem to the 'real' alarm device which, when will be activated, will send you SMS. Easy to do but you need some electronics technician/engineer in your place to do it.

Veraendert 2020-04-16 13:45

Re: Please help a firefighter
 
1 Attachment(s)
Quote:

Originally Posted by claustn (Post 1566885)
I agree that separate alarms for each account would be the best, but you can also have an Ambience for running with the loud email tone and another one for everything else. Or use the Situations app to change stuff according to where you are.

Mabe i'll just let the app check if i'm connected to known wifi (which means i'm at home or at work and will likely have the alarm device with me) and act accordingly. I'll give it a try.

That's me yesterday btw. 3rd one from left. The good looking one.

xelo 2020-04-16 17:39

Re: Please help a firefighter
 
@veraendert: I'm a volunteer in the german civil protection service and my local unit decided to use a tool named divera for alerting us. Unfortunately there is also only an iOS or Android app, thus is "suffer" from the same problem. Which App is your fire brigade using?

Veraendert 2020-04-16 18:58

Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails
 
Dear colleague, we use this one now: https://www.alamos-gmbh.com/service/apager-pro/
The whole Landkreis (county?) is supposed to use it. Best part is that it also shows me the way to the fire station should i have forgotten how to get there.

@all: You guys are great. I now have a separate email account, with situation set up so that when i´m not within reach of a known wifi the ambient changes and thus the sound when i get an email. Emails are constantly retrieved for the alarm mail account and only manually for the normal one. I think i can live with that for the time being.

I'll probably try to retrieve the alarm message via kdeconnect with a linux computer later to gain a few seconds and to be able to forward the message via different means.

One last question though: the Situations app lets me execute random commands it seems. Does anyone have any idea how to put this possibility to use?

peterleinchen 2020-04-16 19:48

Re: Please help a firefighter
 
I just found some time to hack together a shell one-liner that should solve it for you (jn case your alert e-mail has a specific unique subject):
Code:

{ dbus-monitor & echo $! >dbusmonpid; } | { grep -q -m 1 'xxxSUBJECTxxx' && gst-launch-1.0 playbin uri=file:///home/nemo/Music/SOMEFILE.ogg.midi.wav.mp3 && kill $(cat dbusmonpid) && rm dbusmonpid; }
Replace the xxxSUBJECTxxx with any unique part of subject of your alert mail. And replace SOMEFILE with any music /sirene/noise sound file.
Tested and worked. :)



This is definitely not fool proof and could be extended with a loop and more. Oh and let the sound play to end (do not use ctrl-c), else the dbus-monitor process will not get killed.
About loudness I do not know with gst-launch but there should be some help.
So there is room for improvement. But hey it works!

Thanks @haltux for the right pointers! :D

ajalkane 2020-04-16 20:03

Re: Please help a firefighter
 
If you can make the alerts come as SMS with predefined message, you could also use FindMyJolla to create alert:

https://openrepos.net/content/ajalkane/find-my-jolla

Halftux 2020-04-16 20:47

Re: Please help a firefighter
 
Quote:

Originally Posted by peterleinchen (Post 1566897)
So there is room for improvement. But hey it works!

Thanks @haltux for the right pointers! :D

Nice one I am glad that I could be of help with this outcome :)
Very good and flexible starter.
I could also think of, that you not filter the subject which is good, but when needed you could also filter the account which gets an e-mail.
Just as an idea when the subject changes.

Veraendert 2020-04-17 06:21

Re: Please help a firefighter
 
This sounds great, i'll test it. I should probably make this a cron job to start on boot, no?
I can define the message myself so that shouldn't be a problem.
Volume should be easy: https://gstreamer.freedesktop.org/do...ume/index.html

peterleinchen 2020-04-17 07:31

Re: Please help a firefighter
 
You are welcome.
Fire fighters are system relevant ;) so I needed to help :D

About volume level I found that gstreamer thing also but think this is just setting 0-100 % of actual level (not sure).
So I think this approach here sounds better:
Code:

after installing alsa-utils via pkcon I was able to change the master volume/balance via cmd line like 'amixer sset Master 80%,80%'


The current code snippet I made is a one-time executer, so you would need to put into a loop. I thought it is easier to control when you want it to run. If you want it always, a systemd script on boot or cron job is good. But then it would need some more fine tuning against reliability, e.g. how to stop it or how to pause/stop the sound...

Veraendert 2020-04-17 09:11

Re: Please help a firefighter
 
Just in case a colleague of mine finds this: I had to install gstreamer1.0-tools, too

Veraendert 2020-04-17 11:07

Re: Please help a firefighter
 
So after install alsa-utils and gstreamer1.0-tools i'm now here:
Code:

{ dbus-monitor & echo $! >dbusmonpid; } | { grep -q -m 1 '<alarm>' && amixer sset Master 100%,100% && gst-launch-1.0 playbin uri=file:///home/nemo/Documents/sirene.mp3 &&
kill $(cat dbusmonpid) && rm dbusmonpid; }

This is a working solution.

peterleinchen 2020-04-17 12:04

Re: Please help a firefighter
 
Quote:

Originally Posted by Veraendert (Post 1566914)
So after install alsa-utils and gstreamer1.0-tools i'm now here:
...
This is a working solution.

Now as we know the trigger subject text we just need your e-mail address to test! :D

Would you mind to edit the first post and hereby the title to some more meaningful?
Like: Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails

--
and maybe reset loudness after sound has played?

Veraendert 2020-04-17 14:17

Re: Please help a firefighter
 
Quote:

Originally Posted by peterleinchen (Post 1566915)
Now as we know the trigger subject text we just need your e-mail address to test! :D

I'm not that stupid :D

Thank you all for your input. I'll try to figure out how to make a systemd service from this that also resets sound volume.

Android_808 2020-04-18 07:34

Re: Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails
 
Can you record the current level using awk and alsamixer sget to a file, like the PID, just before you set it to 100. Then restore it when you do the cleanup up the end.

nonsuch 2020-04-18 12:01

Re: Please help a firefighter
 
Quote:

Originally Posted by Halftux (Post 1566886)
And the email application has a session dbus interface (com.jolla.email.ui) maybe it is helpful.

https://together.jolla.com/question/...e-information/

https://talk.maemo.org/showthread.php?t=92303

With this + a simple shell script, shouldn't it be possible to look for certain keywords in incoming mails, and sound an alarm if such are found?

Veraendert 2020-04-19 17:01

Re: Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails
 
Quote:

Originally Posted by Android_808 (Post 1566939)
Can you record the current level using awk and alsamixer sget to a file, like the PID, just before you set it to 100. Then restore it when you do the cleanup up the end.

I'm a little unsure if i can but i'll do my best. Right now, i have the problem that the terminal stops working after some time and i have to restart it. I have gotten one alarm now but i don't want to miss the next one. So- having the sound restored is somewhat the icing on the cake.

peterleinchen 2020-04-19 18:25

Re: Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails
 
Sounds like OOM kills of terminal. :(

I see my terminal cover often greyed out, i.e. killed and the command just interrupted :eek:

I extended my swap manually with a swap file on home (maybe better on SD card like on N900?) and it got better.

Maybe try with ShellEx or qCommand from openrepos?

Or let a cron job restart this command every xx minutes?
(will you get re-notified more often via mail?)

Android_808 2020-04-19 23:03

Re: Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails
 
Quote:

Originally Posted by Veraendert (Post 1566982)
I'm a little unsure if i can but i'll do my best. Right now, i have the problem that the terminal stops working after some time and i have to restart it. I have gotten one alarm now but i don't want to miss the next one. So- having the sound restored is somewhat the icing on the cake.

Did a little digging. You can use alsamixer -sget Master but you may also be able to use alsactl.

Maybe something like editing the dbus command posted earlier to add

alsactl --file ~/.config/asound.state store

Before the alsamixer -sset Master bit and

alsactl --file ~/.config/asound.state restore

In the kill/cleanup part.

Veraendert 2020-04-20 15:44

Re: Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails
 
Sounds good, will try. But then the script worked very well twice today already. Which means that i'm really tired. Because it was quite early when my sleep was interrupted.

peterleinchen 2020-04-20 21:00

Re: Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails
 
Cannot help you with this sound stuff,
as I am not really a knowledged one regarding PA, alsa and so on
and all that alsa vodoo just gives me a lot of 'no such device' or 'cannot read control' or similar on XA2...

Veraendert 2020-04-21 13:50

Re: Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails
 
No problem, you helped a great deal already. I just need some time to figure things out. As long as i have a working solution, i'm fine.

biketool 2020-04-21 14:21

Re: Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails
 
To dodge into a different direction may I ask what bulky analog device you have for callouts? Are people still using Motorola Minotaur and Minotaur IIs?(edit, damn they are up to the Minotaur 6, now as big as a little '90s belt pager now but still voice paging.)
I was a paid guy and finished as an officer and EMT-P but ended up taking the tech telated topics during my 8-5 work hours, though we were still doing in the VHF in rural western US when I medical'ed out.
I am also an amateur radio guy so hacking a VHF receiver with tone controls back then was cake though we also had commercial UHF POCSAG pagers with priority so they all beeped about 1-2 sec after the tones came over the VHF dispatch channel.
Not sure what your dispatch's setup looks like.

Big life altering advice for all first responders.
Lift properly, ask for help(hard for young guys, especially young volunteers), protect your spine, stairways with a patient on the cot and you are the backwards guy will get you; the damage you do might put you away fast or might just get worse over time; it is what ended my career.
Also remember that car drivers are what kill by far the most first responders and that people get lax at training events in a way they never would on a real call(hours of repeated extinguish/relight burn to learns especially).
Pass this on to the young guys at your department and wherever you end up doing teaching.

spag 2020-04-21 21:30

Re: Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails
 
Quote:

Originally Posted by biketool (Post 1567033)
T
I am also an amateur radio guy so hacking a VHF receiver with tone controls back then was cake

I guess today one could maybe do this with a cheap SDR USB stick and a Raspberry Pi.


All times are GMT. The time now is 13:03.

vBulletin® Version 3.8.8