Forum

Full Version: Mail client ideas, thinking outside the box
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello and all, I just moved to xbian and so far so good...

I am setting up a project using xbian as a media service along with Sprinkler_Pi as an irrigation system for my back yard. This will all be outside providing watering systems, a wifi/router service and importantly media/music around the pool. I am not however running a screen or tv on it, it's just for audio.

One thing I would like to add is some alarm or monitor to indicate when people are arriving at the front door. Wiring the existing doorbell to my Raspberry is a bit difficult (given the distance) so I had this thought...

My Synology NAS Surveillance Station and camera reliably sees people coming to the door and will send an alert email when it sees movement. I was hoping the xbian Pi in the back yard could monitor emails and do a 'sound on new email' as an alert. The email xbmc add-on is no good as it doesnt produce sounds or monitor constantly..

Any suggestions for a email client that I can use (running in the background) that will monitor a gmail account and sound an alert through the normal 3.5mm jack over the current playing music?

A couple of quick notes, aplayer is nicely plays wav files on commend but mpg321 or mpg123 seems to garble mp3 files when they are trying to output.
@Warren

using email as trigger would work, but is too much to configure/maintain/run for only trigger delivery. most SS or CAMs provide also simpler ways. as for instance simple http query to run, or put custom file on to shared storage. or just to ping -> touch remote ip and port combination!

any of this has all the benefits over email xchange

can be provided as event based system -> so no interval polls,
doesn't require special daemon installs and messy configs (and digging in case of failures)
is not dependent on any other "entity" in the flow
is much less demanding on system resources (can be managed with one instance of bash in memory)

recheck the SS/Cam and report back.

but in general the "system" infrastructure is already present in XBian base install. system already now has listener -

event bridge between XBMC and upstart job control (EventServer connector running with XBMC running) .
system already can run/trigger any function/trigger inside XBMC from base system (eventclient "command" provided by default -> connecting to locally started xbmc)
and of course back to Upstart which by default manages only XBian startup / shutdown - but it was developed exactly to serve your kind of purpose. we just need to tell it what to do and when to do it. Wink

(finally a "fresh" and "distinct" requirement Smile )

and to your aplay vs mpg123 problem.

"ffmpeg" tool can be used for pipe - pipe transcoding online. so you can pipe mp3 via ffmpeg to aplay Smile

like this:
Code:
root@xbcubox:/dev/snd# cat /usr/local/share/xbmc/addons/skin.confluence/sounds/cursor.wav | aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=imxspdif
    imx-spdif,
    Default Audio Device
sysdefault:CARD=imxhdmisoc
    imx-hdmi-soc,
    Default Audio Device
root@xbcubox:/dev/snd# cat /usr/local/share/xbmc/addons/skin.confluence/sounds/cursor.wav | aplay -Dsysdefault:imxhdmisoc
Playing WAVE 'stdin' : Unsigned 8 bit, Rate 22050 Hz, Stereo

done

what you do is just put ffmpeg between "cat file.mp3 and aplay". done. with no effort.

mk
(16th Mar, 2014 11:42 AM)mk01 Wrote: [ -> ]using email as trigger would work, but is too much to configure/maintain/run for only trigger delivery. most SS or CAMs provide also simpler ways. as for instance simple http query to run, or put custom file on to shared storage. or just to ping -> touch remote ip and port combination!
recheck the SS/Cam and report back.
(finally a "fresh" and "distinct" requirement Smile )

Thanks MK.
SS on the Synology NAS has limited notification methods. Email (could be to a local email server within the NAS itself), SMS (using services like clickatel) and finally push (but thats limited too);
Mobile device (using the linked Synology app), MSN or Skype.

Nice to be trying something new, although I have seen some related solutions using full home-automation which I am not (yet) looking to stretch to.

(16th Mar, 2014 11:42 AM)mk01 Wrote: [ -> ]and to your aplay vs mpg123 problem.
"ffmpeg" tool can be used for pipe - pipe transcoding online. so you can pipe mp3 via ffmpeg to aplay Smile

like this:
Code:
root@xbcubox:/dev/snd# cat /usr/local/share/xbmc/addons/skin.confluence/sounds/cursor.wav | aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=imxspdif
    imx-spdif,
    Default Audio Device
sysdefault:CARD=imxhdmisoc
    imx-hdmi-soc,
    Default Audio Device
root@xbcubox:/dev/snd# cat /usr/local/share/xbmc/addons/skin.confluence/sounds/cursor.wav | aplay -Dsysdefault:imxhdmisoc
Playing WAVE 'stdin' : Unsigned 8 bit, Rate 22050 Hz, Stereo
what you do is just put ffmpeg between "cat file.mp3 and aplay". done. with no effort.
mk

Thanks again but you lost me with this. The answer sounds good but not sure where/how that code is used or applied. Simple things are sometimes hard for me to 'get' but appreciate your effort.

Serious thanks for the above, not sure what the better or possible polling/pushing options are for notifying/triggering xmbc from the surveillance software that I have running though. Email seems to be the only technology-standard option to use easily.
As I type this I am now thinking of using something like pigdin to work with the MSN notifications (less polling than email) but difficult to auto-start/run perhaps.
But you understand that the ways you describe are simply non-sense ... for what you need.

Not because are "closed/licensed" or "too fancy" but simply because configure/maintain such "signaling" method will cost so much time - returning on service to you what - one 0/1 status that the picture has changed ?

if the NAS fw has at least configurable retry count on smtp send? or at least user defined smtp gateway? then don't be crazy (be nice to your time) and in case you can define retry count on email send failure - set it to 0 and smtp server use IP of your Raspberry.

on Raspberry install "conntrack" package. in simple script use conntrack as this:
Code:
conntrack -E -p tcp --state SYN_RECV --dport 25 | while read line; do initctl emit -n doorbellalert; done

this will run, listen on new connection on port 25 (smtp). if your NAS will try to send email, you get tick, event named "doorbellalert" will be generated in your RPI.

in /etc/init/ create doorbell.conf
Code:
start on doorbellalert

task
script
    
     xbmc-send --action=XBMC.Play("doorbellnotifycation.audio")
end script

you are finished with notification. although I send you command you don't need XBMC at all. is useless.

change "xbmc-send" for
Code:
cat "doorbellnotifycation.audio" | ffmpeg -i - -codec s16be - | aplay -DNAMEOFAUDIOCARD

this will accept any format of input audio file, autodetected and send ti aplay to play it out on sound card named "NAMEOFAUDIOCARD" (aplay -L will tell you the available sound card names)

so 7 lines of code, implemented in 10minutes. is this not what you wanted ?

if NAS is not providing editable retry count (what means it would be rsending the same event again and again because on our tcp/25 is no real smtp server listening), then only difference to the setup is that you have to fake SMTP server on port 25. this is not too much of a complication, just you will use such script:

Code:
mkfifo FROMNAS

netcat 25 < TONAS  > FROMNAS &

while read line; do
    case $line in
       helo*)
           echo "250" > TONAS
           ;;
       MAIL*)
           echo "250" > TONAS
             ;;
        RCPT*)
           echo "250" > TONAS
            ;;
       DATA*)
            echo "354 ok, send it; end with <CRLF>.<CRLF>" > TONAS
         \.)
            echo "250" > TONAS
       QUIT*)
            echo "221" > TONAS
         *)
                ;;
   esac
done < FROMNAS

initctl emit -n doorbellalert

you are finished again

what is the "push" option anyhow ?
(16th Mar, 2014 07:16 PM)mk01 Wrote: [ -> ]But you understand that the ways you describe are simply non-sense ... for what you need.
This makes more sense, yes the email notification allows for a smpt server address so easy to do what you have suggested. I will try this in the next day or two, seems like a reasonable process. :-)

Not sure how the other notification systems work exactly (re port etc)...
@Warren

when you will implement it, follow just this handshake, as I didn't remember exactly after the years ...

Code:
helo web-ster.com
250 hello mail.web-ster.com
MAIL FROM: donk@donk.com
250 ok
RCPT TO: donk@donk.com
250 ok its for <donk@donk.com>
DATA
354 ok, send it; end with <CRLF>.<CRLF>
To: fake-address@donk.com
From: donk@donk.com
Subject: This is only a test...

Hello, this is the body.  This whole email is forged.
It's not legit at all!

.
250 Message queued
QUIT
221 Goodbye

first line is what you get from NAS, then it is going like NAS - you - NAS - you ... I suppose sending "250" as answer is enough (so all anwer lines would be echo "250" > TONAS)


i tried to edit original post to follow this demo

feel free to follow up, don't panic if you don't get it run on first try. get back to this thread as mostly the "problem" is only in wrong texting or not backslashing special codes ... (\. to represent "." for instance)
Reference URL's