nfarina / homebridge-sonos

Sonos plugin for homebridge: https://github.com/nfarina/homebridge
155 stars 52 forks source link

Doesnt work with Sonos Playbar? #2

Closed amitgandhinz closed 7 years ago

amitgandhinz commented 8 years ago

I havent been able to get this working with my Sonos Playbar.

I have set up the Sonos in the "accessories" section of the config.json, with the "room" value matching the Room Name in the Sonos iOS app.

"accessories": [ { "accessory": "Sonos", "room": "Family Room", "name": "TV Speakers" } ]

Here are my logs:

Loading 1 accessories... [TV Speakers] Initializing Sonos accessory...

Sat, 28 Nov 2015 18:52:05 GMT EventedHTTPServer [::ffff:192.168.1.69] HTTP request: /characteristis Sat, 28 Nov 2015 18:52:05 GMT HAPServer [b8:27:eb:44:f8:79] HAP Request: PUT /characteristics Sat, 28 Nov 2015 18:52:05 GMT Accessory [PiBridge] Processing characteristic set: {"characteristic":[{"aid":2,"iid":9,"value":false}]} Sat, 28 Nov 2015 18:52:05 GMT Accessory [PiBridge] Setting Characteristic "On" to value false [TV Speakers] Ignoring request; Sonos device has not yet been discovered. Sat, 28 Nov 2015 18:52:05 GMT Accessory [PiBridge] Error setting Characteristic "On" to value fals: Sonos has not been discovered yet. Sat, 28 Nov 2015 18:52:05 GMT HAPServer [b8:27:eb:44:f8:79] Error setting characteristics: Sonos hs not been discovered yet.

fwboettger commented 8 years ago

@amitgandhinz - do you have a Sonos Sub as well (paired with the playbar) or do you maybe even also pair another set of speakers (play1, play3 or play5's) with the playbar to a 5.1 surround home cinema setup?

amitgandhinz commented 8 years ago

@fwboettger Thanks for getting back to me. The only Sonos device i have is the Playbar. No sub or play1/3/5's.

It randomly started finding the device the other day (ie no longer errors). However, the controls dont turn the speaker on/off. Doing so would be a nice way to mute the TV via Siri Homekit.

Thanks

fwboettger commented 8 years ago

@amitgandhinz - and the name of the room / the zone you've given in your Sonos smartphone/tablet/desktop app is exactly "Family Room"?

chadyj commented 8 years ago

I have a similar issue. In my case I successfully setup Homebridge and homebridge-sonos and can start/stop 2 different Sonos as well as control with Siri. But at some point it stops working and I see errors like:

Thu, 21 Jan 2016 01:03:49 GMT EventedHTTPServer [::ffff:10.0.1.11] HTTP request: /characteristics
Thu, 21 Jan 2016 01:03:49 GMT HAPServer [CC:22:3D:E3:CE:30] HAP Request: PUT /characteristics
Thu, 21 Jan 2016 01:03:49 GMT Accessory [Homebridge] Processing characteristic set: [{"aid":2,"iid":9,"value":true}]
Thu, 21 Jan 2016 01:03:49 GMT Accessory [Homebridge] Setting Characteristic "On" to value true
[Kitchen Sonos] Ignoring request; Sonos device has not yet been discovered.
Thu, 21 Jan 2016 01:03:49 GMT Accessory [Homebridge] Error setting Characteristic "On" to value true:  Sonos has not been discovered yet.
Thu, 21 Jan 2016 01:03:49 GMT EventedHTTPServer [::ffff:10.0.1.11] HTTP Repsonse is finished

FWIW this is running on a Raspberry Pi. Rebooting doesn't fix the problem. However I can get things working again if I delete the homebridge/persist/ folder.

Config file is

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:30",
        "port": 51826,
        "pin": "031-45-154"
    },

    "description": "This is an example configuration file with one fake accessory and one fake platform. You can use this as a template for creating your own configuration file containing devices you actually own.",

    "accessories": [
   {
     "accessory": "Sonos",
     "name": "Kitchen Sonos",
     "room": "Kitchen"
   },
   {
     "accessory": "Sonos",
     "name": "Living Room Sonos",
     "room": "Living Room"
   }
 ]
}
fwboettger commented 8 years ago

@chadyj - did you change the "grouping" of your devices (your rooms) via the Sonos Desktop/Smartphone/Tablet app (after you started homebridge)? Would be good to know which devices you have in which room, and if there are any paired/grouped ones...

chadyj commented 8 years ago

@fwboettger Didn't touch the groupings. None are paired/grouped.

fwboettger commented 8 years ago

@chadyj - sorry, then i don't have an idea i'm afraid, sorry to not being able to help....

rudders commented 8 years ago

I have a similar problem - Sonos Playbar and a Play:3 and I get errors connecting to one or the other - I'll investigate and get back to this thread.

amitgandhinz commented 7 years ago

So i finally found time to dig back into the sonos playbar integration with this plugin.

It looks like a lot of the updates this year fixed my detection issue - yay =)

However, the getCurrentState == 'playing' and this.device.play and this.device.stop do not work for the Sonos Playbar.

I have made a fix for this locally, where instead of doing the current actions in the code, flipping the speaker switch off will instead call setMuted(true) and switching it on will setMuted(false). Getting the current state will use getMuted().

I will need to investigate how I can override these in the main branch only if the device type is a Playbar, so it doesnt interfere with Sonos Play 1/3/5 devices.

See https://github.com/nfarina/homebridge-sonos/pull/46 for work on this.

amitgandhinz commented 7 years ago

This is now resolved in #46

amitgandhinz commented 7 years ago

Also note I just discovered why play/stop wasnt working on the playbar.

Those endpoints dont work when the Playbar is using the TV Audio In line. If the playbar is put into music mode via the Sonos App, then the play/stop commands via homebridge appear to work. The trick is now to find a way to programmatically switch the audio source for the playbar.

I am tracking the issue for switching the inputs here - https://github.com/bencevans/node-sonos/issues/148