| Both sides previous revision Previous revision | |
| indigo_2023.2_documentation:overview [2025/10/21 21:50] – [Insert Event Data into Variable] davel17 | indigo_2023.2_documentation:overview [2025/10/21 22:04] (current) – [Insert Event Data into Variable] davel17 |
|---|
| Click the ''**Edit Action Settings...**'' button and it will open a dialog (shown above). Here you will select the variable and, optionally, the format string as defined in the [[http://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior|Python datetime string formatting]] documentation (see the chart at the bottom for format specifiers). The format in the **''Format string''** field is the default format. | Click the ''**Edit Action Settings...**'' button and it will open a dialog (shown above). Here you will select the variable and, optionally, the format string as defined in the [[http://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior|Python datetime string formatting]] documentation (see the chart at the bottom for format specifiers). The format in the **''Format string''** field is the default format. |
| |
| === Insert Event Data into Variable === | |
| {{:indigo_2023.2_documentation:insert_event_data_into_variable.png?600|}} | |
| |
| Click the ''**Edit Action Settings...**'' button and it will open a dialog (shown above). Here you will select the variable and, optionally, the ''**Path specifier**'' if you want to access specific parts of the event data. | |
| |
| Path specifiers use a specific syntax and require knowledge of the event data you'll be receiving from the event. For example, given this Indigo event data: | |
| <code> | |
| { | |
| "foo": 1234567890, | |
| "bar": "Baz", | |
| "data": ["Thing 1", "Thing 2"], # a list | |
| "more_data": {'a': 1, 'b': 2}, # a dictionary | |
| "timestamp": "2025-08-07T14:32:21", | |
| } | |
| </code> | |
| |
| You could use path specifiers like these to have the associated data inserted into the variable you chose (leave off the quotes): | |
| |
| <code> | |
| "source" equals "server" | |
| "data" equals ["Thing 1", "Thing 2"] | |
| "more_data['b'] equals {'a': 1, 'b': 2} | |
| </code> | |
| |
| If you want to go deeper into the payload, the path specifiers can be chained together like this: | |
| |
| <code> | |
| { | |
| "foo": 1234567890, | |
| "bar": "Baz", | |
| "data": [ | |
| "Thing 1", | |
| [ | |
| "Thing A", | |
| "Thing B", | |
| "Thing C" | |
| ] | |
| ], | |
| "more_data": { | |
| "a": 1, | |
| "b": 2, | |
| "c": [ | |
| 1, | |
| 2, | |
| 3, | |
| 4, | |
| 5 | |
| ] | |
| }, | |
| "timestamp": "2025-08-07T14:32:21" | |
| } | |
| </code> | |
| |
| You can go deeper like this (again, leave off the quotes): | |
| <code> | |
| "data[0]" equals "Thing 1" # The index of the list element, the index starts at zero | |
| "data[1][2]" equals "Thing C" # The second element (index 1) of "data" is a list and the third element (index 2) of that list is "Thing C" | |
| "more_data.a" equals 1 # The value of key "a" is 1 | |
| "more_data.c[3] equals 4 # The value of key "c" is a list and the fourth element (index 3) of that list is 4 | |
| </code> | |
| You can chain these path specifiers as needed, such as //''some_json[3].a.foo[9]''// | |
| === Toggle Variable === | === Toggle Variable === |
| {{toggle_variable_action.png?nolink|Toggle Variable Action Image}} | {{toggle_variable_action.png?nolink|Toggle Variable Action Image}} |