I’m about to move into a new loft, and I’m really looking forward to doing some home automation stuff. Specifically, I want to set it up so that when I hit the “Arriving Home” scene, it will do the following: unlock the front door, turn on the lights, and play music from a playlist. The first two seem very simple to do - it is the 3rd one giving me a headache.
I am completely new to home automation, so I’m currently just exploring resources, researching, and learning. I intend to use a Mi Casa VeraLite as my controller. My HTPC will be running XBMC Live (though I am willing to switch it over to Linux if need be) which will be attached to my speakers via a stereo, my homeserver (which contains all my media) will be running Linux in all likelihood, and my primary PC will be running Windows 7. However, I am willing to make hardware modifications where suggested. Would anyone mind suggesting a way to accomplish what I’m trying to pull off?
On a linux based system you could install MPD (Music player daemon) which is a small software that can play music from the terminal or over the network.
I personally use it to run it on my Synology diskstation (which is basically a Linux server). VeraLite sends a http request to the diskstationto start playing. That way its possible to integrate it to a scene. For MPD there are also various small graphical based frontends.
[quote=“superholz, post:3, topic:171942”]On a linux based system you could install MPD (Music player daemon) which is a small software that can play music from the terminal or over the network.
I personally use it to run it on my Synology diskstation (which is basically a Linux server). VeraLite sends a http request to the diskstationto start playing. That way its possible to integrate it to a scene. For MPD there are also various small graphical based frontends.[/quote]
Hi superholz, as i’m new to all this, would you be able to share some examples of the http request you use/send. Thanks
Hi Rookie, I read this quite late so sorry for answering late.
sure. I actually did not mention that I use a php server in between. So I send a simple http request to that server (within a luup code of a scene)
local http = require(“socket.http”)
http.request(“http://xx.xx.xx.xx./music1.php?m=play”)
everything else then is handled by the php script. There is a library available for the Music player daemon (MPD) and so it becomes easy to use the MPD via php.
See here an example for the php-code:
<?php
//define which playlist will be played
$file2="testpls";
//inckude the pjhp library for the MPD player interaction
include('mpd-class/mpd.class.php');
//define a new MPD object with the host and the port
$myMpd = new mpd('localhost',6600);
//get the command from the http request
$COMMAND=$_GET["m"];
//clear the playlist on mpd and load the new one
$myMpd->PLClear();
$myMpd->PLLoad($file2);
//set in shuffle mode
$myMpd->PLShuffle();
//evaluate the input parameter and trigger different actions
if ($COMMAND=="save") $myMpd->PLSave($file);
if ($COMMAND=="play") $myMpd->Play();
if ($COMMAND=="stop") $myMpd->Stop();
if ($COMMAND=="refresh") $myMpd->DBRefresh();
if ($COMMAND=="load") $myMpd->PLLoad($file2);
PLLoad
?>
Best Home Automation shopping experience. Shop at Ezlo!