Announcement

Collapse
No announcement yet.

Echo to Sonos Integration

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Echo to Sonos Integration

    I have a Sonos audio system installed that I have now integrated with my Homeseer ZS2 home controller. All of that works fine in that I can control the Sonos system (as well as my lights) through the Homeseer system on the PC. I have just now added an Amazon Echo to the mix. The Echo lets me control the lights through the Homeseer, but the Echo does not or can not see any of the five Sonos speakers that are available; therefore, the Echo can NOT control any of the Sonos Speakers. What else do I need to know, or do, in order to get my Echo to Sonos integration to work?

    #2
    Originally posted by JeffSDavis View Post
    I have a Sonos audio system installed that I have now integrated with my Homeseer ZS2 home controller. All of that works fine in that I can control the Sonos system (as well as my lights) through the Homeseer system on the PC. I have just now added an Amazon Echo to the mix. The Echo lets me control the lights through the Homeseer, but the Echo does not or can not see any of the five Sonos speakers that are available; therefore, the Echo can NOT control any of the Sonos Speakers. What else do I need to know, or do, in order to get my Echo to Sonos integration to work?
    This question is probably better posted on the Echo related threads. As far I can tell, if you use the "direct" way (ie you didn't create your own skills), you can only control lights and thermostats so most of the Sonos commands wouldn't fit there. Someone asked whether we could "fake" for example a volume control to be like a dim control and I'm not sure how HS3 really implements that. I think it is a setting somewhere but again, better asked on the Echo related threads.

    Dirk

    Comment


      #3
      I am controlling my Sonos through my Echo, by using Virtual Devices.
      Works just fine...

      Comment


        #4
        I control, on a limited basis, my Sonos system via Echo using Events. "Alexa, trigger play NPR" runs an event that plays NPR station on my Sonos speaker in Kitchen.

        tenholde
        tenholde

        Comment


          #5
          I added the ability to have Alexa/Echo control the volume of my wife's Sonos using a Virtual Device and a script. I'll try to provide all the "lessons learned" that I can remember. I'm using the HomeSeer Echo API, not the skills.

          First, as you may have read in other forums, the Amazon system severely limits the HomeSeer devices it "recognizes"; Alexa did not recognize any of the Sonos devices. So in many cases you'll need to create Virtual devices that Alexa (the Amazon software) will recognize. That pretty much means, from what I've experienced, devices that are straight on/off or look like a light dimmer. I created a virtual device named "Sonos Loudness" with Status text of: on, off and range of 1 to 99 (again, just like a light dimmer).

          Why "Sonos Loudness" instead of "Sonos Volume" as the name of the Virtual Device? Because no matter what I tried that had "volume" as part of the device name, Alexa would associate my voice command to its' own internal music player volume (it would also say if I tried to command a volume setting greater than 10, that the volume could only be adjusted between 0 and 10). With that figured out, the command I speak is "Alexa, set Sonos Volume to 40", or any other value between 0 and 100.

          The next thing is to tie the change in the value of the Virtual Device to the actual Sonos Volume. For this you need an Event and a script that is called by the Event.

          Click image for larger version

Name:	SetSonosVolume_Event.png
Views:	1
Size:	76.3 KB
ID:	1185179

          The Event looks for any change in the value of the "Sonos Volume" Virtual Device - if that change does it occur, then it runs the script 'SetSonosVolume.cs'. The script doesn't get passed any parameters - it just gets the current value of the Virtual Device and sets the REAL Sonos Volume to that value. Here's the script code, written in C#:

          Code:
          using System;
          using HomeSeerAPI;
          
          public object Main(object[] Parms)
          {
          	int exitCode = 0;
          	int newVolume = 0;
          	int devRef = 376;
          	
          	// This script does not use passed parameters - instead, it uses the value of a Virtual Status device named
          	// "Sonos Volume", which has Reference ID = 376.
          
          	newVolume = hs.DeviceValue(devRef);
          	
          	// Execute the HomeSeer CAPI commands to fetch the volume value and then set it to the parameter passed to the script.
          	HomeSeerAPI.CAPI.CAPIControl cc = hs.CAPIGetSingleControl(hs.GetDeviceRefByName("Sonos Beck's Volume"), true, "Volume (value)%", false, false);
          	cc.ControlValue = newVolume;
          	HomeSeerAPI.CAPI.CAPIControlResponse cr = hs.CAPIControlHandler(cc);
          		
          	// Wrap up -- Write to the log - that the Sonos had it's volume  set/changed.
          	hs.WriteLog("SetSonosVolume", "Set volume of Beck's Sonos to " + newVolume );
          	return exitCode;
          }
          For your use of the script, you'll need to replace the value of devRef with the ID of your Virtual Device, and replace "Sonos Beck's Volume" with the name of your Sonos. I hope this helps!

          Regards,
          BBB

          Comment


            #6
            Originally posted by MrMxyzptlk View Post
            I am controlling my Sonos through my Echo, by using Virtual Devices.
            Works just fine...
            I'm trying to do the same thing but struggling to get it working. Can you explain a bit more how you are setting this up and getting Echo to respond?

            Thanks

            Comment


              #7
              Originally posted by ideaguy View Post
              I'm trying to do the same thing but struggling to get it working. Can you explain a bit more how you are setting this up and getting Echo to respond?

              Thanks
              You can also "cheat" and use Spud's EasyTrigger plugin to do a "Set Device to another Device" action in an event.

              Z

              Comment


                #8
                vasrc - I'm a newbie. Can you explain how you set this up as an event that works with Echo?

                Comment


                  #9
                  Originally posted by ideaguy View Post
                  vasrc - I'm a newbie. Can you explain how you set this up as an event that works with Echo?
                  Which part, the virtual device part, the Event part or the EasyTrigger part?

                  For EasyTrigger you need to install the plugin (it's free for 30? days then you would need to purchase it). It's like the swiss army knife of Event actions

                  If the virtual device part:
                  Create a new device from the Home page (Green +)
                  Goto the Status Graphics tab and delete the two existing On/Off items
                  Create a new range and set it to 0 - 100
                  Set the Control Use: to "Dim"
                  The "Voice Command" should already be set for new devices.

                  Create a new Event
                  It will contain a simple Trigger of: IF "new virtual device name" had it's Value set or changed
                  and the Action:
                  EasyTrigger Set Device to another Device "new virtual device name" to "Sonos Volume name"

                  Then you let Echo discover the new device (Alexa discover new devices)

                  You should then be able to say:
                  Alexa, set "New device name" to X %

                  I did get Sonos Volume to work, but as BBB said, it's probably best to use something else as Echo does have some words it's partial to for itself.

                  There should be several more detailed explanations available about setting up devices and events. Look in the How-Tos section.

                  Z

                  Comment


                    #10
                    Very helpful. Thank you!

                    Comment

                    Working...
                    X