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 could do something similar with Automation, but that has a drawback. What if a friend is waiting for us, and we don’t want them to sit in the dark? Sometimes we leave our homes and don’t want the lights off. A Notification lets us decide what we want.

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.

  1. Create a new Workflow, give it a name and save it.
  2. Open the Workflow and add a ‘Write Value’ step.
  3. Select the ‘many’ mode because we want to control multiple devices simultaneously.
  4. Choose ‘Lightbulb’ as the service type
  5. Choose ‘Power State’ as the characteristic.
  6. 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.

  1. Go to Notifications, add the new Instant Notification and give it a title.
  2. 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.
  3. Choose ‘Keep Latest Notification’ as behavior because we don’t need multiple Notifications to turn off the light.
  4. Add an ‘Execute Workflow’ action and select the Workflow we just created. If you used a Scene, use an ‘Execute Scene’ action instead.
  5. 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.

  1. Open the Shortcuts app, switch to the Automation tab and tap the plus icon in the upper-right corner.
  2. Select ‘Create Home Automation. That will create an Automation in HomeKit, that we can customize in the next step.
  3. Select ‘People Leave’ as the event and tap next. We’re going to change the start event soon in Controller for HomeKit.
  4. Here you choose what the Automation will do. Scroll down to the bottom of the list and choose ‘Convert to Shortcut.’
  5. 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.
  6. 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.

  1. 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.’
  2. Give the Automation a more meaningful name.
  3. 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.’
  4. 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.
  5. 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.
  6. 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!)
  7. 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!