Squeezebox + Tasker
Hi,
I have to profiles on Tasker:
1. Coming home
Detects correct GSM cell and puts WiFi on.
Exit task is WiFi off.
2. At home
Waits for that phone connects to my home wifi, waits for 5 seconds (waiting to connect network properly) then does with HTTP GET (to Squeezebox Server/Logitech Media Server) 'Play' -signal:
home-on.php:
Code:
<?php
$fp = fsockopen("localhost", 9090, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "00:04:20:26:XX:XX play\r\n";
fwrite($fp, $out);
$out = "00:04:20:26:XX:XX mixer volume 22\r\n";
fwrite($fp, $out);
fclose($fp);
exit;
}
?>
and exit task activates when it has been disconnected from home WiFi (as i leave home) and does HTTP GET to this php:
home-off.php
Code:
<?php
$fp = fsockopen("localhost", 9090, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "00:04:20:26:XX:XX pause 1\r\n\r\n";
fwrite($fp, $out);
fclose($fp);
exit;
}
?>
00:04:20:26:XX:XX is of course your squeezebox ID.
Result: When I come home, music starts with right volume. When I leave home, music stops. Quite handy.
|