Trying to call Sonos action from within a script

Posted on
Fri Jan 22, 2021 10:38 am
pgershon offline
Posts: 509
Joined: Jul 10, 2004

Trying to call Sonos action from within a script

Not sure what I am doing wrong here. I am trying to call the action "SonosFavorites" from within a script of a different plugin I am writing. I can see that within the Sonos plugin, the call is made to:
Code: Select all
   def actionZP_SonosFavorites(self, pluginAction):
      return self.Sonos.actionDirect(pluginAction, "ZP_SonosFavorites")

So I am trying from my script:
Code: Select all
                  c=PA({'mode':"",'setting':setting})
                  sonosPlugin.executeAction("actionDirect", props={'pluginAction':c, 'action':"ZP_SiriusXM"})

I defined the class PA as the Sonos plugin did:
Code: Select all
class PA():
   def __init__(self, deviceId=None, props=None):
      self.deviceId = deviceId
      self.props = props

My script "sonosPlugin.executeAction " generates the error message:
TypeError: No registered converter was able to produce a C++ rvalue of type CCString from this Python object of type instance

I am not sure what I am doing wrong.

The script within the plugin runs without problem
Code: Select all
self.actionDirect (PA(dev.id, {"setting":setting}), "ZP_SiriusXM")


I believe my statement should be equivalent?

Posted on
Sat Jan 23, 2021 7:53 am
pgershon offline
Posts: 509
Joined: Jul 10, 2004

Re: Trying to call Sonos action from within a script

I got it figured out:

Code: Select all
         sonosPlugin = indigo.server.getPlugin("com.ssi.indigoplugin.Sonos")
         sonosProps = { 'mode':'Play Now','setting':'initial',            }
         sonosProps["setting"]=sonosDev.pluginProps["setting"+str(station)]
         sonosPlugin.executeAction("actionZP_SonosFavorites", deviceId=int(sonosDev.pluginProps["sonosID"]), props=sonosProps)

Needed to separate executeAction entries for deviceid and props, and then be are the props included all the properties the action addressed.

Posted on
Sat Jan 23, 2021 11:04 am
pgershon offline
Posts: 509
Joined: Jul 10, 2004

Re: Trying to call Sonos action from within a script

Another question...

The Sonos plugin creates as array of favorite stations using the below, where Sonos_Favorites is a global array within the plugin which contains various information on the stations on the Sonos device's favorites list.

Code: Select all
   def getZP_SonosFavorites(self, filter=""):
      array=[]
      for title in Sonos_Favorites:
         array.append((title[4], title[1]))
#         indigo.server.log(title[1]+";"+title[0]+";"+title[4])
      return array

I can select a favorite from this list for my own device using the devices.xml:

Code: Select all
         <Field id="setting1" type="menu">
            <Label>Sonos Favorite:</Label>
            <List class="com.ssi.indigoplugin.Sonos" method="getZP_SonosFavorites" dynamicReload="yes"/>
         </Field>

The list that gets displayed is title[1] from above, and the selection I make is title[4] (eg setting1 is set to a title[4] value). But I want to get the title[1] value as well (which is the station name, so I can display it on a keypad etc ). I am not sure ho to modify the list, but I thought I could find the corresponding value in the Sonos_Favorites array. But my plugin does not have this array.

I could call getZP_SonosFavorites from within my plugin, but I don't know how to do it. xyz= getZP_SonosFavorites() returns an error because getZP_SonosFavorites is in the Sonos plugin and not mine. But I cannot use sonosPlugin.executeAction("ZP_SonosFavorites") because ZP_SonosFavorites is not an action with a callback.

What am I missing, anyone?

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 8 guests