- 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.