Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| indigo_2025.1_documentation:plugin_scripting_tutorial [2025/09/22 19:58] – created - external edit 127.0.0.1 | indigo_2025.1_documentation:plugin_scripting_tutorial [2025/10/22 15:27] (current) – [Execute Action Group 12345678:] jay | ||
|---|---|---|---|
| Line 154: | Line 154: | ||
| </ | </ | ||
| - | Custom Python classes that you create can implement the %%__str__(self)%% method. Take this simple example: | + | Custom Python classes that you create can implement the //'' |
| < | < | ||
| Line 192: | Line 192: | ||
| ===Execute Action Group 12345678: | ===Execute Action Group 12345678: | ||
| + | Execute an action group: | ||
| < | < | ||
| indigo.actionGroup.execute(12345678) | indigo.actionGroup.execute(12345678) | ||
| </ | </ | ||
| + | ===Execute Action Group 12345678 with extra event data:=== | ||
| + | Execute an action group, but pass through an arbitrary dictionary of data to actions that support using **event_data**: | ||
| + | < | ||
| + | extra_data = {" | ||
| + | indigo.actionGroup.execute(12345678, | ||
| + | </ | ||
| ==== Log Examples ==== | ==== Log Examples ==== | ||
| Line 249: | Line 256: | ||
| </ | </ | ||
| - | ===Get the folder containing a device=== | + | === Get the folder containing a device === |
| < | < | ||
| lamp = indigo.devices[" | lamp = indigo.devices[" | ||
| Line 260: | Line 267: | ||
| </ | </ | ||
| + | === Event Data Examples === | ||
| + | Webhook events pass data along the chain that can be easily accessed in embedded or linked scripts. The data is passed first to any // | ||
| + | |||
| + | < | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | A more robust event dictionary might look like this: | ||
| + | |||
| + | < | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Regardless of where the data came from (trigger, schedule, etc), the variable name will be //'' | ||
| + | |||
| + | < | ||
| + | # If you did a indigo.actionGroup.execute(12345) the source would be `python`. | ||
| + | # You don't need to import `event data`, it will be made available automatically. | ||
| + | if event_data[" | ||
| + | indigo.server.log(f" | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | All event_data payloads will be formatted as //''< | ||
| ==== Miscellaneous Examples ==== | ==== Miscellaneous Examples ==== | ||
| Line 283: | Line 332: | ||
| indigo.server.sendEmailTo(" | indigo.server.sendEmailTo(" | ||
| </ | </ | ||
| + | |||
| ===== Starting the host from an existing terminal window ===== | ===== Starting the host from an existing terminal window ===== | ||