Announcement

Collapse
No announcement yet.

CAPI on Linux Sonos toggle Mute

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

  • CAPI on Linux Sonos toggle Mute

    Does anyone know how to toggle the MUTE on Sonos I assume you need to use CAPI?

    I tried copying and modifying the CAPI for the volume that works but cant seem to make it work.

    Here is the code I tried:
    Code:
    Sub Main(ByVal str0 As String)
    
    Dim str as string
    Dim ref as string
    Dim cc As HomeSeerAPI.CAPI.CAPIControl
    Dim cr As HomeSeerAPI.CAPI.CAPIControlResponse
    
    ref = hs.GetDeviceRefByName("Mark Mute")
    str = hs.DeviceValue(ref)
    
    hs.WriteLog("Info","The mute is set to: " & str)
    
            
    cc = hs.CAPIGetSingleControl(ref, True, "Muted", False, False)
    
    if str = 1001  then
    hs.WriteLog("Info","is mute")
    cc.ControlValue = 1000 
     else
    hs.WriteLog("Info","not mute" )
     cc.ControlValue = 1001
     end if
    
    cr = hs.CAPIControlHandler(cc)
    str = hs.DeviceValue(ref)
    
    hs.WriteLog("Info","mute: " & str)
    End Sub

  • #2
    My SONOS devices already have a toggle option so you shouldn't need to do anything complex. I've even managed to get it down to a single line.

    Code:
    Sub Main(ByVal Parms As Object)
    
    hs.CAPIControlHandler(hs.CAPIGetSingleControl(62, True, "Toggle", False, False))
    
    End Sub
    You need to replace 62 with your SONOS mute device.
    My Plugins:

    Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
    Yeelight 3P | Nanoleaf 3P

    Comment


    • #3
      Originally posted by mrhappy View Post
      My SONOS devices already have a toggle option so you shouldn't need to do anything complex. I've even managed to get it down to a single line.

      Code:
      Sub Main(ByVal Parms As Object)
      
      hs.CAPIControlHandler(hs.CAPIGetSingleControl(62, True, "Toggle", False, False))
      
      End Sub
      You need to replace 62 with your SONOS mute device.
      Perfect works great! Thank you

      Comment

      Working...
      X