In this example, we want to monitor the temperature in a greenhouse. We want a notification to warn us if it gets too low or too high. Additionally, the Notification should include the current temperature. We can do this by overriding the Notification text when we trigger it.

We need three things to make this work.

  • An Instant Notification that tells us that something is wrong.
  • A Shortcut to trigger the Notification and replace its text and title.
  • An Automation to trigger the Shortcut.

The Notification

We’ll use a simple Instant Notification that we’ll receive as soon as the Automation is triggered. Our Shortcut will later overwrite its text and title.

  1. Go to Notifications, add the new Instant Notification and give it a title. This is still important because it is part of the trigger URL.
  2. Select ‘time-sensitive’ as the interruption level because we always want to know if the temperature is off even when we’re in focus mode or something similar.
  3. Choose ‘Keep All Notifications’ as behavior because we want to see how often and how long the temperature was invalid.
  4. Finally, select the devices that should receive the Notification.

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 ‘A Sensor Detects Something’ as the event and tap next. 
  4. We’ll change the start event later in Controller for HomeKit because Shortcuts can’t handle the events we need. However, first, we need to select a temporary event. Select the temperature sensor and tap next twice.
  5. Here you choose what the Automation will do. Scroll down to the bottom of the list and choose ‘Convert to Shortcut.’
  6. At this point, we have an HomeKit Automation that will trigger a Shortcut. In the Shortcut, delete the ‘Set Scenes and Accessories’ action.
  7. Use the search bar on the bottom to search for the ‘Get the state of <your home name>’ action and add it.
  8. Tap on ‘Accessory State’ and select your temperature sensor. That will read the current value and save it into a variable we can use later.
  9. Search for the ‘Get Contents of URL’ action in the search bar on the bottom and add it.
  10. Paste the URL you copied from our Notification in the URL field.
  11. Tap the arrow in the action to expand the advanced settings.
  12. Change the ‘Method’ from GET to POST. That allows you to send parameters to our server.
  13. Add a new field of the type ‘text.’ Use ‘title’ as the key. The text of this field will replace the title of your Notification.
  14. Add a second field of the type ‘text.’ Use ‘text’ as the key. The text of this field will replace the text of your Notification. Note that the keyboard suggestions will include ‘Current Temperature.’ Tap on this to insert the value of the variable into your text.
  15. Finally, tap next to finish the Shortcut.

When you tap ‘Test this Automation,’ you should receive the Notification with the title and text you just defined. It should contain the current temperature of your sensor. 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.
  2. Give the Automation a more meaningful name.
  3. Now, we’re going to change the start event. Tap the current start event, select ‘Each value change,’ and tap ‘Save.’
  4. Now you’ll always get a message if your temperature sensor changes its value. 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 your temperature sensor and select its Current Temperature. Use ‘less than’ as the comparison operator, and choose the lowest acceptable temperature as the value. I use 30°C in my example.
  6. Add another condition and choose your temperature sensor again. This time use ‘greater than’ and enter the highest acceptable temperature as the value. I use 40°C in my example.
  7. At last, switch from ‘All’ to ‘Any’ so your Automation will run if either of the conditions is true.

Wrap Up

That’s it. Controller for HomeKit will now keep an eye on your temperature and let you know if it’s off. If you like this, look at our Advanced HomeKit Notifications Documentation. We have some other great examples there!