Easy Sonos

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: Easy Sonos

Post by G3rard »

Php files can be called from a switch, I am using that but you have to run the php from a web server like a Synology and use http:// instead of script://.
Not using Domoticz anymore
trekker25
Posts: 40
Joined: Tuesday 26 May 2015 10:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Easy Sonos

Post by trekker25 »

G3rard wrote:Php files can be called from a switch, I am using that but you have to run the php from a web server like a Synology and use http:// instead of script://.
got it all working. Created 2 dummy switches for each Sonos. And in Blocky sent a command when the doorbel is rang!

Even when the both speakers are streaming radio in a Group, when the doorbell rings, the sonos speakers stop each nicely, play the doorbell mp3 and afterwards continue to play the radio stream!!!

Cheers for the solution from this German guy!!! And thanks G3rard for pointing me to the solution!
thorbj
Posts: 113
Joined: Thursday 20 November 2014 22:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Norway
Contact:

Re: Easy Sonos

Post by thorbj »

G3rard wrote:Hi thorbj, that's not normal. When you switch off the Sonos (eg with the Sonos app) then this should be visible in the status of the switch. That can take a minute due to the time script, but it should change to off.

What does the php show if you open it in the browser and the Sonos is off?
I found the solution to this, somehow I had downloaded the html of the github, instead of the sonos.class.php :lol: :lol:
2xRaspberry Pi Model 2 w/RaZberry z-wave chip (master/slave)|Fibaro Wall Plug|Fibaro Universal Dimmer 500W|Aeon Labs Multisensor|RFXtrx433E|Nexa WMR-1000|Nexa Pe-3|Nexa Remote|Nexa LGDR3500|Lightify Gateway|Lightify RGBW bulb
thorbj
Posts: 113
Joined: Thursday 20 November 2014 22:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Norway
Contact:

Re: Easy Sonos

Post by thorbj »

G3rard wrote:You can take a look at https://github.com/ThomasTr/sonos. That has the possibility to stop current playing radio/list, plays a mp3, continues previously played radio/list. Maybe you can use that for the doorbell mp3.
I'm having difficulties getting this to work.
After having downloaded the files from Git, and the PHPSonos.inc.php, and put then on my webserver, I get the following error:
Fatal error: Uncaught exception 'Exception' with message 'Missing zone' in /home/pi/sonos/sonos.php:70 Stack trace: #0 /home/pi/sonos/sonos.php(58): Sonos->_assertZone('') #1 /home/pi/sonos/sonos.php(10): Sonos->_main() #2 /home/pi/sonos/index.php(7): Sonos->__construct() #3 {main} thrown in /home/pi/sonos/sonos.php on line 70
I have added my sonos speakers IP adresses to the config.php.

Code: Select all

<?php
$config = array(
	'zones' => array(
                'Stue'    => '10.10.10.139',
                'Stue' => '10.10.10.119',
                'Stue'  => '10.10.10.137',
				),
	'radiostations' => array(
		'DasDing'  => 'swr-mp3-m-dasding.akacast.akamaistream.net/7/588/137139/v1/gnl.akacast.akamaistream.net/swr-mp3-m-dasding',
                '1Live'    => '1live-diggi.akacast.akamaistream.net/7/965/119435/v1/gnl.akacast.akamaistream.net/1live-diggi',           
		'SWR3'     => 'mp3-live.swr3.de/swr3_m.m3u',
                'Donau3FM' => 'server1.webradiostreaming.de:2640',
	),
        'messagePath'   => '/home/pi/sonos/messages/',
        'messageStorePath'   => '/home/pi/sonos/messages/',
        'messageLang'   => 'no',
        'currentRadio'  => 'currentRadio.txt',
        'filePhpSonos'  => 'PHPSonos.inc.php',
        'logging'       => false,
        'logfile'       => 'log.txt',
);
?>
Does anyone know what can be wrong here?

-Thanks!
2xRaspberry Pi Model 2 w/RaZberry z-wave chip (master/slave)|Fibaro Wall Plug|Fibaro Universal Dimmer 500W|Aeon Labs Multisensor|RFXtrx433E|Nexa WMR-1000|Nexa Pe-3|Nexa Remote|Nexa LGDR3500|Lightify Gateway|Lightify RGBW bulb
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Easy Sonos

Post by G3rard »

First try it with one zone in the config.php file or otherwise give the 3 zones a different name.
Not using Domoticz anymore
trekker25
Posts: 40
Joined: Tuesday 26 May 2015 10:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Easy Sonos

Post by trekker25 »

G3rard wrote:First try it with one zone in the config.php file or otherwise give the 3 zones a different name.
my first guess indeed. as you need to send a message/command to 1 zone.
That's they only negative of this solution: doesn't recognize grouped speakers, but for the rest it works charmless.

Finished by doorbell project and i get a Prowl message and a doorbell ring on both of my Sonos speakers! Now it's time to install my Foscam IP camera and i'm done!
thorbj
Posts: 113
Joined: Thursday 20 November 2014 22:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Norway
Contact:

Re: Easy Sonos

Post by thorbj »

G3rard wrote:First try it with one zone in the config.php file or otherwise give the 3 zones a different name.
Thanks for the reply!

I have now tried with only one zone, but I still get the same error.

Here is the edited config.php:

Code: Select all

<?php
$config = array(
	'zones' => array(
                'Stue'    => '10.10.10.139',
				),
	'radiostations' => array(
		'DasDing'  => 'swr-mp3-m-dasding.akacast.akamaistream.net/7/588/137139/v1/gnl.akacast.akamaistream.net/swr-mp3-m-dasding',
                '1Live'    => '1live-diggi.akacast.akamaistream.net/7/965/119435/v1/gnl.akacast.akamaistream.net/1live-diggi',           
		'SWR3'     => 'mp3-live.swr3.de/swr3_m.m3u',
                'Donau3FM' => 'server1.webradiostreaming.de:2640',
	),
        'messagePath'   => '/home/pi/sonos/messages/',
        'messageStorePath'   => '/home/pi/sonos/messages/',
        'messageLang'   => 'no',
        'currentRadio'  => 'currentRadio.txt',
        'filePhpSonos'  => 'PHPSonos.inc.php',
        'logging'       => false,
        'logfile'       => 'log.txt',
);
?>
- Thanks!
2xRaspberry Pi Model 2 w/RaZberry z-wave chip (master/slave)|Fibaro Wall Plug|Fibaro Universal Dimmer 500W|Aeon Labs Multisensor|RFXtrx433E|Nexa WMR-1000|Nexa Pe-3|Nexa Remote|Nexa LGDR3500|Lightify Gateway|Lightify RGBW bulb
trekker25
Posts: 40
Joined: Tuesday 26 May 2015 10:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Easy Sonos

Post by trekker25 »

thorbj wrote:
G3rard wrote:First try it with one zone in the config.php file or otherwise give the 3 zones a different name.
Thanks for the reply!

I have now tried with only one zone, but I still get the same error.

Here is the edited config.php:

Code: Select all

<?php
$config = array(
	'zones' => array(
                'Stue'    => '10.10.10.139',
				),
	'radiostations' => array(
		'DasDing'  => 'swr-mp3-m-dasding.akacast.akamaistream.net/7/588/137139/v1/gnl.akacast.akamaistream.net/swr-mp3-m-dasding',
                '1Live'    => '1live-diggi.akacast.akamaistream.net/7/965/119435/v1/gnl.akacast.akamaistream.net/1live-diggi',           
		'SWR3'     => 'mp3-live.swr3.de/swr3_m.m3u',
                'Donau3FM' => 'server1.webradiostreaming.de:2640',
	),
        'messagePath'   => '/home/pi/sonos/messages/',
        'messageStorePath'   => '/home/pi/sonos/messages/',
        'messageLang'   => 'no',
        'currentRadio'  => 'currentRadio.txt',
        'filePhpSonos'  => 'PHPSonos.inc.php',
        'logging'       => false,
        'logfile'       => 'log.txt',
);
?>
- Thanks!
are you running it on your Pi? That doesnt work if you haven't installed a seperate webserver.


my config:
<?php

$config = array(
'zones' => array(
'Woonkamer' => '172.16.2.166',
'Keuken' => '172.16.3.164',

),
'radiostations' => array(
'DasDing' => 'swr-mp3-m-dasding.akacast.akamaistream.net/7/588/137139/v1/gnl.akacast.akamaistream.net/swr-mp3-m-dasding',
'1Live' => '1live-diggi.akacast.akamaistream.net/7/965/119435/v1/gnl.akacast.akamaistream.net/1live-diggi',
'SWR3' => 'mp3-live.swr3.de/swr3_m.m3u',
'Donau3FM' => 'server1.webradiostreaming.de:2640',
),
'messagePath' => '//172.16.0.3/Public/MEDIA/MP3/',
'messageStorePath' => '/c/music/_Sprachmeldungen/',
'messageLang' => 'du',
'currentRadio' => 'currentRadio.txt',
'filePhpSonos' => 'PHPSonos.inc.php',
'logging' => true,
'logfile' => 'log.txt',
);


so message path is a full name to a server.

Also i'm running it own my Qnap NAS.
thorbj
Posts: 113
Joined: Thursday 20 November 2014 22:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Norway
Contact:

Re: Easy Sonos

Post by thorbj »

I'm running on an Apache-install on my pi. That shouldn't be a problem. Or am I wrong?
I copied your configuration, but added my on IP for the sonos speaker, still same error. I have tried with the IP of all my speakers, even the BRIDGE.
2xRaspberry Pi Model 2 w/RaZberry z-wave chip (master/slave)|Fibaro Wall Plug|Fibaro Universal Dimmer 500W|Aeon Labs Multisensor|RFXtrx433E|Nexa WMR-1000|Nexa Pe-3|Nexa Remote|Nexa LGDR3500|Lightify Gateway|Lightify RGBW bulb
trekker25
Posts: 40
Joined: Tuesday 26 May 2015 10:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Easy Sonos

Post by trekker25 »

thorbj wrote:I'm running on an Apache-install on my pi. That shouldn't be a problem. Or am I wrong?
I copied your configuration, but added my on IP for the sonos speaker, still same error. I have tried with the IP of all my speakers, even the BRIDGE.
maybe a chmod issue?

and did you try opening it just in a browser and what url do you use?
thorbj
Posts: 113
Joined: Thursday 20 November 2014 22:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Norway
Contact:

Re: Easy Sonos

Post by thorbj »

All php files have 755 rights, and the filder has 777.
I've tried accessing it via a browser, that's when the error appears. http://ServerIP:port/index.php
2xRaspberry Pi Model 2 w/RaZberry z-wave chip (master/slave)|Fibaro Wall Plug|Fibaro Universal Dimmer 500W|Aeon Labs Multisensor|RFXtrx433E|Nexa WMR-1000|Nexa Pe-3|Nexa Remote|Nexa LGDR3500|Lightify Gateway|Lightify RGBW bulb
trekker25
Posts: 40
Joined: Tuesday 26 May 2015 10:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Easy Sonos

Post by trekker25 »

http://172.16.0.3/sonos/index.php?zone= ... &volume=80
try something like this.

The index.php demands to have a GET variable called zone.
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: Easy Sonos

Post by G3rard »

trekker25 wrote:http://172.16.0.3/sonos/index.php?zone= ... &volume=80
try something like this.

The index.php demands to have a GET variable called zone.
Indeed and I would start with just the play command, because in my setup playing messages was not so easy (due to config I had to do).

Code: Select all

http://<ip>/sonos/index.php?zone=Stue&action=Play
Not using Domoticz anymore
thorbj
Posts: 113
Joined: Thursday 20 November 2014 22:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Norway
Contact:

Re: Easy Sonos

Post by thorbj »

G3rard wrote:
trekker25 wrote:http://172.16.0.3/sonos/index.php?zone= ... &volume=80
try something like this.

The index.php demands to have a GET variable called zone.
Indeed and I would start with just the play command, because in my setup playing messages was not so easy (due to config I had to do).

Code: Select all

http://<ip>/sonos/index.php?zone=Stue&action=Play
Ah, so I need to issue commands with the index.php address? I will try playing with that later when I'm home again :) Tank you!!
2xRaspberry Pi Model 2 w/RaZberry z-wave chip (master/slave)|Fibaro Wall Plug|Fibaro Universal Dimmer 500W|Aeon Labs Multisensor|RFXtrx433E|Nexa WMR-1000|Nexa Pe-3|Nexa Remote|Nexa LGDR3500|Lightify Gateway|Lightify RGBW bulb
trekker25
Posts: 40
Joined: Tuesday 26 May 2015 10:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Easy Sonos

Post by trekker25 »

thorbj wrote:
G3rard wrote:
trekker25 wrote:http://172.16.0.3/sonos/index.php?zone= ... &volume=80
try something like this.

The index.php demands to have a GET variable called zone.
Indeed and I would start with just the play command, because in my setup playing messages was not so easy (due to config I had to do).

Code: Select all

http://<ip>/sonos/index.php?zone=Stue&action=Play
Ah, so I need to issue commands with the index.php address? I will try playing with that later when I'm home again :) Tank you!!
Play

http://yourserver/sonos/index.php?zone= ... ction=Play
Stop

http://yourserver/sonos/index.php?zone= ... ction=Stop
Toggle between play and stop

http://yourserver/sonos/index.php?zone= ... lePlayStop
Volume up / down

http://yourserver/sonos/index.php?zone= ... n=VolumeUp
http://yourserver/sonos/index.php?zone= ... VolumeDown
Mute

http://yourserver/sonos/index.php?zone= ... ction=Mute
Next radio from list

http://yourserver/sonos/index.php?zone= ... =nextRadio
Play message

http://yourserver/sonos/index.php?zone= ... &volume=20


The Google TTS service doesn't work anymore gives me HTTP 404 errors?? But i just downloaded my own doorbell mp3. You need to name it 0.mp3 (and use messageID1) and place it in the correct locations.

Seems every message had a 0 status (start action) and a 1 status (action stopped). For a doorbell you just need 0.mp3 and messageId1
wmn79
Posts: 27
Joined: Monday 13 April 2015 23:19
Target OS: NAS (Synology & others)
Domoticz version: 3.5033
Location: Amsterdam, The Netherlands
Contact:

Re: Easy Sonos

Post by wmn79 »

I have created an overview of this topic and some other Sonos related topics on this page on the wiki: http://www.domoticz.com/wiki/Sonos
Feel free to add info or improve it so we have one place with all Sonos related information.
wmn79
Posts: 27
Joined: Monday 13 April 2015 23:19
Target OS: NAS (Synology & others)
Domoticz version: 3.5033
Location: Amsterdam, The Netherlands
Contact:

Re: Easy Sonos

Post by wmn79 »

G3rard wrote:Would be nice if this is integrated in Domoticz.
I have a Sonos, but unfortunately no knowledge of c++ :?

I got a script from ab1976 to update the status of a virtual Sonos switch in Domoticz if the Sonos is switched on/off with another controller.
I altered it a bit and it is running as a LUA time script on a Synology.

LUA script

Code: Select all

function execute(command)
        -- returns success, error code, output.
    local f = io.popen(command..' 2>&1 && echo " $?"')
    local output = f:read"*a"
    return output
end

commandArray = {}

str=execute('php /volume1/web/domoticz/sonos/sonos.status-kantoor.php','r')
str2=execute('php /volume1/web/domoticz/sonos/sonos.status-keuken.php','r')

if string.find(str, "PLAYING") then
	print("Sonos kantoor aan")
	--print(str)
	if otherdevices['Sonos kantoor']=='Off' then
		commandArray['Sonos kantoor']='On'
	end
else
	print("Sonos kantoor uit")
	--print(str)
	if otherdevices['Sonos kantoor']=='On' then
		commandArray['Sonos kantoor']='Off'
	end
end

if string.find(str2, "PLAYING") then
	print("Sonos keuken aan")
	--print(str2)
	if otherdevices['Sonos keuken']=='Off' then
		commandArray['Sonos keuken']='On'
	end
else
	print("Sonos keuken uit")
	--print(str2)
	if otherdevices['Sonos keuken']=='On' then
		commandArray['Sonos keuken']='Off'
	end
end

return commandArray
PHP page

Code: Select all

<?php
$IP_sonos_1 = "192.168.1.1";
require("sonos.class.php");
$sonos_1 = new SonosPHPController($IP_sonos_1);
$transInfo= $sonos_1->GetTransportInfo();
echo $transInfo;
?>
I am using this script and it is working nicely, I only found out that when two Sonos devices are grouped and you pause the group. Only the initial device, so the device of which the playlist is used gets turned off. The other device still keeps the status "Playing" and therefore the virtual switch is not switching off, does someone else also see this behaviour?
HansLe
Posts: 25
Joined: Wednesday 13 January 2016 21:12
Target OS: Raspberry Pi / ODroid
Domoticz version: V2.3530
Location: Netherlands
Contact:

Re: Easy Sonos

Post by HansLe »

Hi, I've modified the stop and play scripts. You can use these scripts with an IP as parameter. These scripts also writes a line in the log file.

Place the scripts in: /home/pi/domoticz/scripts
Make the scipts executable: chmod +x <filename>

You can start them via a switch.
sonos-switch.JPG
sonos-switch.JPG (53.05 KiB) Viewed 38184 times

Code: Select all

#!/usr/bin/php
<?php
// Play SONOS device with given IP adres
//  f.e. in Domoticz switch enter by on action : script:///home/pi/domoticz/scripts/sonos.play.php 172.16.0.11
//
//  Uses curl. Maybe you havbe to install curl: sudo apt-get install php5-curl
//
require ("PHPSonos.inc.php");  
// check number of arguments; 1 is always the php filename
if ($argc < 2 ) {
	$msg = "SONOS%20play,%20no%20IP%20as%20argument!" ;  // change spaces to %20!
}
else {
	$ip = $argv[1];
	$sonos = new PHPSonos($ip);     // no check on valid IP address!
	$sonos = $sonos->Play();
	$msg = "SONOS%20$ip%20started";   // changes spaces to %20!
}
//
// Now write $msg to the Domoticz log file via json
//
// After http:// enter your Domoticz server url
//
$url = "http://xxx.xx.x.xx:pppp/json.htm?type=command&param=addlogmessage&message=$msg"; 
// open connection
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_NOBODY, TRUE);
// execute post
$result = curl_exec($ch);
// close connection
curl_close($ch);
?>

Code: Select all

#!/usr/bin/php
<?php
// Stop SONOS device with given IP adres
//  f.e. in Domoticz switch enter by off action : script:///home/pi/domoticz/scripts/sonos.stop.php 172.16.0.11
//
//  Uses curl. Maybe you havbe to install curl: sudo apt-get install php5-curl
//
require ("PHPSonos.inc.php");  
// check number of arguments; 1 is always the php filename
if ($argc < 2 ) {
	$msg = "SONOS%20stop,%20no%20IP%20as%20argument!" ;  // change spaces to %20!
}
else {
	$ip = $argv[1];
	$sonos = new PHPSonos("$ip");     // no check on valid IP address!
	$sonos = $sonos->Stop();
	$msg = "SONOS%20$ip%20stopped";   // changes spaces to %20!
}
//
// Now write $msg to the Domoticz log file via json
//
// After http:// enter your Domoticz server url
//
$url = "http://xxx.xx.x.xx:pppp/json.htm?type=command&param=addlogmessage&message=$msg"; 
// open connection
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_NOBODY, TRUE);
// execute post
$result = curl_exec($ch);
// close connection
curl_close($ch);
?>
Raspberry Pi B+ | Domoticz v3.4834 | RFXtrx433E | Action sockets and remote control (a cheap solution to start with)
Sonos device: control via Action remote control and EasySonos (via Domoticz scripts)
2 x Chresta TX320, Kaku sensoren, D-link camera
HansLe
Posts: 25
Joined: Wednesday 13 January 2016 21:12
Target OS: Raspberry Pi / ODroid
Domoticz version: V2.3530
Location: Netherlands
Contact:

Re: Easy Sonos

Post by HansLe »

Hi, a developed an alarm script for the Sonos. You can use these scripts with an IP as parameter. This scripts also writes a line in the log file.

Place the scripts in: /home/pi/domoticz/scripts
Make the scipts executable: chmod +x <filename>

You can download free sounds on the web. Save one of them to f.e. as alarm.mp3

A webdirectory on the RPI is necessary. See the attachement for a example
sonos-alarm.JPG
sonos-alarm.JPG (23.14 KiB) Viewed 38147 times
xxx.xx.x.xx in the script is the IP address of your RPI (Domoticz). pppp the port number.

Code: Select all

#!/usr/bin/php
<?php
// Play given MP3 file at a SONOS device with given IP adres
//  f.e. in Domoticz ALARM switch enter by on action : script:///home/pi/domoticz/scripts/sonos.alarm.php 172.16.0.11
//                   enter by off action f.e.  my stop script (see other post)
//
//  Uses a webserver directory; define /var/www/sonos and /var/www/sonos/spraak
//  Uses curl. Maybe you havbe to install curl: sudo apt-get install php5-curl
//
$volume = 50;   					// define your own volume, 100 is max.
$url = 'http://xxx.xx.x.xx/sonos/spraak/alarm.mp3';  	// define your own mp3 file; dont forget to copy it to the directory

//
require ("PHPSonos.inc.php");
// check number of arguments; 1 is always the php filename
if ($argc < 2 ) {    
	$msg = "SONOS%20play,%20no%20IP%20as%20argument!" ;  // change spaces to %20!
	exit;
}
else {
	$ip = $argv[1];
	$sonos = new PHPSonos($ip);     // no check on valid IP address!
	$msg = "SONOS%20$ip%20alarm%20started";   // changes spaces to %20!
//
// save informations
//
	$saveVolume	  = $sonos->GetVolume();
	$savePositionInfo = $sonos->GetPositionInfo();
	$saveMediaInfo    = $sonos->GetMediaInfo();
	$radio     	  = (strpos($saveMediaInfo['CurrentURI'], "x-")) !== false; //playlist in php starts with x-rincon-mp3radio
	$oldti		  = $sonos->GetTransportInfo();
//
// set AVT to message
//
	$sonos->SetVolume($volume);
	$sonos->SetAVTransportURI($url);
	$sonos->Play();
//
//	wait until message is done
//
	while ($sonos->GetTransportInfo() == '' || $sonos->GetTransportInfo() == 1)
	    {
	        sleep(0);    // dont spent time
	    }
//
// set old queue
//
	if ($radio) {
		$sonos->SetRadio($saveMediaInfo['CurrentURI'], $saveMediaInfo['title']);
		 }
	else {
		$sonos->SetAVTransportURI($saveMediaInfo['CurrentURI'], $saveMediaInfo['CurrentURIMetaData']);
		 }
	try {
// seek TRACK_NR
        	 $sonos->Seek("TRACK_NR", $savePositionInfo['Track']);
// seek REL_TIME
	         $sonos->Seek("REL_TIME", $savePositionInfo['RelTime']);
       	}
	catch (Exception $e) {
       	}
//
// play if previous list was playing
	if ($oldti == 1)
	       {
		 $sonos->Play();
		 }

	$sonos = $sonos->SetVolume($saveVolume);
//
}
//
// Now write $msg to the Domoticz log file via json
//
// After http:// enter your Domoticz server url
//
$url = "http://xxx.xx.x.xx:pppp/json.htm?type=command&param=addlogmessage&message=$msg"; 
// open connection
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_NOBODY, TRUE);
// execute post
$result = curl_exec($ch);
// close connection
curl_close($ch);
?>
Last edited by HansLe on Tuesday 19 January 2016 13:30, edited 2 times in total.
Raspberry Pi B+ | Domoticz v3.4834 | RFXtrx433E | Action sockets and remote control (a cheap solution to start with)
Sonos device: control via Action remote control and EasySonos (via Domoticz scripts)
2 x Chresta TX320, Kaku sensoren, D-link camera
geezerrr
Posts: 79
Joined: Tuesday 02 December 2014 22:16
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Easy Sonos

Post by geezerrr »

Cool!! I put on my to do list
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest