Page 1 of 1

Getting Songs plugin to execute actions from within Python

PostPosted: Sun Apr 23, 2017 1:14 pm
by pgershon
I have a plugin that run my Grand Concerto and I am trying to get the python code to communicate with the Sonos plugin. I can look at values within Sonos, but I am having trouble getting Sonos to perform actions. I tried two ways - the first fails, the second works but relies on an Action Group I wrote to perform:

Code: Select all
sqzPlugin = indigo.server.getPlugin("com.ssi.indigoplugin.Sonos")
sqzPlugin.executeAction("TogglePlay", deviceId="42384538")
and
Code: Select all
indigo.actionGroup.execute(1445798824)


42384538 is the ID of the Sonos device. 1445798824 is the ID of a Sonos Action Group that does Toggle Play. The action group works fine from the Indigo main interface, just not from within the Python script.

Error generated by first approach:

    NuVo Grand Concerto Error Error in plugin execution runConcurrentThread:

    Traceback (most recent call last):
    File "plugin.py", line 226, in runConcurrentThread
    File "plugin.py", line 266, in parseToServerLine
    File "plugin.py", line 363, in parseToServer
    ArgumentError: Python argument types in
    PluginInfo.executeAction(PluginInfo, str)
    did not match C++ signature:
    executeAction(CPlugin {lvalue}, CCString actionTypeId, unsigned long deviceId=0, boost::python::api::object props=None, bool waitUntilDone=True)

    NuVo Grand Concerto Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)


Any thoughts?

Re: Getting Songs plugin to execute actions from within Pyth

PostPosted: Sun Apr 23, 2017 1:41 pm
by FlyingDiver
Try this:
Code: Select all
sqzPlugin = indigo.server.getPlugin("com.ssi.indigoplugin.Sonos")
if sqzPlugin.isEnabled():
    sqzPlugin.executeAction("actionTogglePlay", deviceId="42384538")


Unless documented elsewhere by the plugin developer, you need to look at the Actions.xml file inside the plugin to determine the name of the action you're trying to invoke.

Re: Getting Songs plugin to execute actions from within Pyth

PostPosted: Tue May 02, 2017 3:46 pm
by pgershon
I needed to remove the quotes from the device id, then it worked. Thanks.