One of my favorite uses of Advanced HomeKit Notifications is a reminder to turn off my lights if I forget them when I leave home. Especially with the rising energy prices, this is a great way to save a bit of money.
What we want to achieve:
When the last person leaves home, and any light is still on, we want to get a notification that lets us turn it off.
We need four things to make this work.
- A Workflow to turn off all lights. You can use a Scene instead if you like.
- An Instant Notification that allows us to execute the Workflow.
- A Shortcut to trigger the Notification.
- An Automation to trigger the Shortcut.
The Workflow
A Workflow is perfect for this task because we can turn off all lights without manually selecting each lamp.
- Create a new Workflow, give it a name and save it.
- Open the Workflow and add a 'Write Value' step.
- Select the 'many' mode because we want to control multiple devices simultaneously.
- Choose 'Lightbulb' as the service type
- Choose 'Power State' as the characteristic.
- Set the 'Value' to off.
There is a minor bug that we have to work around here. (We'll fix that soon!) To set the value to 'off,' we need to select 'Value' and then turn the toggle on and off again. So now it should say 'off' next to 'Value.'
Instead of a Workflow, you could create a Scene to turn off the lights. That is easier if you only want to turn off some lights or if you want to reuse that Scene in an Automation.
The Notification
We'll use a simple Instant Notification that we'll receive as soon as the Automation is triggered.
- Go to Notifications, add the new Instant 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 turn off the light.
- Add an 'Execute Workflow' action and select the Workflow we just created. If you used a Scene, use an 'Execute Scene' action instead.
- Finally, select the devices that should receive the Notification. You probably want to choose your iPhone because you'll have that with you when you leave.
You can find the URL that will trigger this Notification at the end of the Notification settings. Copy it to your clipboard by tapping it. You'll need that URL in the Shortcut that we'll create next.
The Shortcut
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.
- 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 'People Leave' as the event and tap next. We're going to change 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 'Get Contents of URL' action in the search bar on the bottom and add it.
- Paste the URL you copied from our Notification in the URL field and tap next.
When you tap 'Test this Automation,' you should receive the Notification. Finally, tap 'Done' and then close the Shortcuts app.
The Automation
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, it should be called 'When Anyone Leaves Home.'
- Give the Automation a more meaningful name.
- Now, we're going to change the start event. Tap the current start event, 'Somebody Leaves Home,' select 'Last Person Leaves Home' instead, and tap 'Save.'
- Now you'll always get a message if the last person leaves your home. However, that could get annoying quickly, so we're going to add conditions now. Tap 'AND the following conditions are met' and choose Accessory.
- Navigate to the first of your lights and select its Power State. Use 'equal to' as the comparison operator, choose 'On' as the value and save.
- Repeat the last step until you have added all your lights as conditions. (I know that's tedious. We'll make it easier in the future!)
- When you add multiple conditions, switch from 'All' to 'Any' so your Automation will run if any condition is true.
Wrap Up
That's it. HomeKit will now keep an eye on your lights and let you know if you forget them. If you like this, look at our Advanced HomeKit Notifications Documentation. We have some other great examples there!