Connecting Sonos with KNX

After some more work I came up with a better solution written on C# by using Open Software’s UPnP stacks. The advantage is that the whole solution is installable and works out of the box.

Every user is only responsible to edit the UniqueDeviceNames.ini file in a proper way. We assist this step too.

What you need

  1. A KNX installation and properly defined group addresses (see [commands list] section of the ini file). Also you need a KNX/IP interface to be able to transmit selected KNX telegrams via IP network. In particular, a Gira HomeServer can perform this function.
  2. A Sonos system. We will discover all online ZonePlayers and put them in a text file for your convenience. Do not mind anymore the complicated IDs, will use only friendly names as you see them in the original Sonos Controlles.
  3. A Windows box with Microsoft .NET Framework 2.0
  4. The Sonos KNX interface Setup v1.0.0 kit from here. PLEASE DO NOT INSTALL THIS VERSION ANYMORE! CHECK BELOW FOR UPDATES!

How to install

  1. Double click on setup.exe and follow the directions on the screen. Accept all security warnings (windows and firewall). Remember the installation folder location.
  2. Go to computer management, expand Services and look for SonosHS service. Start it (only once, the service is set to automatic startup for the future)
  3. in about 30 seconds a filename UniqueDevicesNames.txt will be written in the installation folder. Check this file to make sure you use the proper Zone Players friendly names in the next step
  4. edit the file UniqueDevicesNames.ini and make sure to use proper group addresses and zone player names in sections [map_to_zone] and [map_to_command]. For a list of available zones see UniqueDevicesNames.txt and for a list of available commands see the [commands list - this section is only informative] section. Also make sure you input proper IP and port addresses for the KNX IP interface.
  5. save the ini file. there is no need to restart the service, all should work from now on

How to debug

Stay tuned, I will post a Windows form application with identical functionality soon. Just look at the form and see if you can properly receive the KNX telegrams. The source code (VS2010 solution) is available upon request.

Known issues

  1. if you add a Zone Player after the service starts, this Zone Player will not be visible to the interface until the service SonosHS is restarted (or the computer is restarted)
  2. not all commands are implemented at this moment
  3. there is no feedback implemented from Sonos to the KNX
  4. the solution requires some CPU and memory optimization

Enjoy!

UPDATE 22/10/2010

Here are the new setup kits for version 1.0.2. See below change log for more information

  1. Windows service setup kit
  2. Windows application setup kit

ChangeLog

1.0.2

- compatible with 32 and 64 bits systems
- added: toggleMute 1bit command
- added: balance control via EIS6 command (0=max left, 50=balanced, 100=max right)
- added: play mode change via KNX 4 bit control with 0:NORMAL, 1:INTRO, 2:SHUFFLE, 3:RANDOM, 4:REPEAT_ONE, 5:REPEAT_ALL, 6-15:NORMAL
- got rid of UniqueDeviceNames.txt file, now we manage the [zone_list] section inside the UniqueDeviceNsmes.ini file directly
- more debug information in EventViewer, under Application logs, source SonosHS
- the service starts automatically, no need for user intervention (not nice solution but it works)

issues: Sonos ZonePlayers seem to respond inaccurately to Play Mode commands, perhaps the UPnP standard implementation does not match between Sonos and Open Software (Intel)

1.0.1 - initial version x86 compatible only
- supports transport commands: play, stop, pause, next, previous, mute, unmute
- supports volume commands: master volume via EIS 6 (0...100)

Comments

18 responses to “Connecting Sonos with KNX”

  1. Martin Avatar
    Martin

    Hi,

    Getting the following error:

    A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 192.168.1.13:7003

    IP is correct not sure about the port no info form my IP interface.

    Many Thanks

    Martin

  2. Hi, you need to make sure you configure the “Communication object gatweay” in your “Project settings” in Expert software then upload the new configuration to Gira HomeServer.
    My values are:
    1. Send and receive comm objects via network – checked
    2. Local IP port – 7003
    3. Sender 1 – checked, with IP address the IP address of the box you run the application, net mask – your network mask

  3. Martin Avatar
    Martin

    Excellent, forgot to check the send and receive comm objects – works great! Thanks for the application.

    Martin

  4. Actually you will learn that in several hours the service fails due to some memory leaks (it can be programmed to restart automatically though). I was unable to fix the leaks, they are over my capacity to deal with no matter what.

    I am looking for someone interested in the project and with experience in .NET programming to try to fix the issue. I can give all source code and collaborate on it.

  5. Davey Jones Avatar
    Davey Jones

    Great post, this looks like it is going to be of great help to me! I have a problem where after I have altered the file to include the appropriate commands I try to save it but it tells me access is denied?

    Any help would be greatly appreciated!!

    Kind regards,

    Davey

  6. The program is installed in protected folders. If you get this message make sure you start your text editor (such as Notepad) with Run as administrator (right click with the mouse). Then you can save the file in the installation folder.

  7. Zone list example in UniqueDeviceNames.ini

    Please check that the format is well, use this example:

    [ZONE_LIST]
    PORTABLE=RINCON_000E5851565201400_MR
    DINING ROOM=RINCON_000E5830093201400_MR
    GUEST ROOM=RINCON_000E58233A4601400_MR
    MASTER BEDROOM=RINCON_000E5821CE0001400_MR
    LIVING ROOM=RINCON_000E58234DF001400_MR
    PATIO=RINCON_000E58133EE401400_MR

  8. MARIO Avatar
    MARIO

    Please send me an exemple of files.ini full. I dont understand thats necessary in map zone et map command
    i send my files
    MAP_TO_ZONE]
    6/2/1=PORTABLE
    6/2/42=DINING ROOM
    6/2/25=LIVING ROOM
    6/2/13=PATIO
    6/2/35=LIVING ROOM
    6/2/16=MASTER BEDROOM
    6/2/53=PATIO
    6/2/43=PATIO
    6/2/6=MASTER BEDROOM
    6/2/33=PATIO
    6/2/52=DINING ROOM
    6/2/15=LIVING ROOM
    6/2/23=PATIO
    6/2/45=LIVING ROOM
    6/2/24=GUEST ROOM
    6/2/36=MASTER BEDROOM
    6/2/51=PORTABLE
    6/2/4=GUEST ROOM
    6/2/31=PORTABLE
    6/2/56=MASTER BEDROOM
    6/2/12=DINING ROOM
    6/2/26=MASTER BEDROOM
    6/2/54=GUEST ROOM
    6/2/5=LIVING ROOM
    6/2/91=PORTABLE
    6/2/32=DINING ROOM
    6/2/46=MASTER BEDROOM
    6/2/71=PORTABLE
    6/2/34=GUEST ROOM
    6/2/11=PORTABLE
    6/2/41=PORTABLE
    6/2/3=PATIO
    6/2/61=PORTABLE
    6/2/2=DINING ROOM
    6/2/14=GUEST ROOM
    6/2/81=PORTABLE
    6/2/21=PORTABLE
    6/2/44=GUEST ROOM
    6/2/55=LIVING ROOM
    6/2/22=DINING ROOM

    [MAP_TO_COMMAND]
    6/2/34=MUTEUNMUTE
    6/2/36=MUTEUNMUTE
    6/2/71=
    6/2/56=
    6/2/1=VOLUMEX
    6/2/31=MUTEUNMUTE
    6/2/44=NEXTPREVIOUS
    6/2/45=NEXTPREVIOUS
    6/2/23=PAUSE
    6/2/2=VOLUMEX
    6/2/24=PAUSE
    6/2/41=NEXTPREVIOUS
    6/2/25=PAUSE
    6/2/22=PAUSE
    6/2/51=
    6/2/91=BALANCE
    6/2/32=MUTEUNMUTE
    6/2/13=PLAYSTOP
    6/2/54=
    6/2/14=PLAYSTOP
    6/2/35=MUTEUNMUTE
    6/2/61=SETPLAYMODE
    6/2/11=PLAYSTOP
    6/2/26=PAUSE
    6/2/6=VOLUMEX
    6/2/15=PLAYSTOP
    6/2/46=NEXTPREVIOUS
    6/2/5=VOLUMEX
    6/2/81=TOGGLEMUTE
    6/2/21=PAUSE
    6/2/43=NEXTPREVIOUS
    6/2/42=NEXTPREVIOUS
    6/2/53=
    6/2/16=PLAYSTOP
    6/2/52=
    6/2/12=PLAYSTOP
    6/2/4=VOLUMEX
    6/2/33=MUTEUNMUTE
    6/2/3=VOLUMEX
    6/2/55=

    [COMMANDS LIST – THIS SECTION IS ONLY INFORMATIVE]
    MUTEUNMUTE = KNX_1BIT_1=MUTE_0=UNMUTE
    SETPLAYMODE = KNX_4BIT_0_15 PLAY MODE: 0:NORMAL, 1:INTRO, 2:SHUFFLE, 3:RANDOM, 4:REPEAT_ONE, 5:REPEAT_ALL
    NEXTPREVIOUS= KNX_1BIT_1=NEXT_0=PREVIOUS
    PLAYSTOP = KNX_1BIT_1=PLAY_0=STOP
    TOGGLEMUTE = KNX_1BIT_1=TOGGLEMUTE
    VOLUMEX = KNX_8BIT_EIS6_0-100_MASTERVOLUME
    PAUSE = KNX_1BIT_1=PAUSE
    BALANCE = KNX_8BIT_EIS6_0-100: 0 IS MAX LEFT, 50 IS BALANCED, 100 IS MAX RIGHT

    [ZONE_LIST]
    PORTABLE=RINCON_000E58721DCC01400_MR
    CHAMBRE ISA=RINCON_000E5871262E01400_MR

    [HS]
    PORT=7003
    KEY=
    IP=192.168.0.170

  9. Hi,

    Since you only have 2 zones named PORTABLE and CHAMBRE ISA, then in MAP_TO_ZONE list please use only those 2 zones and map corresponding KNX group addresses to them.

    In the MAP_TO_COMMAND please take again the above group addresses and specify what they mean. When you create the group addresses in KNX make sure you use the correct format (such as BIT for MUTEUNMUTE, PLAY, STOP etc, or 8 BIT for VOLUMEX)

    Here is my file

    [MAP_TO_ZONE]
    6/2/4=GUEST ROOM
    6/2/34=GUEST ROOM
    6/2/52=DINING ROOM
    6/2/51=PORTABLE
    6/2/56=MASTER BEDROOM
    6/2/42=DINING ROOM
    6/2/12=DINING ROOM
    6/2/35=LIVING ROOM
    6/2/45=LIVING ROOM
    6/2/43=PATIO
    6/2/32=DINING ROOM
    6/2/31=PORTABLE
    6/2/15=LIVING ROOM
    6/2/41=PORTABLE
    6/2/2=DINING ROOM
    6/2/13=PATIO
    6/2/23=PATIO
    6/2/6=MASTER BEDROOM
    6/2/91=PORTABLE
    6/2/25=LIVING ROOM
    6/2/24=GUEST ROOM
    6/2/5=LIVING ROOM
    6/2/11=PORTABLE
    6/2/22=DINING ROOM
    6/2/33=PATIO
    6/2/61=PORTABLE
    6/2/21=PORTABLE
    6/2/14=GUEST ROOM
    6/2/53=PATIO
    6/2/3=PATIO
    6/2/16=MASTER BEDROOM
    6/2/46=MASTER BEDROOM
    6/2/81=PORTABLE
    6/2/26=MASTER BEDROOM
    6/2/54=GUEST ROOM
    6/2/55=LIVING ROOM
    6/2/36=MASTER BEDROOM
    6/2/44=GUEST ROOM
    6/2/1=PORTABLE
    6/2/71=PORTABLE

    [COMMANDS LIST – THIS SECTION IS ONLY INFORMATIVE]
    PLAYSTOP = KNX_1BIT_1=PLAY_0=STOP
    NEXTPREVIOUS= KNX_1BIT_1=NEXT_0=PREVIOUS
    VOLUMEX = KNX_8BIT_EIS6_0-100_MASTERVOLUME
    MUTEUNMUTE = KNX_1BIT_1=MUTE_0=UNMUTE
    TOGGLEMUTE = KNX_1BIT_1=TOGGLEMUTE
    PAUSE = KNX_1BIT_1=PAUSE
    SETPLAYMODE = KNX_4BIT_0_15 PLAY MODE: 0:NORMAL, 1:INTRO, 2:SHUFFLE, 3:RANDOM, 4:REPEAT_ONE, 5:REPEAT_ALL
    BALANCE = KNX_8BIT_EIS6_0-100: 0 IS MAX LEFT, 50 IS BALANCED, 100 IS MAX RIGHT

    [MAP_TO_COMMAND]
    6/2/5=VOLUMEX
    6/2/22=PAUSE
    6/2/24=PAUSE
    6/2/3=VOLUMEX
    6/2/71=
    6/2/15=PLAYSTOP
    6/2/52=
    6/2/46=NEXTPREVIOUS
    6/2/61=SETPLAYMODE
    6/2/14=PLAYSTOP
    6/2/32=MUTEUNMUTE
    6/2/6=VOLUMEX
    6/2/2=VOLUMEX
    6/2/23=PAUSE
    6/2/81=TOGGLEMUTE
    6/2/33=MUTEUNMUTE
    6/2/21=PAUSE
    6/2/91=BALANCE
    6/2/26=PAUSE
    6/2/11=PLAYSTOP
    6/2/43=NEXTPREVIOUS
    6/2/25=PAUSE
    6/2/55=
    6/2/1=VOLUMEX
    6/2/12=PLAYSTOP
    6/2/31=MUTEUNMUTE
    6/2/13=PLAYSTOP
    6/2/54=
    6/2/53=
    6/2/41=NEXTPREVIOUS
    6/2/42=NEXTPREVIOUS
    6/2/16=PLAYSTOP
    6/2/51=
    6/2/36=MUTEUNMUTE
    6/2/56=
    6/2/35=MUTEUNMUTE
    6/2/4=VOLUMEX
    6/2/45=NEXTPREVIOUS
    6/2/44=NEXTPREVIOUS
    6/2/34=MUTEUNMUTE

    [ZONE_LIST]
    GUEST ROOM=RINCON_000E58233A4601400_MR
    UNNAMED ROOM=RINCON_000E58133EE401400_MR
    PORTABLE=RINCON_000E5851565201400_MR
    MASTER BEDROOM=RINCON_000E5821CE0001400_MR
    DINING ROOM=RINCON_000E5830093201400_MR
    PATIO=RINCON_000E58133EE401400_MR
    LIVING ROOM=RINCON_000E58234DF001400_MR

    [HS]
    PORT=7003
    KEY=
    IP=192.168.104.10

  10. Mario Avatar
    Mario

    It s possible to connect witloof interface knx ip basic? If yes what the key? The port us normaly 3671

  11. The above is the IP and port of HomeServer from Gira. In HomeServer one can define a key like a password so not every app would be accepted to send commands in KNX (or receive commands from KNX).

    If you have a different router there is no need to specify the key. I never tested with other KNX-IP router except Gira HomeServer 3

  12. MARIO Avatar
    MARIO

    this is my config
    [MAP_TO_ZONE]
    6/2/1=PORTABLE

    [MAP_TO_COMMAND]
    6/2/1=MUTEUNMUTE

    [COMMANDS LIST – THIS SECTION IS ONLY INFORMATIVE]
    MUTEUNMUTE = KNX_1BIT_1=MUTE_0=UNMUTE
    SETPLAYMODE = KNX_4BIT_0_15 PLAY MODE: 0:NORMAL, 1:INTRO, 2:SHUFFLE, 3:RANDOM, 4:REPEAT_ONE, 5:REPEAT_ALL
    NEXTPREVIOUS= KNX_1BIT_1=NEXT_0=PREVIOUS
    PLAYSTOP = KNX_1BIT_1=PLAY_0=STOP
    TOGGLEMUTE = KNX_1BIT_1=TOGGLEMUTE
    VOLUMEX = KNX_8BIT_EIS6_0-100_MASTERVOLUME
    PAUSE = KNX_1BIT_1=PAUSE
    BALANCE = KNX_8BIT_EIS6_0-100: 0 IS MAX LEFT, 50 IS BALANCED, 100 IS MAX RIGHT

    [ZONE_LIST]
    PORTABLE=RINCON_000E58721DCC01400_MR
    CHAMBRE ISA=RINCON_000E5871262E01400_MR

    [HS]
    PORT=3671
    KEY=
    IP=192.168.0.170

    when i send 1 on gad 6/2/1 there sonos dont mute.

    it is possible to view a log

  13. Check the 22/10/2010 update at the end of the article. Install the application version of the software (Windows application setup kit link), there you have a GUI where you can see all telegrams received from KNX bus if they are truly routed to IP world.

    If there is no telegram in the list it means the telegrams are not routed to the app.

  14. MARIO Avatar
    MARIO

    i haved try and there are no telegram traced ? I try with 2 différent interface ip/KNX and thre are not telegram. y have probably a problem with firewal with my port knx (3671).

  15. Gira HomeServer has a setting at every group address definition to enable/disable it’s routing to the IP network. Maybe your router configuration should allow it too for all or for individual group addresses.

    Until you succeed to pass the telegrams there is no chance for the app to work…

  16. kjetil Avatar
    kjetil

    I am trying to make this software work with a Siemens N148/22 KNX/IP gateway, but there is no telegrams reaching the bus.
    Can the source be changed to make this work with other gateways than Gira Homeserver?

  17. Marc Avatar
    Marc

    Hi,

    I am using a Jung Facility Pilot at home and have a several Sonos Players that i want to control. Do you have any experience that this service will work with the Jung facility pilot? And if yes how to set it up? I think I understand the configuration of the service, and the configuration ini file but how do I connect it to KNX then?
    Sorry if this questions are stupid and already thanks for your help.

    Regards,
    Marc

  18. Hi, I am not sure if Jung Facility Pilot is similar to Gira Facility Server. But if you have an UPNP controller in the visualisation client I think you might be able to control any kind of media players in the network. However you need a panel to control it and this panel tends to move to the smartphone. In my case I finally decided it is much easier to use the rich experience of native Sonos controller on my iPhone.

Leave a Reply

Your email address will not be published. Required fields are marked *