Action Group Callback Help

Posted on
Sat Aug 19, 2023 7:37 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Action Group Callback Help

What information is sent back to the callback method ? The documentation can use some expaning and I've seen lots of different ways of implementing actions.

What I want to do is very basic:

1) Choose a Device
2) Choose a command

In plugin.py :

1) Identify the deviceId
2) Know what command was chosen

I know this involves the Actions.xml and the plugin.py. The documentation says that the device list is done by indigo. So if I use ConfigUI in Actions.xml to define a dropdown of commands (let's use MUTE as an example) how do I read that in plugin.py? For this use case, let's say my callback method id="sendCommand"

Posted on
Sat Aug 19, 2023 8:44 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Action Group Callback Help

Honestly, probably easier for you to just read the source code of almost any plugin that supports actions.

Basically, the valuesDict passed to the method named in the callback specified in the Actions.xml will have entries for any parameters specified in the action. The ID of the device is passed as one of the parameters.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Aug 20, 2023 8:44 am
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Action Group Callback Help

ok I dug around a little and figured it out. Here's what I was looking for , thanks.

Code: Select all
def sendCommand(self, pluginAction, device, callerWaitingForResult):
      self.logger.debug(f"When creating the Action, here's the device {device.name}")      
      match pluginAction.props["commandCode"]:
         case 'mute':
            success = self._mute(device)

         case "volume_up":
            success = self._volumeUp(device)

         case "volume_down":
            success = self._volumeDown(device)

      return

Posted on
Sun Aug 20, 2023 11:16 am
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Action Group Callback Help

ryanbuckner wrote:
The documentation can use some expaning and I've seen lots of different ways of implementing actions.


Thanks for the feedback; I'll take a look at what's there and see if I can add some more detail.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: brettlid and 8 guests