I while ago I tweeted a video of me using Siri to feed my cat
Got a new pet feeder and “hacked” it to make it work with Siri/HomeKit.— Rafa (@rafahari) May 6, 2020
The cat was not impressed, but whatever, Siri can feed her now. pic.twitter.com/e42FA89vVW
Since then several people have asked me how did I make that work, and through the mystical power of procrastination I am now writing a simple how-to guide, 6 months later.
This is extremely hacky — everytime you log in to the Petkit app in a different device this breaks, but it made for a cool tweet and it's fun.
If you have an Apple Silicon based Mac, then that's the only device we'll need, otherwise we need an iOS device to run the Petkit app… oh yeah and we need the Petkit feeder and app. I should've start there.
I've only tested this with the Petkit Element Mini, but I see no reason why it wouldn't work with the other Petkit devices.
There's two parts to this:
First thing we need to do is find the right API call. We're going to do this by "listening" to our network requests, trigger a manual feeding with the Petkit app, and finding the right booger.
To listen to the network requests I use an app called Charles, which is available for both macOS and iOS.
Let's start by opening the Petkit app, make sure you're logged in and everything is already set up and proceed to the screen that would trigger a new feeding… AND STOP, NO TOUCHING!
Let's now open Charles, make sure the status is set to Active, tap Current Session, and let's hit the little Clear Session icon in the bottom to make it easier to find the right one.
Alright, we can now go back to Petkit, and trigger a new manual feeding. The amount of food that you selected is going to be the amount used for our "smart feedings". Did the feeder dispense food? Good. If it didn't then something's wrong and I'm not qualified to help you any further, go figure that one out first.
Cool, let's now go back to Charles, and BOOM, it should have a bunch of new items in that list… it should look something like this:
Tap the one that says
http://api.petkt.com and then look for the first one that says
latest/feedermini/save_dailyfeed — that's the one, that's our booger! Keep that thing around, we're gonna need it very soon.
There's now two ways we can trigger this via Siri: we can either create a Shortcut, or add it as a device to our Home app via Homebridge.
Definitely the easiest way is to create a Shortcut — open the Shortcuts app and hit
+ to create a new Shortcut.
That's hit, run the Shortcut and the your feeder should dispense food!
If you're running Homebridge, we can add the Petkit feeder as a device using the
config.jsonadd the appropriate Request Headers
If something is not working, it's very likely that you either wrote down the API call incorrectly. I like to use an app like Paw to assemble and test the API call before, to make sure I got it right.
There you go, a convoluted and complicated way of achieving something pretty nerdy that will definitely break in a couple weeks.