Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
indigo_2025.1_documentation:plugin_scripting_tutorial [2025/10/21 20:32] – [Path Strings] davel17indigo_2025.1_documentation:plugin_scripting_tutorial [2025/10/22 15:27] (current) – [Execute Action Group 12345678:] jay
Line 154: Line 154:
 </code> </code>
  
-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 //''__str__(self)''// method. Take this simple example:
  
 <code> <code>
Line 192: Line 192:
  
 ===Execute Action Group 12345678:=== ===Execute Action Group 12345678:===
 +Execute an action group:
 <code> <code>
 indigo.actionGroup.execute(12345678) indigo.actionGroup.execute(12345678)
 </code> </code>
 +===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**:
 +<code>
 +extra_data = {"a": 1, "b": ["c", 2, 3]}
 +indigo.actionGroup.execute(12345678, event_data=extra_data)
 +</code>
  
 ==== Log Examples ==== ==== Log Examples ====
Line 249: Line 256:
 </code> </code>
  
-===Get the folder containing a device===+=== Get the folder containing a device ===
 <code> <code>
 lamp = indigo.devices["office desk lamp"] lamp = indigo.devices["office desk lamp"]
Line 260: Line 267:
 </code> </code>
  
 +=== 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 //**conditional scripts**//. The event data can have many forms, but certain data will be passed regardless of the source of the call. By default, every event dictionary will contain the following:
 +
 +<code>
 +{
 +    "event-indigo-id": 1214985350,  # the ID of the trigger, schedule, action group, etc
 +    "event-type": "Trigger",  # the event type - trigger, schedule, action group, etc.
 +    "source": "server",  # the source of the event (see description below)
 +    "timestamp": "2025-08-07T14:32:21",  # ISO formatted datetime string
 +}
 +</code>
 +
 +A more robust event dictionary might look like this:
 +
 +<code>
 +{
 +     "data": (dict)
 +     "event-indigo-id": 1234567890 (integer)
 +     "event-plugin-event-id": simpleWebhook (string)
 +     "event-plugin-id": com.indigodomo.webserver (string)
 +     "event-plugin-name": Web Server (string)
 +     "event-type": PluginEventTrigger (string)
 +     "http-method": GET (string)
 +     "request-url": https://localhost:8176/webhook/8143484549824dbba1286a873daa3cea (string)
 +     "source": python (string)
 +     "status-code": 200 (integer)
 +     "timestamp": 2025-10-21T21:20:50 (string)
 +     "webhook-id": 8143484549824dbba1286a873daa3cea (string)
 +}
 +</code>
 +
 +Regardless of where the data came from (trigger, schedule, etc), the variable name will be //''event_data''//. The data can be accessed like this:
 +
 +<code>
 +# 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["source"] == "python":
 +    indigo.server.log(f"{event_data['timestamp']}" # or whatever
 +    ...
 +</code>
 +
 +All event_data payloads will be formatted as //''<class 'indigo.Dict'>''//.
 ==== Miscellaneous Examples ==== ==== Miscellaneous Examples ====
  
  • /www/perceptive/wiki/data/attic/indigo_2025.1_documentation/plugin_scripting_tutorial.1761078749.txt.gz
  • Last modified: 2025/10/21 20:32
  • by davel17