Reverse Engineering a Cat Feeder to Increase Productivity

overview

I laughed it off over the weekend and had to write it down - After some late night Amazon research, I received a FreshElement Solo PetKit. I had two problems he could solve: low motivation for the project and loving Target's Dark Chocolate Sea Salt Almonds too much. I'm a codemonkey - Why can't I feed my monkey brain when I press code?

I couldn't find a USB candy dispenser (I even checked thinkgeek, nothing close!), so I decided to try a cat feeder. This stuff rocks, and I'll show you how to recreate what I did.

Tease [embedded content]

Code: https://github.com/morganpartee/pyPetKit/blob/master/run.py

To get started you will need to set your username and password here: https://github.com/morganpartee/pyPetKit/blob/master/settings.py

An overview

REST APIs are essentially the language of the Internet. Most products use them to communicate between devices and servers. I saw some old Python code whose authentication flow had worked before, so I had a starting point!

I spied the API request that did a manual feed, replicated that in Python with Requests, and bound that script to a button on my streamdeck, which also sends a ctl+enter to submit the commit!< /p>

There are other (better) ways to do this - AWS, webhooks, git hooks (git hooks probably being the best bet), but I wanted this to only work locally, so I'm not handing out candy while I'm out of town. No need to over complicate! At worst, I forget to use the button and I eat less candy.

Equipment

I really can't overstate - This thing is perfect for handing out snacks. Food is portioned by this little silicone auger system, with silicone fingers that limit the amount that can pass through the dispenser. It's clever and gentle on food. And food safe!

Auger Top ViewAuger side view

And that was just plain cute:

Cute

They include a food sizing chart stating they should be under 12mm:

Sizing

But it filters and distributes food like:

Wall

So if it's 12mm high on the side, it'll work fine. I plan to test jerky bits and cheez balls in the future. It includes a desiccant packet in the lid to keep things fresh...so I think it's pretty safe to go wild.

As of this writing, they cost around $70, but they work great and are well built: Buy here

Application

The app is pretty good. It's kinda weird if you don't have a pet... I had to add myself as a dog and choose my "breed": Race Selector

But after that, I was able to use the API. After testing the portion size several times with the app! 1/10th of a cup equals half the rotor, which averages out to about five almonds.

Spying

I used Packet Capture for Android while running a manual feed:

Package

And I found this query:

Packet

There really isn't a silver bullet here, I had to sift through several groups of requests to find the right one. But we can see that it hits the /latest/d4/saveDailyFeed endpoint, which gives us a big clue! The URLENCODED section tells us that the amount, time and device ID are included in the URL... So we can replace...

Reverse Engineering a Cat Feeder to Increase Productivity

overview

I laughed it off over the weekend and had to write it down - After some late night Amazon research, I received a FreshElement Solo PetKit. I had two problems he could solve: low motivation for the project and loving Target's Dark Chocolate Sea Salt Almonds too much. I'm a codemonkey - Why can't I feed my monkey brain when I press code?

I couldn't find a USB candy dispenser (I even checked thinkgeek, nothing close!), so I decided to try a cat feeder. This stuff rocks, and I'll show you how to recreate what I did.

Tease [embedded content]

Code: https://github.com/morganpartee/pyPetKit/blob/master/run.py

To get started you will need to set your username and password here: https://github.com/morganpartee/pyPetKit/blob/master/settings.py

An overview

REST APIs are essentially the language of the Internet. Most products use them to communicate between devices and servers. I saw some old Python code whose authentication flow had worked before, so I had a starting point!

I spied the API request that did a manual feed, replicated that in Python with Requests, and bound that script to a button on my streamdeck, which also sends a ctl+enter to submit the commit!< /p>

There are other (better) ways to do this - AWS, webhooks, git hooks (git hooks probably being the best bet), but I wanted this to only work locally, so I'm not handing out candy while I'm out of town. No need to over complicate! At worst, I forget to use the button and I eat less candy.

Equipment

I really can't overstate - This thing is perfect for handing out snacks. Food is portioned by this little silicone auger system, with silicone fingers that limit the amount that can pass through the dispenser. It's clever and gentle on food. And food safe!

Auger Top ViewAuger side view

And that was just plain cute:

Cute

They include a food sizing chart stating they should be under 12mm:

Sizing

But it filters and distributes food like:

Wall

So if it's 12mm high on the side, it'll work fine. I plan to test jerky bits and cheez balls in the future. It includes a desiccant packet in the lid to keep things fresh...so I think it's pretty safe to go wild.

As of this writing, they cost around $70, but they work great and are well built: Buy here

Application

The app is pretty good. It's kinda weird if you don't have a pet... I had to add myself as a dog and choose my "breed": Race Selector

But after that, I was able to use the API. After testing the portion size several times with the app! 1/10th of a cup equals half the rotor, which averages out to about five almonds.

Spying

I used Packet Capture for Android while running a manual feed:

Package

And I found this query:

Packet

There really isn't a silver bullet here, I had to sift through several groups of requests to find the right one. But we can see that it hits the /latest/d4/saveDailyFeed endpoint, which gives us a big clue! The URLENCODED section tells us that the amount, time and device ID are included in the URL... So we can replace...

What's Your Reaction?

like

dislike

love

funny

angry

sad

wow