Schedule and Cancel Notifications with the API
If you want notifications when a door or a window has been left open for a period of time, or to learn how to use the Pushcut API then this guide is for you!
Step 1: Create a new Pushcut notification
Add a new notification in the Pushcut app.
Set a name and enter a title and a message.
Step 2: Create an API Key
In the app under the Account tab, scroll to Integrations and tap Add API Key. Set the name to HomeKit and then tap Generate.
Step 3: Create the first HomeKit automation
- In HomeKit use the
+
icon to create a new automation. - Set the trigger to when your door opens.
- Select Convert to Shortcut instead of a scene (under Advanced at the bottom).
- Delete the Set Scenes and Accessories action.
- Add the URL action and paste in the webhook URL of your notification (from Step 1).
- Add the Get Contents of URL action and make sure the URL parameter is set.
- Tap on the
>
to expand the Get Contents of URL action, and change the method fromGET
toPOST
.- Add a new field: set the type to Text, the key to
identifier
and the value todoor_open
. - Add another new field: set the type to Text, the key to
delay
and the value to10m
.
- Add a new field: set the type to Text, the key to
- Tap Next and Done.
Step 4: Create the second HomeKit automation
- In HomeKit use the
+
icon to create a new automation. - Set the trigger to when your door closes.
- Select Convert to Shortcut instead of a scene (under Advanced at the bottom).
- Delete the Set Scenes and Accessories action.
- Add the URL action and paste in
https://api.pushcut.io/v1/submittedNotifications/door_open
. (Thedoor_open
part at the end is the identifier you set earlier). - Add the Get Contents of URL action and make sure the URL parameter is set.
- Tap on the
>
to expand the Get Contents of URL action, and change the method fromGET
toDELETE
.- Add a new header: set the key to
API-Key
and the value to the API Key from Step 2.
- Add a new header: set the key to
Step 5: Relax and enjoy!
That's it, you are all set! Now whenever your door opens a new notification will be scheduled for in 10 minutes time. If your door closes before the 10 minutes are up it will be cancelled, but otherwise you'll be notified! And the best part: when the door is then closed the notification will disappear.
You could also use this to schedule a server action (using the same delay
parameter), and send yourself a notification allowing you to cancel it.