Knowledge of Shortcuts: Moderate
This example shows one way to create a new Calendar event from Indigo with included data. This kind of automation is probably most useful for tracking things that happen infrequently--you could easily overwhelm your calendar with something that happens multiple times per day. This is a bare minimum example that's meant to show the necessary pieces. It assumes that all the necessary pieces are set up on your Indigo server machine (access to Calendar, etc.)
You'll need three things at least:
- Some way to cause the Shortcut to run - in this case, an embedded script that's fired using an Indigo Action.
- An Apple Shortcut to process the incoming data and create the Calendar event.
- An Apple Calendar to add the data to - I'd recommend a separate calendar (I've uncreatively called mine "Indigo").
Code: Select all
import os
val = indigo.variables[123456].value # The value to pass. In this case, a variable value.
os.system(f'/usr/bin/shortcuts run "Post Event to Calendar" <<< \"{val}\"') # Will return 0 on success; 256 on error.
This example shows the event being added as an all day event; it could be modified to include a timestamp or time(s) to make the event more specific. You could also add more data to the payload to include things like location and notes (it would require passing the data in a recognizable format like JSON.).
A version of this example is also posted to the Apple Shortcuts Wiki