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
fl1p
Posts: 17
Joined: Friday 19 July 2013 12:27
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Belgium
Contact:

Re: Easy Sonos

Post 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?
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 »

Add a virtual switch and put the php url in the On Action of the switch.
Not using Domoticz anymore
User avatar
fl1p
Posts: 17
Joined: Friday 19 July 2013 12:27
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Belgium
Contact:

Re: Easy Sonos

Post 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...?
bran2000
Posts: 60
Joined: Saturday 20 June 2015 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Easy Sonos

Post 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"
User avatar
fl1p
Posts: 17
Joined: Friday 19 July 2013 12:27
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Belgium
Contact:

Re: Easy Sonos

Post 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...
bran2000
Posts: 60
Joined: Saturday 20 June 2015 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Easy Sonos

Post 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.
User avatar
fl1p
Posts: 17
Joined: Friday 19 July 2013 12:27
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Belgium
Contact:

Re: Easy Sonos

Post 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:
bran2000
Posts: 60
Joined: Saturday 20 June 2015 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Easy Sonos

Post 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
Attachments
image2.PNG
image2.PNG (329.5 KiB) Viewed 4132 times
image1.PNG
image1.PNG (171.25 KiB) Viewed 4132 times
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 »

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.
bran2000
Posts: 60
Joined: Saturday 20 June 2015 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Easy Sonos

Post 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.
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 »

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.
Not using Domoticz anymore
Holland
Posts: 179
Joined: Friday 12 July 2013 13:53
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta Ch
Location: The Netherlands
Contact:

Re: Easy Sonos

Post 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
bran2000
Posts: 60
Joined: Saturday 20 June 2015 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Easy Sonos

Post by bran2000 »

Sorry, i already tried, it's not working
Attachments
Capture.PNG
Capture.PNG (9.54 KiB) Viewed 4085 times
trekker25
Posts: 40
Joined: Tuesday 26 May 2015 10:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Easy Sonos

Post 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!
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 »

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.
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: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?
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: 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.
Not using Domoticz anymore
Derik
Posts: 1602
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Easy Sonos

Post by Derik »

There is a icon on the drive for sonos
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
trekker25
Posts: 40
Joined: Tuesday 26 May 2015 10:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Easy Sonos

Post 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?
Derik
Posts: 1602
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Easy Sonos

Post by Derik »

https://drive.google.com/folderview?id= ... sp=sharing

You can find a sonos icon for your Domoticz webui...
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests