Arguments to Action callBackMethods

Posted on
Fri Jul 15, 2016 11:54 am
FlyingDiver offline
User avatar
Posts: 7184
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Arguments to Action callBackMethods

In the wiki (http://wiki.indigodomo.com/doku.php?id= ... actionsxml), it doesn't specifically document the arguments to action callBackMethods, but the example only shows two:

Code: Select all
def writeToLog(self, action):
    # call for variable substitution on the message field they entered
    theMessage = self.substitute(action.props.get("message", ""))
    # set the type for the message if they configured one
    theType = action.props.get("type")
    # debugging - show the message if debugging is enabled
    self.debugLog(u"Write to log: " + theMessage)
    # if they entered a type, log the message with it, otherwise log the message without a type
    if theType:
        indigo.server.log(theMessage,type=theType)
    else:
        indigo.server.log(theMessage)


However, I've seen an additional argument in a number of plugins, including the "Example Device - Factory" one:

Code: Select all
   ########################################
   # Custom Plugin Action callbacks (defined in Actions.xml)
   ######################
   def setBacklightBrightness(self, pluginAction, dev):
      try:
         newBrightness = int(pluginAction.props.get(u"brightness", 100))
      except ValueError:
         # The int() cast above might fail if the user didn't enter a number:
         indigo.server.log(u"set backlight brightness action to device \"%s\" -- invalid brightness value" % (dev.name,), isError=True)
         return



If three is correct, the Wiki should be updated and the method signature explicitly documented.

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

Posted on
Fri Jul 15, 2016 12:22 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Arguments to Action callBackMethods

I believe they are both correct. It can take two or three. Some actions specify a device, others do not. If your action does then include the 3rd parameter. We will get the documentation updated.

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests