Page 2 of 5

Re: Easy Sonos

Posted: Thursday 09 July 2015 15:42
by fl1p
How do you integrate this in Domoticz? I have everything running, but I want to be able to click a button, then a TTS message comes out of a speaker.
The PHP-script is ready, and what now?

Re: Easy Sonos

Posted: Sunday 12 July 2015 12:07
by G3rard
Add a virtual switch and put the php url in the On Action of the switch.

Re: Easy Sonos

Posted: Sunday 12 July 2015 15:47
by fl1p
That seems to work only sometimes... I added a simple test with "Play". I click the button, it works. Then I pause it via Sonos and I click the button again. Doesn't work for a few times.
The button has a very strange behaviour.

And how do I start a playlist? Just put in the name of the playlist/radio station between the brackets? Does it have to be in my sonos favourits or sonos playlists or both...?

Re: Easy Sonos

Posted: Thursday 16 July 2015 8:51
by bran2000
Hi,

sorry i tried to put this command (see below) on the switch, the on action for the script isn't working, did i miss something ?

put "#!/usr/bin/env php" before the "<?php" statement in sonos.play.php
chmod u+x sonos.play.php
call it with "script://home/pi/domoticz/scripts/sonos.play.php"

Re: Easy Sonos

Posted: Thursday 16 July 2015 15:28
by fl1p
I'm not sure what your level of linux is, so I put it in full. Maybe you got this right allready.
Just for sure:
1) In het file sonos.play.php you shut put this:

Code: Select all

 #!/usr/bin/env php
2) Browse to the file where sonos.play.php is located and do:

Code: Select all

sudo chmod u+x sonos.play.php
3) The in the On-command line in your switch, you put:

Code: Select all

script:///home/pi/domoticz/scripts/sonos.play.php
Else, did you try and test it via the command line on your server itself?

For me, that sometimes worked...

Re: Easy Sonos

Posted: Thursday 16 July 2015 17:47
by bran2000
Sorry, still not working
i have got the message error in the logs : "Error executing scrript command /home/pi/domoticz/scripts/sonos.play.php returned 32512".
Very strange because when i type the command line (with the putty console) in the folder scripts "php sonos.play.php", it's working.

Re: Easy Sonos

Posted: Friday 17 July 2015 10:09
by fl1p
It means he can't find the script. Are you sure you put the script it in that place?
Also mind the 3 slashes behind script:

Re: Easy Sonos

Posted: Friday 17 July 2015 10:53
by bran2000
i checked the on action on the switch is :
script:///home/pi/domoticz/scripts/sonos.play.php

i joined some screenshots, it should be helpful, i hope

Re: Easy Sonos

Posted: Friday 17 July 2015 13:46
by wmn79
Not sure if that fixes it but maybe you should set the chmod u+x also on the sonos.class.php. In your screenshot you can see that it is not executable at the moment, while it is required by the sonos.play.php file.

Re: Easy Sonos

Posted: Friday 17 July 2015 14:16
by bran2000
Thanks for your reply, i did the same for the sonos.class.php (chmod u+x sonos.class.php) but still the same message : "Error executing scrript command /home/pi/domoticz/scripts/sonos.play.php returned 32512" in the logs.

Re: Easy Sonos

Posted: Sunday 19 July 2015 12:36
by G3rard
I use a php file as well, but I am calling it using http:// instead of script:///. Maybe you can try that?
My php file is running from the web server of my NAS so not on a Pi.

Re: Easy Sonos

Posted: Sunday 19 July 2015 13:08
by Holland
Try the following.

On the first line of sonos.play.php

Remove; (don't what's behind the red square). #!/usr/bin/env php

Replace by this;

#!/usr/bin/php

Re: Easy Sonos

Posted: Monday 20 July 2015 9:43
by bran2000
Sorry, i already tried, it's not working

Re: Easy Sonos

Posted: Monday 20 July 2015 19:23
by trekker25
noticed that a simple Play() command is not working if you have a group of 2 Sonos players?

sometimes i have my 2 speakers as group (1 in kitchen, 1 in living).

Trying to figure out how to solve this!

EDIT this seems not needed.
Play wasn't working because there was nothing in the queue.

EDIT2 trying to get a mp3 played for my doorbell:

$sonos_1->Stop();
$sonos_1->AddURIToQueue("x-file-cifs://172.16.0.3/Public/MEDIA/MP3/dingdong.mp3",1) ;
$sonos_1->Next();
$sonos_1->Play();

for some reason first it worked and the mp3 was inserted inside the queue as the next song. But after some testing, it is added evertime as the last one of the queue??

anyone had the same issue? Other problem there is: a Radio stream is not considered as a Queue and nothing can be added! So need to check first if Stream is playing or queue!

Re: Easy Sonos

Posted: Monday 20 July 2015 21:28
by G3rard
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.

Re: Easy Sonos

Posted: Monday 20 July 2015 23:17
by trekker25
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.
Thanks, this one does exactly what I need it for!

also when in a group, the message goes only to the speaker i choose. And afterwards the 2 speakers get correctly in sync again. But need to test, as i want it to be sent to both speakers (1 in kitchen, 1 in living room).

Also i only have it working for now from my own pc running WAMP with php/etc and just browsing to
http://localhost/sonos/index.php?zone=k ... &volume=20

How do I use it in DOmoticz? I created a virtual switch and tried script://home/pi/scripts/sonos/index.php?zone=kitchen&action=sendMessage&messageId=1&volume=20 but doesn't seem to work. Also see now logging. but gave the folder sonos 777 rights?

Re: Easy Sonos

Posted: Tuesday 21 July 2015 0:14
by G3rard
trekker25 wrote: How do I use it in DOmoticz? I created a virtual switch and tried script://home/pi/scripts/sonos/index.php?zone=kitchen&action=sendMessage&messageId=1&volume=20 but doesn't seem to work. Also see now logging. but gave the folder sonos 777 rights?
See my post above http://www.domoticz.com/forum/viewtopic ... 214#p49096, please try that.
I think you always have to start a php with http and not with script.

Re: Easy Sonos

Posted: Tuesday 21 July 2015 8:13
by Derik
There is a icon on the drive for sonos

Re: Easy Sonos

Posted: Tuesday 21 July 2015 8:26
by trekker25
Derik wrote:There is a icon on the drive for sonos
what do you mean by this?


running it with http:// wil also not work on Rpi, as when i try to access http://ip_rpi/ nothing happens. And with script:// it doesn't seem to do anything.

Read somewhere you need to run apache2 besides the builtin webserver. (for the dashboard on :8080)

So probably going to run it from my NAS.

see this topic:
http://www.domoticz.com/forum/viewtopic.php?f=4&t=7067

In this wiki:
https://www.domoticz.com/wiki/Scripts#PHP_Scripts

it would be usefull if it would mentioned that PHP scripts can't be called from a Switch?

Re: Easy Sonos

Posted: Tuesday 21 July 2015 8:33
by Derik
https://drive.google.com/folderview?id= ... sp=sharing

You can find a sonos icon for your Domoticz webui...