Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume Control with Sonos #3

Open
andy-81 opened this issue Nov 29, 2015 · 24 comments
Open

Volume Control with Sonos #3

andy-81 opened this issue Nov 29, 2015 · 24 comments

Comments

@andy-81
Copy link

andy-81 commented Nov 29, 2015

Hi All,

First of all thanks for all the hard work everyone has put in with the homebridge server, Ive been using it on a RPi model B version 1 and after having some issues getting it up and running have now managed to get through all the issues I had making it stable but after switching to Jessie all is working well.

The issue I have at present is with the Sonos plugin. I can turn the speakers on and off without any issues however the volume I am unable to control with Siri. I believe the issue is somewhere in how it is registering the volume and as others are mentioning they have it working I am wondering what has gone wrong but I have reinstalled and cleared settings a number of times and it always comes back the same. If I use the MyTouchHome application I can indeed see the volume and it shows the volume correctly and allows me to adjust it within the app however it has N/A next to the volume control which is why I believe it has registered somewhere incorrectly.

Can anyone think of anything I have done wrong or any adjustments in the son files I may need to make? I took a quick look through and couldn't see anything obvious (I have a small amount of programming knowledge although it is very rusty as this was from when I was in school) Any help would be appreciated to work out why it is showing as N/A in the app and why Siri is unable to understand volume.

All I did for the install was npm install -g home bridge-sonos and then configured the Accessories section in my config file so not hacked around with the code as yet only had a look at the relevant files to see anything obvious. The latest install was a week ago now, I did try an npm update.

Thanks all and thanks for your help and special thanks to nfarina for starting up the project.

@davidgruhin
Copy link

I too am unable to control the volume with Siri, although I am able to adjust it in MyTouchHome, as well as turn the speakers on and off using Siri.

Please advise.

Thanks!

@hdoucet
Copy link

hdoucet commented Dec 21, 2015

Same problem .. i can change the volume via MyTouch App .. but not via Siri. Can somebody tell what SIRI words must be used to change the volume ?

@NovaGL
Copy link

NovaGL commented Dec 28, 2015

The reason it doesn't work is Siri doesn't understand the word "Volume"

It is a custom command for HomeKit, if this plugin was implemented differently you could say set brightness or hue or any other known command and it would change the volume

@farberm
Copy link

farberm commented Jan 2, 2016

NovaGL

Can you help implenmenting the sonos plugin to do volume?

@NovaGL
Copy link

NovaGL commented Jan 3, 2016

It's not possible Siri does not support volume, if you change the word to brightness (in the code) it will work.

Eg "Hey Siri, set Lounge Sonos Brightness to 50"

@farberm
Copy link

farberm commented Jan 3, 2016

I have tried that and it does not work.

On Jan 2, 2016, at 8:51 PM, NovaGL notifications@github.com wrote:

It's not possible Siri does not support volume, if you change the word to brightness it will work.

Eg "Hey Siri, set Lounge Sonos Brightness to 50"


Reply to this email directly or view it on GitHub #3 (comment).

@farberm
Copy link

farberm commented Jan 3, 2016

nfarina:

Can you update the code. I tried to do it locally and it did not work.

@NovaGL
Copy link

NovaGL commented Jan 3, 2016

Did you try replacing

.addCharacteristic(VolumeCharacteristic)

with

.addCharacteristic(new Characteristic.Brightness())

You can also use the word hue or saturation if you prefer.

@JBX77
Copy link

JBX77 commented Jan 6, 2016

You can create scenes with the Elgato Eve app to change the volume. I have scenes for 10, 20 and 30% which is enough for daily use.

@andy-81
Copy link
Author

andy-81 commented Jan 7, 2016

As per NovaGL's response changing the one line he mentioned will allow you to change the volume using brightness as well as ask what the brightness is to get the current volume of the speaker. It is on line 35 of the index.js file.

@JBX77
Copy link

JBX77 commented Jan 7, 2016

I can confirm NovaGL's solution works for the volume.
It now works with a spoken command like "Change Sonos Livingroom to 20%".

@hdoucet
Copy link

hdoucet commented Jan 8, 2016

So i tried changing line 35 from
addCharacteristic(VolumeCharacteristic)
to
.addCharacteristic(new Characteristic.Brightness())
But when i start homebridge i cannot run the program.
I get following output ...

"dgram.js:461
throw new Error('Not running'); // error message from dgram_legacy.js
^

Error: Not running
at Socket._healthCheck (dgram.js:461:11)
at Socket.close (dgram.js:354:8)
at SonosAccessory. (/usr/local/lib/node_modules/homebridge-sonos/index.js:70:23)
at /usr/local/lib/node_modules/homebridge-sonos/node_modules/sonos/lib/sonos.js:614:7
at Parser. (/usr/local/lib/node_modules/homebridge-sonos/node_modules/sonos/node_modules/xml2js/lib/xml2js.js:255:20)
at emitOne (events.js:77:13)
at Parser.emit (events.js:169:7)
at Object.saxParser.onclosetag (/usr/local/lib/node_modules/homebridge-sonos/node_modules/sonos/node_modules/xml2js/lib/xml2js.js:225:24)
at emit (/usr/local/lib/node_modules/homebridge-sonos/node_modules/sonos/node_modules/xml2js/node_modules/sax/lib/sax.js:615:33)
at emitNode (/usr/local/lib/node_modules/homebridge-sonos/node_modules/sonos/node_modules/xml2js/node_modules/sax/lib/sax.js:620:3"

Any explanation why it worked with @JBX77, @NovaGL, @andy-81 ?

@Nousemusic
Copy link

To control the volume with siri via brightness: In the Version v0.0.4 of the package, has the word "volume" be replaced to "brightness" every time it appears in the index.js?

@jkoehl
Copy link

jkoehl commented Jan 23, 2016

Just to add come more clarity and references to the above info provided...

This is from the HomeKit documentation about integrating with Siri:

(https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/HomeKitDeveloperGuide/AccessingServicesandTheirCharacteristics/AccessingServicesandTheirCharacteristics.html#//apple_ref/doc/uid/TP40015050-CH6-SW1)

"Apple-defined service types that are recognized by Siri include:

Door locks
Fans
Garage door openers
Lights
Outlets
Thermostats
"

What this means is the apps like Eve can see the custom characteristic that this module adds (the "Volume" characteristic). The Eve app just lists all of the characteristics that are set on the service including custom ones.

But Siri doesn't know about it since there isn't a "Speaker" service with a "Volume" characteristic that she knows about.

@NovaGL
Copy link

NovaGL commented Jan 24, 2016

Siri doesn't care as much about the service, eg I combined a door with a motion sensor, it cares about the characteristic. Even though we named it Volume, all Siri sees is Custom.

It's up to Hardware vendors to push the Volume Characteristic via the MFI program.

I suggest people just create scenes like suggested above. Call it "Volume 50%" and then set the speaker volume to 50% in the setup. That way when you say "Volume 50%" Siri will understand it.

@mattnewham
Copy link

This should be added to the Readme, or at least the Wiki

@keith
Copy link

keith commented Jul 24, 2016

Here's a patch that you can apply to the current version of homebridge-sonos in order to get volume working:

diff --git i/index.js w/index.js
index 40ce2b3..fcadc75 100644
--- i/index.js
+++ w/index.js
@@ -144,7 +144,7 @@ function SonosAccessory(log, config) {

   if (!this.room) throw new Error("You must provide a config value for 'room'.");

-  this.service = new Service.Switch(this.name);
+  this.service = new Service.Lightbulb(this.name);

   this.service
     .getCharacteristic(Characteristic.On)
@@ -152,7 +152,7 @@ function SonosAccessory(log, config) {
     .on('set', this.setOn.bind(this));

   this.service
-    .addCharacteristic(VolumeCharacteristic)
+    .addCharacteristic(Characteristic.Brightness)
     .on('get', this.getVolume.bind(this))
     .on('set', this.setVolume.bind(this));

This makes HomeKit think it's a lightbulb so the Siri commands are a little strange but it seems to work as expected.

@farberm
Copy link

farberm commented Jul 24, 2016

keith:
Could you be more specific as to where to apply the above patch. Should I edit a specific file and which file where in the file or di I need to add a file etc.
Thx

@keith
Copy link

keith commented Jul 24, 2016

If you use git apply this will "just work"

@farberm
Copy link

farberm commented Jul 24, 2016

Excuse my ignorance but is that the complete terminal command. I am working on OSX?

I installed using the sudo npm install -g homebridge-sonos

@aebgit
Copy link

aebgit commented Sep 28, 2016

@farberm just edit the file index.js with your favourite editor.

Instead of using service Lightbulb I've got great results with service Fan. I have no fans in my house, so there is no conflict with dimmable lights in the same room when using Siri. I just renamed my Sonos speakers within the iOS 10 Home-App (from Apple) to "Musik" and moved the speakers into their rooms. Now I can control the volume via Siri with "Stelle Musik im Wohnzimmer auf 15%" ("Set music in the livingroom to 15%") .

//this.service = new Service.Switch(this.name);
this.service = new Service.Fan(this.name);

this.service
//    .addCharacteristic(VolumeCharacteristic)
    .addCharacteristic(new Characteristic.RotationSpeed())
    .on('get',  @this.getVome.bind(this))
    .on('set', this.setVolume.bind(this));

Apple lists all service types and their characteristics here: https://developer.apple.com/reference/homekit/1627282-homekit_constants

EDIT:
I figured out later that it doesn't matter on which Sonos player I change the volume. Homebridge-Sonos will always only the volume ONLY for one player (I guess its the current 'master').

@elmstreet
Copy link

I tried NovaGL trick. It works for on of my Sonos Speakers. The Play:3. It doesn't work for the Play:5 as far as Voice Command. When using in Home app, I can control the volume with a slider. I don't understand why Siri can't work with my Play:5...

@raphus
Copy link

raphus commented Jan 15, 2017

thanks so much for the volume 'mod' ! worked like a charm

@markoox
Copy link

markoox commented Apr 21, 2017

He, have problems with the Volume control! Can everyone help me.

I use the eve app, and I see the Sons as a switch, I can change the volume with the app, but not with Siri. I use Siri in German.

Like: Setze Box Küche auf 50%. But Siri Don´t know what I mean.

The rest of the plugin works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests