Step by step guide: Sonos integration
Moderator: leecollings
Re: Step by step guide: Sonos integration
its exactly the same
- Attachments
-
- Schermafbeelding 2018-09-16 om 13.59.21.png (312.64 KiB) Viewed 6183 times
-
- 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
Almost out of idea's. Apparently the link between the button and the device is gone.
I would delete the selector switch and the dummy.
Then recreate a dummy for each Sonos group/or device. Recreate the selector switch for each Sonos group/or device
I would delete the selector switch and the dummy.
Then recreate a dummy for each Sonos group/or device. Recreate the selector switch for each Sonos group/or device
Re: Step by step guide: Sonos integration
yes that did the trick! its working now in Domoticz. Do you also how to run the api continuously, now, when I close the terminal de pipe is broken. Is there an option within synology which I can use?
-
- 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
The solution is PM2, but I have it running on a RPi. See also the first post in this threat.
Don't know if PM2 can run on a synology.
Re: Step by step guide: Sonos integration
I have it running on my synology NAS, instead of PM2 you can run node server.js via another way, see link below.
https://www.youtube.com/watch?v=tkbu3TT5LT8
https://www.youtube.com/watch?v=tkbu3TT5LT8
-
- 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
How do I update the Sonos HTTP API from git without loosing my settings?
git pull in this directory?
git pull in this directory?
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
-
- Posts: 54
- Joined: Sunday 27 December 2015 19:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Netherlands
- Contact:
Re: Step by step guide: Sonos integration
Dear all,rjpost wrote: ↑Monday 29 May 2017 11:20 Hello Guys,
I was wondering if you could provide me with some guidance in regards to getting this Sonos integration to work the way i would like to.
I have the following objective. I want to use a sonos connect ( not the amp version). When I select play on that specific sonos I want my to turn my receiver on and set it to input AUX. I want to achieve this through the Harmony HUB. I can control that perfectly through domoticz however I need to determine whether or not a specific sonos player is playing music.
I wanted to create an event with blocky to sent a command to the harmony hub when the sonos switch is set to status playing.
<deleted>
Can some explain to me where I should change the variables so it will work in my setup.
any help is appreciated.
Thanks a lot.
- Ronald-
Wanted to achieve the same with my Onkyo AV Receiver. Thinking that if I start my Sonos connect in the Living Room, Domoticz should turn on automatically the receiver and switch to the right input channel. Made a small modification to the script elsewhere in this thread, and it works like a charm. Hope it useful for someone else.
regards, Jeroen
Code: Select all
--
--
-- Domoticz LUA Script to turn Onkyo Receiver on when Sonos is playing
-- Date: 2018-12-24
--
--
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
local sonos=assert(io.popen('curl http://192.168.178.55:5005/Woonkamer/state'))
local status = sonos:read('*all')
sonos:close()
local jsonStatus = json:decode(status)
local sonos_woonkamer = 'Sonos Woonkamer'
local onkyo_switch = 'Onkyo versterker'
local onkyo_input = 'Versterker Ingang'
--print(status)
playerstate = jsonStatus['playbackState']
-- artist = jsonStatus['currentTrack']['artist']
-- title = jsonStatus['currentTrack']['title']
-- album = jsonStatus['currentTrack']['album']
-- streaminfo = jsonStatus['currentTrack']['streamInfo']
commandArray = {}
if (playerstate == "PLAYING" or playerstate == "STOPPED" or playerstate == "PAUSED_PLAYBACK") then
if playerstate == "PLAYING" then
if otherdevices[sonos_woonkamer]~='Playing' then
commandArray[sonos_woonkamer]='Set Level 10'
--os.execute('curl http://192.168.1.4:8080/json.htm?type=command¶m=switchlight&idx=103&switchcmd=Set%20Level&level=10')
print('Sonos Woonkamer status: ' ..playerstate)
end
if otherdevices[onkyo_switch]~='On' then
commandArray[onkyo_switch]='On'
print('Onkyo switched on because Sonos Woonkamer is playing.')
if otherdevices[onkyo_input]~='Sonos' then
commandArray[onkyo_input]='Set Level 20'
print('Onkyo switched to Sonos, as input was on different channel.')
end
end
end
if playerstate == "PAUSED_PLAYBACK" then
if otherdevices[sonos_woonkamer]~='Paused' then
commandArray[sonos_woonkamer]='Set Level 20'
--os.execute('curl http://192.168.1.4:8080/json.htm?type=command¶m=switchlight&idx=103&switchcmd=Set%20Level&level=20')
print('Sonos Woonkamer: ' ..playerstate)
end
end
if playerstate == "STOPPED" then
if otherdevices[sonos_woonkamer]~='Off' then
commandArray[sonos_woonkamer]='Set Level 0'
--os.execute('curl http://192.168.1.4:8080/json.htm?type=command¶m=switchlight&idx=103&switchcmd=Set%20Level&level=20')
print('Sonos Woonkamer: ' ..playerstate)
end
end
else
--print("2")
--print('</font color="red">Sonos Woonkamer: SONOS-HTTP-API is off-line</font>')
end
return commandArray
- Dutchsea
- Posts: 120
- Joined: Tuesday 08 December 2015 13:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version: v2023.2
- Location: The Netherlands
- Contact:
Re: Step by step guide: Sonos integration
Hi, enter the string in a webbrowser, not in the command line of your Raspberry pi!Asterixenobelix wrote: ↑Monday 22 May 2017 18:46 Anyone else any suggestions about my above mentioned problem? Is there a way to uninstall the sonos-api and install it again? I keep getting the error message when entering the right http-command.
And for IP use the ip address of your Pi
Raspberry PI 3B on USB drive, Debian version: 12 (bookworm), Domoticz 2024.7
Aeon Z-Wave G5 stick, RFXCOM, Sonof Zigbee 3.0 Dongle plus E, Nefit Easy, Fritzbox, Buienradar, Sonos
Aeon Z-Wave G5 stick, RFXCOM, Sonof Zigbee 3.0 Dongle plus E, Nefit Easy, Fritzbox, Buienradar, Sonos
- Dutchsea
- Posts: 120
- Joined: Tuesday 08 December 2015 13:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version: v2023.2
- Location: The Netherlands
- Contact:
Re: Step by step guide: Sonos integration
Hi, i have Sonos up and running and 4 rooms work perfect. I just get errors for 1 room.
I changed the room name in the Sonos app as it had spaces in the name. But still i get errors.
I used the command: http:/ip:5005/zones to get info on the zones. In the info i see the old name still present eventhough the sonos app uses the new name. Is the Domoticz plugin storing the names at initial install that dont change when the names in the sonos system are changed? If so, how do i change the old name in the new name?
I changed the room name in the Sonos app as it had spaces in the name. But still i get errors.
I used the command: http:/ip:5005/zones to get info on the zones. In the info i see the old name still present eventhough the sonos app uses the new name. Is the Domoticz plugin storing the names at initial install that dont change when the names in the sonos system are changed? If so, how do i change the old name in the new name?
Raspberry PI 3B on USB drive, Debian version: 12 (bookworm), Domoticz 2024.7
Aeon Z-Wave G5 stick, RFXCOM, Sonof Zigbee 3.0 Dongle plus E, Nefit Easy, Fritzbox, Buienradar, Sonos
Aeon Z-Wave G5 stick, RFXCOM, Sonof Zigbee 3.0 Dongle plus E, Nefit Easy, Fritzbox, Buienradar, Sonos
-
- 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
@Dutchsea
I think a restart of the server instance would do it, assuming that the name server.js is still valid in your case
I think a restart of the server instance would do it, assuming that the name server.js is still valid in your case
Code: Select all
pm2 restart server
- Dutchsea
- Posts: 120
- Joined: Tuesday 08 December 2015 13:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version: v2023.2
- Location: The Netherlands
- Contact:
Re: Step by step guide: Sonos integration
Thank you. I rebooted the Pi twice. After the second time the name matched.
Raspberry PI 3B on USB drive, Debian version: 12 (bookworm), Domoticz 2024.7
Aeon Z-Wave G5 stick, RFXCOM, Sonof Zigbee 3.0 Dongle plus E, Nefit Easy, Fritzbox, Buienradar, Sonos
Aeon Z-Wave G5 stick, RFXCOM, Sonof Zigbee 3.0 Dongle plus E, Nefit Easy, Fritzbox, Buienradar, Sonos
-
- Posts: 55
- Joined: Sunday 23 October 2016 19:49
- Target OS: Linux
- Domoticz version: 4.10778
- Contact:
Re: Step by step guide: Sonos integration
Hi,
I have followed the installation procedure ... https://github.com/jishi/node-sonos-http-api
But the process failed at this step
start the server by running
npm start
Attached the log
Please advise .
Thank you
I have followed the installation procedure ... https://github.com/jishi/node-sonos-http-api
But the process failed at this step
start the server by running
npm start
Attached the log
Code: Select all
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose config Skipping project config: /home/gerardosamara/.npmrc. (matches userconfig)
5 verbose stack Error: ENOENT: no such file or directory, open '/home/gerardosamara/package.json'
5 verbose stack at Error (native)
6 verbose cwd /home/gerardosamara
7 error Linux 4.9.0-9-amd64
8 error argv "/usr/bin/node" "/usr/bin/npm" "start"
9 error node v4.9.1
10 error npm v2.15.12
11 error path /home/gerardosamara/package.json
12 error code ENOENT
13 error errno -2
14 error syscall open
15 error enoent ENOENT: no such file or directory, open '/home/gerardosamara/package.json'
15 error enoent This is most likely not a problem with npm itself
15 error enoent and is related to npm not being able to find a file.
16 verbose exit [ -2, true ]
Thank you
Domoticz Beta V4.11763 in Debian 10 VM
Domoticz Beta V4.11763 in RPI3
MDAH 0.2.42 + Imperihome Pro V4.3.17
App Android Domoticz Lite V0.2.201
Domoticz Beta V4.11763 in RPI3
MDAH 0.2.42 + Imperihome Pro V4.3.17
App Android Domoticz Lite V0.2.201
-
- 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
@gerardosamara
Try to follow my guide, see first post.
Therefore, skip the part.
Try to follow my guide, see first post.
Therefore, skip the
Code: Select all
npm start
-
- Posts: 55
- Joined: Sunday 23 October 2016 19:49
- Target OS: Linux
- Domoticz version: 4.10778
- Contact:
Re: Step by step guide: Sonos integration
@Holland,
Finally I re-installed and it works following the installation guide in post#1 , on my Debian9 machine
Pm2 was not installed .
After installing Pm2 , "Pm2 list" shows the server on line
Step#8 : Basic commands play" , "pause" , "state" are OK
==> GREAT !
Finally I re-installed and it works following the installation guide in post#1 , on my Debian9 machine
Pm2 was not installed .
After installing Pm2 , "Pm2 list" shows the server on line
Step#8 : Basic commands play" , "pause" , "state" are OK
==> GREAT !
Domoticz Beta V4.11763 in Debian 10 VM
Domoticz Beta V4.11763 in RPI3
MDAH 0.2.42 + Imperihome Pro V4.3.17
App Android Domoticz Lite V0.2.201
Domoticz Beta V4.11763 in RPI3
MDAH 0.2.42 + Imperihome Pro V4.3.17
App Android Domoticz Lite V0.2.201
-
- Posts: 55
- Joined: Sunday 23 October 2016 19:49
- Target OS: Linux
- Domoticz version: 4.10778
- Contact:
Re: Step by step guide: Sonos integration
The step #8 has been completed successfully ( Sonos selector switch)
But the server does not run automatically after a reboot ( need to do a pm2 start server.js )
How to setup the automotic start at boot in a Debian 9 installation , There is no procedure in this post#1 stet by step procedure ?
Thank you
But the server does not run automatically after a reboot ( need to do a pm2 start server.js )
How to setup the automotic start at boot in a Debian 9 installation , There is no procedure in this post#1 stet by step procedure ?
Thank you
Domoticz Beta V4.11763 in Debian 10 VM
Domoticz Beta V4.11763 in RPI3
MDAH 0.2.42 + Imperihome Pro V4.3.17
App Android Domoticz Lite V0.2.201
Domoticz Beta V4.11763 in RPI3
MDAH 0.2.42 + Imperihome Pro V4.3.17
App Android Domoticz Lite V0.2.201
-
- Posts: 28
- Joined: Friday 01 December 2017 18:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Step by step guide: Sonos integration
Cant get this running without issues...
Code: Select all
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose stack Error: ENOENT: no such file or directory, open '/home/pi/package.json'
4 verbose stack at Error (native)
5 verbose cwd /home/pi
6 error Linux 4.19.42-v7+
7 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
8 error node v5.6.0
9 error npm v3.6.0
10 error path /home/pi/package.json
11 error code ENOENT
12 error errno -2
13 error syscall open
14 error enoent ENOENT: no such file or directory, open '/home/pi/package.json'
15 error enoent ENOENT: no such file or directory, open '/home/pi/package.json'
15 error enoent This is most likely not a problem with npm itself
15 error enoent and is related to npm not being able to find a file.
16 verbose exit [ -2, true ]
-
- Posts: 62
- Joined: Friday 27 July 2018 19:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Step by step guide: Sonos integration
Thank you for all the work! It works like a charm.
I did however changed the dz script from anfelt, so now the played numbers / radio station are displayed in a seperate device. I also updated the icons from dhanjel, so now they don't have white borders anymore.
The script can be found at Github.
I had some problems with the auto-start of pm2, so I followed the steps from junr and that works like a charm. Of course you need pm2 in order for this to work, you can install that the help of this post. And pm2 do also need autostart, you can set that up with.
I did however changed the dz script from anfelt, so now the played numbers / radio station are displayed in a seperate device. I also updated the icons from dhanjel, so now they don't have white borders anymore.
The script can be found at Github.
I had some problems with the auto-start of pm2, so I followed the steps from junr and that works like a charm. Of course you need pm2 in order for this to work, you can install that the help of this post. And pm2 do also need autostart, you can set that up with.
Last edited by rensbr on Wednesday 25 September 2019 11:26, edited 3 times in total.
- 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
Any plans for the Sonos plug-in to be added to the stable release yet? Is it working reliably on the beta?
-
- Posts: 4
- Joined: Sunday 13 October 2019 12:09
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Contact:
Re: Step by step guide: Sonos integration
Hi All,
First thanks for all the good work!
I have the Sonos plugin up and running and it works well, except one thing...
After a notification Sonos won't start automatically when playing music directly from the Spotify app(Spotify connect).
If I play music by the Sonos app everything seems to be ok, but I prefer the Spotify app.
In the log I get the following error:
2019-10-13 11:50:30.677 Error: (Sonos Veranda) Unexpected response status received in function sendMessage (500, Internal Server Error). The following command is sent: urn:schemas-upnp-org:service:AVTransport:1#Seek, /MediaRenderer/AVTransport/Control
I'm running Domoticz 4.10717, Python 3.5.3, Raspberry Pi
Anyone who can help me?
First thanks for all the good work!
I have the Sonos plugin up and running and it works well, except one thing...
After a notification Sonos won't start automatically when playing music directly from the Spotify app(Spotify connect).
If I play music by the Sonos app everything seems to be ok, but I prefer the Spotify app.
In the log I get the following error:
2019-10-13 11:50:30.677 Error: (Sonos Veranda) Unexpected response status received in function sendMessage (500, Internal Server Error). The following command is sent: urn:schemas-upnp-org:service:AVTransport:1#Seek, /MediaRenderer/AVTransport/Control
I'm running Domoticz 4.10717, Python 3.5.3, Raspberry Pi
Anyone who can help me?
-
- Posts: 58
- Joined: Thursday 20 April 2017 1:17
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Location: France
- Contact:
Re: Step by step guide: Sonos integration
Dear all,junr wrote: ↑Sunday 18 June 2017 12:18Sven,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
Go to the api directory
Start de pm2 serverCode: Select all
cd node-sonos-http-api
Save the processCode: Select all
sudo pm2 start server.js
The pm2 will save the running process.Code: Select all
sudo pm2 save
It works fine nowCode: Select all
Sudo reboot
Greetz JUNR
I just setup the node-sonos-http-api on my pi3 with raspbian buster which is working like a charm

Just wanna add than i add to run
Code: Select all
sudo pm2 startup

Code: Select all
cd node-sonos-http-api
sudo pm2 start server.js
sudo pm2 save
sudo reboot
RPI3 Raspbian Buster + Domoticz v2020.1 stable + RFXtrx433E + Z-Stick Gen5 + Amazon Echo (alexicz)
x5 THGN810 / x5 ZMNHJD1 / x2 Flood sensor FGFS101 / x1 Smoke sensor FGSD002
x1 ZMNHAD1 / x2 FGS213 / x3 Wallplug FGWPE/F / NodOn Soft remote CRC-3-6-0
x5 THGN810 / x5 ZMNHJD1 / x2 Flood sensor FGFS101 / x1 Smoke sensor FGSD002
x1 ZMNHAD1 / x2 FGS213 / x3 Wallplug FGWPE/F / NodOn Soft remote CRC-3-6-0
Who is online
Users browsing this forum: No registered users and 1 guest