scripting - DaveL17/matplotlib GitHub Wiki
The bundle identifier for the Matplotlib plugin is:
com.fogbert.indigoplugin.matplotlib
Redraw One Chart Action
Redraw All Charts Action
Apply Theme Action
Experimental Matplotlib Plugin API
You can invoke the Indigo Action item Redraw One Chart through a simple Python script:
plugin=indigo.server.getPlugin("com.fogbert.indigoplugin.matplotlib")
plugin.executeAction("refreshAChartAction", 12345678)
where
"refreshAChartAction" (action ID - str - required)
12345678 (Indigo Device ID - int - required)
The "Redraw One Chart" action does not require any other props, and (if provided) will either be ignored or Indigo will throw an error.
If you receive a ValueError
, it is likely due to an invalid device ID. If you receive a InvalidParameter
error or an
ArgumentError
error, it is likely because you did not include a valid device ID (Indigo does not accept device names.)
You can invoke the Indigo Action item Redraw All Charts through a simple Python script:
plugin=indigo.server.getPlugin("com.fogbert.indigoplugin.matplotlib")
plugin.executeAction("action_refresh_the_charts")
This action does not require any other arguments.
You can invoke the Indigo Action item Apply Theme through a simple Python script:
plugin=indigo.server.getPlugin("com.fogbert.indigoplugin.matplotlib")
plugin.executeAction("themeApplyAction", 0, {'targetTheme': 'YOUR THEME NAME HERE'})
"refreshAChartAction" (action ID - str - required)
0 (Device ID - int - required)
{'targetTheme': theme name
} (props - dict - required)
The theme name must be precisely the same as it appears in Theme Manager. If the included theme name does not exist, you will receive a warning message to the Indigo Events log.
If you receive a InvalidParameter
error or an ArgumentError
error, check your call to executeAction()
to ensure
your parameters are correct and in the proper order.
The plugin now sports an experimental API that will be expanded over time (and become less experimental over time, too). This can be used by scripters to send data to generate charts. The following is a rudimentary example. All payload elements are required; however, you are not required to specify chart properties through a kwargs element. If you choose not to specify any kwarg properties, you must still send an empty dictionary. One last note, the format of the elements is important. The X and Y values must be presented as lists. The kwargs argument must be presented as a valid dictionary (as does the entire payload). The path argument is the full path where you would like the image to be saved.
matplotlibPlugin = indigo.server.getPlugin("com.fogbert.indigoplugin.matplotlib")
payload = {'x_values': [1, 2, 3],
'y_values': [2, 4, 7],
'kwargs': {'linestyle': 'dashed',
'color': 'b',
'marker': 'd',
'markerfacecolor': 'r'},
'path': '/Library/Application Support/Perceptive Automation/Indigo 7/IndigoWebServer/images/controls/static/',
'filename': 'chart_filename1.png'
}
try:
result = matplotlibPlugin.executeAction('refreshTheChartsAPI', deviceId=0, waitUntilDone=True, props=payload)
if result is not None:
indigo.server.log(result['message'])
except Exception as err:
indigo.server.log(u"Exception occurred: {0}".format(err))
The return is a dictionary that will contain information about the success/failure of the API call. Presently, there are two items in the return: 'success' and 'message'.
success (bool)
can be used to detect whether the call to the plugin was a success.
message (unicode string)
will be either 'Success' or traceback information.
For help in interacting with Matplotlib directly, try the matplotlib documentation.
Note
Earlier versions of the plugin used the copy of Matplotlib installed in the base Apple Python install. These tended to be several versions behind so there might be things in the current version of the matplotlib docs unavailable through the plugin. Newer versions of Indigo now ship with Matplotlib and the plugin will typically be updated to always work with the latest shipping version of Indigo (which may or may not work with prior Indigo versions).