Ok, first thread, first ST hub, first device type, first time git user, and a few other things, so bear with me.
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.
- 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
- 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