Step by step guide: Sonos integration

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

Moderator: leecollings

User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Step by step guide: Sonos integration

Post by leecollings »

Yes, you can select just one speaker. Check out the documentation for the full list of commands you can use: https://github.com/jishi/node-sonos-http-api

E.g.
/{Room name}/clip/{filename}[/{announce volume}]
/clipall/{filename}[/{announce volume}]

Examples:
/clipall/sample_clip.mp3
/clipall/sample_clip.mp3/80
/Office/clip/sample_clip.mp3
/Office/clip/sample_clip.mp3/30
Heursqem
Posts: 18
Joined: Sunday 20 March 2016 14:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Step by step guide: Sonos integration

Post by Heursqem »

leecollings wrote:
Heursqem wrote:This is what I would love to achieve

#1 - Someone pushes my doorbell
#2 - I capture the current state of my sonos player (medium, song, volume etc) and save this for later
#3 - I play my own sound through the sonos player (ding-dong)
#4 - I go back to to captured/saved state and listen to original music again

Would all of this be possible with this solution?
Hey, you can already do this with the clipall command (if you want to play the announcement through all Sonos devices on your network).

You can handle all of the above by using:

Code: Select all

http://localhost:5005/clipall/name-of-your-mp3.mp3
(store your mp3 file in /static/clips/)
Works awesome, thanks!!!!
junr
Posts: 6
Joined: Tuesday 07 June 2016 23:02
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Step by step guide: Sonos integration

Post by junr »

ironrider wrote:Hi,

i have to start server.js after a Domoticz reset.
Is ist possible to make the server.js running as a service.
Thanx

Sven
Sven,

Go to the api directory

Code: Select all

cd node-sonos-http-api 
Start de pm2 server

Code: Select all

 sudo pm2 start server.js 
Save the process

Code: Select all

 sudo pm2 save 
The pm2 will save the running process.

Code: Select all

Sudo reboot
It works fine now

Greetz JUNR
RFXcom | Toon | Zware | Sonos |
RezzZ
Posts: 9
Joined: Friday 15 September 2017 17:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Step by step guide: Sonos integration

Post by RezzZ »

Hi guys, I'm trying to get this working for my sonos system and got the api working.

problem now is to create that dummy device and switch:
9. Create a selector switch (create a dummy device and pick selector switch in the list of virtual devices ) according to the below images;
How do I create a dummy device? The device page doesn't allow me to create devices..
I can create new hardware (1-Wire (System)) but it will not create any devices I can use for the selector.
What am I missing?
junr
Posts: 6
Joined: Tuesday 07 June 2016 23:02
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Step by step guide: Sonos integration

Post by junr »

RezzZ

Create a Dummy switch in the hardware tab
Make a virtual sensor with Selector Switch.
in the device tab you select the dummy with

Hope it helps.

Greetz Junr
RFXcom | Toon | Zware | Sonos |
RezzZ
Posts: 9
Joined: Friday 15 September 2017 17:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Step by step guide: Sonos integration

Post by RezzZ »

thanks Junr! I totally missed the dummy switch as a hardware device but it is really in the list...

thanks again!
RezzZ
Posts: 9
Joined: Friday 15 September 2017 17:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Step by step guide: Sonos integration

Post by RezzZ »

any chance someone has already created a transparant icon set for sonos?
the file from dhanjel (posted 8-6-2016) has white corners, not transparant.
royson
Posts: 13
Joined: Friday 10 November 2017 20:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Step by step guide: Sonos integration

Post by royson »

Hi guys.
Im new here and have tried this great solution, but I have wierd problem.
Im running my domoticz installation with https and the switch sends commands in http. Not sure if this is the problem but it doesnt work. If I send the command directly in the browser with http it works, so the api is active. But if I use the exact same link on a selector in domoticz, nothing happends.
Which log can I start searching in for clues?

Thanks in advance for any help.
royson
Posts: 13
Joined: Friday 10 November 2017 20:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Step by step guide: Sonos integration

Post by royson »

royson wrote:Hi guys.
Im new here and have tried this great solution, but I have wierd problem.
Im running my domoticz installation with https and the switch sends commands in http. Not sure if this is the problem but it doesnt work. If I send the command directly in the browser with http it works, so the api is active. But if I use the exact same link on a selector in domoticz, nothing happends.
Which log can I start searching in for clues?

Thanks in advance for any help.
Edit:
I figured it out. Nothing to do with the encryption fortunately. Domoticz just wasnt able to convert the space in "dining room". All sorted now =)
Next step is adding TTS.

Sent from my LG-H815 using Tapatalk

BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

Re: Step by step guide: Sonos integration

Post by BakSeeDaa »

Hi there!

I just had a look at the node-sonos-http-api. I haven't tried it yet, (still waiting for 2 pcs Sonos One to be delivered) but it looks really nice.

I also had a quick look at the LUA script in the initial post. It seems to be a device triggered script so it will run whenever a device changes in Domoticz. That can happen quite often and will put some burden on the Domoticz server for sure.

Looking a bit closer at node-sonos-http-api I see that there is support for a web hook. That sounds promising because using that, Domoticz wouldn't have to do polling the API for changes. Instead Domoticz can be "push noticed" whenever there is a status change. It should be much faster and more efficient than polling. One small problem is that Domoticz currently doesn't have a way to trigger a specific script using the API. Therefore to use the web hook functionality we'd need some software to interpret whats coming in and inform Domoticz about it. That wouldn't be so hard to do.

I've started a nodejs project to intercept events from node-sonos-http-api using web hooks and use them to inform Domoticz. I'll let you know when I have been able to test it in case someone is interested.
MiWa4711
Posts: 7
Joined: Tuesday 28 November 2017 18:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Step by step guide: Sonos integration

Post by MiWa4711 »

Hi,
I am a beginner started with domoticz 8 weeks ago. Now after all my lights are integrated I am looking for sonos.

Did installation following step by step guide but failed.

Can anyone please help me?

Thanks.
Attachments
npm_debug.log.JPG
npm_debug.log.JPG (68.16 KiB) Viewed 6635 times
error2.JPG
error2.JPG (35.79 KiB) Viewed 6635 times
Error1.JPG
Error1.JPG (50.31 KiB) Viewed 6635 times
MiWa4711
Posts: 7
Joined: Tuesday 28 November 2017 18:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Step by step guide: Sonos integration

Post by MiWa4711 »

Dear all,

now it runs. Juhu....
RedFish
Posts: 4
Joined: Thursday 08 February 2018 19:33
Target OS: -
Domoticz version:
Contact:

Re: Step by step guide: Sonos integration

Post by RedFish »

MiWa4711 wrote: Saturday 06 January 2018 17:22 Dear all,

now it runs. Juhu....
How you do it...i've got same problem !!!

EDIT: It's good for me.........It's alive !!! :D :D :D
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: Step by step guide: Sonos integration

Post by AllesVanZelf »

Heursqem wrote: Wednesday 31 May 2017 13:22
leecollings wrote:
Heursqem wrote:This is what I would love to achieve

#1 - Someone pushes my doorbell
#2 - I capture the current state of my sonos player (medium, song, volume etc) and save this for later
#3 - I play my own sound through the sonos player (ding-dong)
#4 - I go back to to captured/saved state and listen to original music again

Would all of this be possible with this solution?
Hey, you can already do this with the clipall command (if you want to play the announcement through all Sonos devices on your network).

You can handle all of the above by using:

Code: Select all

http://localhost:5005/clipall/name-of-your-mp3.mp3
(store your mp3 file in /static/clips/)
But how could I store the actual state, so I can resume after the clipall command?
leecollings wrote: Wednesday 31 May 2017 14:06 It stores the current state within the command. Try it out and you'll see.

I've tested it, with a Play 1 playing a song, it pauses, plays the mp3 file, and then resumes the previously playing song.
I noticed that this is not always working well. I have two sonos-speakers.
If I send a clipall command to the sonoses, the sounds plays well on both speakers, but afterwards the music does not continue where it was. I think the music starts on the playlist from one of the speakers, not always the right one.

But if I send the command to both speakers separately (two links), it works well.
Just for the record 8-)
It might be a coding error?
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
josimd
Posts: 59
Joined: Saturday 09 January 2016 19:47
Target OS: -
Domoticz version:
Contact:

Re: Step by step guide: Sonos integration

Post by josimd »

Gents, installed in on my Synology NAS, and can start / stop my Sonos speakers via the URL in my browser. But is doesn't start with the selector switch in Domoticz when im using the same url... Fout bij verzenden van schakelaar opdracht, controleer apparaat/hardware!

Anyone?


Thanks :-)
Holland
Posts: 179
Joined: Friday 12 July 2013 13:53
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta Ch
Location: The Netherlands
Contact:

Re: Step by step guide: Sonos integration

Post by Holland »

@josimd

Should work. Can you share the url that you use to let it start playing
josimd
Posts: 59
Joined: Saturday 09 January 2016 19:47
Target OS: -
Domoticz version:
Contact:

Re: Step by step guide: Sonos integration

Post by josimd »

Thanks for reply;

in my browser: http://192.168.86.136:5005/woonkamer/play

(small think is when I use http://192.168.86.136:5005/woonkamer/pauze it doesn't stop)

and I use the same in Domoticz;

http://192.168.86.136:5005/woonkamer/play

But then I get the error
Holland
Posts: 179
Joined: Friday 12 July 2013 13:53
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta Ch
Location: The Netherlands
Contact:

Re: Step by step guide: Sonos integration

Post by Holland »

The following url should be changed ;

http://192.168.86.136:5005/woonkamer/pauze

to

http://192.168.86.136:5005/woonkamer/pause

What is the version of Domoticz you are running. Because, some time ago there were some issues with the selector switch. But that has been resolved.
josimd
Posts: 59
Joined: Saturday 09 January 2016 19:47
Target OS: -
Domoticz version:
Contact:

Re: Step by step guide: Sonos integration

Post by josimd »

I'm running on V4.9700 (synology)
Holland
Posts: 179
Joined: Friday 12 July 2013 13:53
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta Ch
Location: The Netherlands
Contact:

Re: Step by step guide: Sonos integration

Post by Holland »

josimd wrote: Sunday 16 September 2018 13:14 I'm running on V4.9700 (synology)
Is new enough.

Can you check again, if your setup similar to the below;
Attachments
Capture.JPG
Capture.JPG (211.13 KiB) Viewed 4847 times
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests