RaspyThing


(B Clark) #1

Ok, first thread, first ST hub, first device type, first time git user, and a few other things, so bear with me. :blush:

After I first installed my system, I wanted something to announce that doors have been opened, just like my brother-in-laws ADT alarm system does. I saw that a Sonos would do it, but that’s too expensive for just a networked beep. I had an un-purposed Raspberry Pi (V1) that has a built in audio output and I’ve dabbled in web hosting and php, so I figured there must be a way to get an http post to call a script that plays a sound. First, I got the raspberry pi to play audio from the command line, then I got Apache and PHP setup to call the command based on the HTTP post. Then I tried writing the device type code from scratch, but when I couldn’t get the HubAction to work I modified the ObyThing code and got it to work.

Features/Drawbacks

  • IP address must be manually entered, no discover
  • There is no communication back to the hub. It’s a simple one way post.
  • It looks for a file locally with the same file name and plays it if it finds one. This should speed up notifications if the network is slow or down.
  • If it doesn’t find a local file, it downloads it and plays the local copy.
  • You can upload files and name them the same as standard files to replace the default sounds without re-writing smartapps. I replaced bell1.mp3 with the Mario Bros entering the pipe sound, and my kids love it when the doors open.
  • There is no security in the PHP script and the Pi should not be open to the internet.
  • To view what files are cached or to upload a new file, browse to the play.php on your device from your network (ex: 192.168.1.18/play.php )
  • You can also trigger sounds from the web browser like this 192.168.1.18/play.php?track=bell1.mp3&volume=100

Future Ideas:

  • Separation of cache and uploads
  • The ability to delete or rename files from the web page
  • Insert links on the web page file links to play the files listed

See full installation instructions and get the PHP file at: RaspyThing.src


Raspberry Pi Speech Synthesis
Raspberry Pi with PHP (or Arduino/ESP8266/NodeMCU) to GPIO to Relay to Gate/Garage Trigger
(Ule) #2

Hi @braclark, you could try to convert your RB into a mediarenderer and use the Dlna player, it´s other option


(B Clark) #3

Thanks @ule. I tried that first but was unable to get it working. Probably because I was so new to ST, and had almost no clue to what I was doing. Now that I have this set up, I kind of like the feature of locally caching the file instead of downloading it every time and to be able to replace the bell1.mp3 that plays when my doors open with any desired sound effect.

I’m going to try to get that DLNA player going again.