Forgetting an open window can become quite uncomfortable, especially in winter. We can remind ourselves if a window is open for too long with Delayed Notifications.
What we want to achieve:
We want to receive a notification when the bathroom room window is open for more than an hour.
We need three things to make this work.
- A Delayed Notification.
- A Shortcut to trigger and cancel the Notification.
- An Automation to trigger the Shortcut.
We’ll use a Delayed Notification, which we’ll schedule when the window is opened and cancel when it’s closed.
- Go to Notifications, add the new Delayed Notification and give it a title.
- Select ‘time-sensitive’ as the interruption level because we always want to get the Notification even if we’re in focus mode or something similar.
- Choose ‘Keep Latest Notification’ as behavior because we don’t need multiple Notifications to tell us the same thing.
- We don’t need any action for this. However, we can adjust the Snooze time. For example, I use 30 minutes to keep the window open a little longer and still get a reminder if I want.
- Enter 60 as ‘Delay in Minutes.’ That ensures that the Notification will arrive an hour after we schedule it.
- Finally, select the devices that should receive the Notification.
The URLs to schedule and cancel this Notification are at the end of the Notification settings. You can copy the URLs to your clipboard by tapping on them. You’ll need them in the Shortcut that we’ll create next.
At this point, we need to build a connection between HomeKit and Controllers Notification Server. That is possible with Apple’s Shortcuts app. If you need to get more familiar with Shortcuts, you can learn more about them here.
We’ll use the Shortcut to schedule and cancel the Notification. Our Automation will trigger it for every value change. In the Shortcut, we’ll determine if the window is open or closed and act accordingly.
- Open the Shortcuts app, switch to the Automation tab and tap the plus icon in the upper-right corner.
- Select ‘Create Home Automation.’ That will create an Automation in HomeKit, that we can customize in the next step.
- Select ‘A Sensor Detects Something’ as the event, select the window sensor, and tap next. We’re going to adjust the start event soon in Controller for HomeKit.
- Here you choose what the Automation will do. Scroll down to the bottom of the list and choose ‘Convert to Shortcut.’
- At this point, we have an HomeKit Automation that will trigger a Shortcut. In the Shortcut, delete the ‘Set Scenes and Accessories’ action. Then search for the ‘If’ action in the search bar on the bottom and add it.
- Tap on ‘Input’ in the ‘If’ action and select your window sensor.
- Tap on ‘Condition’ and select ‘is.’ If your sensor has multiple services, you may need to choose your service first.
- Tap on ‘Choose’ and select ‘Open.’
- Search for the ‘Get contents of URL’ action in the search bar on the bottom and add it.
- Repeat step 9, so you have two ‘Get content of URL’ actions.
- Make sure one is placed between ‘If’ and ‘Otherwise.’ The other needs to be between ‘Otherwise’ and ‘End If.’ You can move actions around while you’re touching and holding them.
- Open Controller and copy the schedule URL of our Notification (see here). Go back to the Shortcuts app and tap ‘URL’ in the first of both actions. Paste the copied URL here.
- Repeat step 12, but with the cancel URL, and paste it into the other action.
- Tap ‘Next.’
Finally, tap ‘Done’ and then close the Shortcuts app.
At last, we need to configure the Automation that will trigger the Shortcut. The previous step already created it, but we need to adjust it because the Shortcut app only supports a few possible Automation settings.
- Open Controller again, go to Automations, and open the new Automation. If you followed the steps above, the name should be the name of your window sensor plus ‘Closes.’
- Optionally, give the Automation a more meaningful name.
- Now, we’re going to change the start event. Tap the current start event, ‘Contact Sensor State is Closed.’
- Select ‘Each value change.’ That ensures that the Shortcut will always run when somebody opens or closes the window.
- Tap ‘Save.’
That’s it. HomeKit will now keep an eye on your window and let you know if you forget it. If you like this, look at our Advanced HomeKit Notifications Documentation. We have some other great examples there!