An “Accessory is turned on” notification with Pushover
A question came across on my Twitter feed today morning where a guy asked: “Is it possible to receive notification on the iPhone whenever an accessory is turned on? The device by the way is controllable over HomeKit.
Unfortunately, there are no out of the box solution neither in the HomeKit framework nor the Shortcuts, but I found a workaround to solve this.
The solution is leveraging a 3rd party solution called Pushover. This service provides easy to use API to send a real push notification to any supported platforms (including iOS). Pushover provides a free tier for home users (including 7500 notifications per month), no limitation in applications and even it can be used via email. The caveat is that you need to purchase (IAP – 5$) the application on the target platform after a 7 days long free trial. I really recommend it, very handy in many use cases.
I assume that you have already created an account at Pushover, you have downloaded the application, now ready to create the automation.
Create an application at Pushover
- On the site, down below the “Your Applications” section, create a new one by clicking “Create an Application/API Token” link.
- Provide a name (mandatory) and an icon if you want, then click “Create Application” button.
- Application created, now need to save your token displayed on the top of the page.
That’s it, now head to the phone.
Create a HomeKit automation with Home
- Open the Home app on your iPad or iPhone, and select “Automation” on the bottom.
- Create a new one.
- Select “An Accessory is Controlled” on the next page.
- Select the accessory you want to monitor. In my example, I’ll use my living room television.
- Set the conditions (turned on/off, any time, any people etc.)
- When you are on the scenes page in Home app, scroll down to the bottom and there you will see a “Convert to Shortcut” button. Click on it. A Shortcuts editor UI will open.
- Remove the default action, and add a new one: Web category – Get Contents of URL. Setup template is on my screenshot. Details (when you add fields to the body (token, user, title, message; all of them Text type):
- URL: https://api.pushover.net/1/messages.json
- Method: POST
- Request body: JSON
- token: the value of your application token generated in the previous step
- user: your user token can be found on Pushover’s dashboard
- title: whatever you want to see in the notification’s title section
- message: the body of the notification
- Once you set it up, click Next and Done.
If you configured everything right, now it’s time to test. In my case, a I’ll receive a notification everytime the TV in the living room is turned on.