The poop analytics I've always wanted

As you may remember from a previous post, I have a blind cat whom I made some eyes for (which, incidentally, were a great success). One of the perennial and enduring problems every couple faces when they have a cat is how to divide the poop scooping. At least, that’s what I imagine, extrapolating from a sample size of 1.

Over the years, I have tried to come up with various equitable solutions that would be fair to both me and my partner. A few days after implementing the first solution, “just leave poop where it is”, we realized that we needed to add “be fair to the cat too” to the above equation, and I went back to the drawing board.

In this post, I will guide you through the various solutions I implemented.

The various solutions I implemented

An artist's rendition of my cat pooping. In reality, there's much more apartment around her.

Poop arrow

Initially, I started with a very simple solution, an indicator of who scooped the poop last. Being the proud owner of a 3D printer, I designed and printed a very simple wheel with the initials of my partner and me, and a poop emoji arrow. Whenever someone scooped the poop, they would turn the arrow to the other person’s initial, so we knew whose turn it was to scoop next.

This had various downsides:

  • We kept forgetting to spin the arrow. When cleaning the litter, turning the arrow was somehow fiddly enough that we wouldn’t bother with it most of the time.
  • The arrow didn’t fit the spindle as snugly as it should, so sometimes it rotated on its own.
  • There was no way to tell how long ago the last scooping was. This threw the schedule out of balance a bit, as we didn’t know if the last cleaning was today or three days ago.

This solution was a failure, as it didn’t really give enough information or work well in practice.

Dividing the days

Afterwards, we decided to divide the days between us. Each of us got three days of the week, and one was a rest day, so we asked the cat to please not poop on Sundays.

This actually worked pretty well, as knowing whose turn it was required minimal coordination. It still required some, because if someone forgot to clean on their day, they’d need to clean the litter the next, so we still had to ask, but it was a much better solution than the arrow.

There were three downsides to this solution:

  • The communication required was a bit cumbersome, sometimes one of us wasn’t available when the other wanted to clean, and so we didn’t know whose turn it was.
  • The selfish, inconsiderate cat sometimes did poop on Sundays.
  • It was impossible to track scooping statistics, thus upsetting our cat’s “Quantified Self” regime.

An improvement was required.

The button

The twenty-first century wouldn’t be the twenty-first century without an overcomplicated, inconvenient technological solution to every problem, and this was no exception. I decided to write an application to track our cat toilet cleaning habits.

To do this, I decided that I needed some sort of device that would have two states (one for each litter cleaning person), that would be wireless (as I wanted to mount it on the cat toilet), and that would last forever without needing to change batteries.

The first (legacy) method of tracking (bottom), and the current, hi-tech one, top.

One quick solution that fulfilled all these requirements was an IKEA TRÅDFRI dimmer switch, which uses Zigbee and is very cheap as well (at 10 EUR).

Zigbee is a network protocol for low-power devices like sensors, buttons, and switches. It’s kind of like WiFi but it can only send messages between devices, and is meant mostly for home automation communication. It’s basically perfect for this kind of device, that will get used infrequently and whose battery needs to last as long as possible.

The only issue I had with this switch (and all the IKEA switches I had, really), was that their battery would run out really quickly, every two or three weeks or so. It maybe an incompatibility between the IKEA Zigbee implementation and the Sonoff Zigbee bridge I’m using, I haven’t been able to figure out exactly what it is, but it luckily hasn’t been an issue in the few weeks I’ve been using it for this project.

The Zigbee

Pressing the switch sends a Zigbee message to the Sonoff bridge, which forwards it to my MQTT server. If I listen to the switch’s topic (tele/zigbee/BEEF/SENSOR, let’s say), I get the following JSON:

{
  "ZbReceived": {
    "0xBEEF": {
      "Device": "0xBEEF",
      "Name": "Cat poop",
      "Power": 1,
      "Endpoint": 1,
      "LinkQuality": 53
    }
  }
}

The Power value depends on whether you press the “on” or the “off” side. I put some stickers with our names over those bits, and now there’s a button for me and one for my partner, to press after we’ve cleaned the litter.

The app

The web UI of the small app I made.

On the other side lives a very simple Django app, with a daemon that listens to MQTT messages. When the daemon receives the MQTT message above, it adds an entry to a database table that indicates that one of us cleaned the litter, along with a timestamp.

The server part of the Django app serves the simple page you see on the right, which currently shows who the last person to clean the litter was, and how long ago the last cleaning took place.

Since every cleaning is stored into the database, I can (and will, at some point) generate detailed statistics about exactly when each one took place, by whom, what the average time between cleanings is, and a whole host of other such statistics that will ultimately be entirely useless, like most analytics.

Still, though, it’s fun to build, and what is art if not building things just for the hell of it?

Epilogue

I really like Zigbee as a protocol, it’s very lightweight, the devices last forever on a small battery, I don’t have to worry about my network getting hacked (since the messages are very restricted in what they can carry and it’s an entirely separate network from my WiFi), it works even if I don’t have internet, and it’s trivial to interoperate with if you have a Zigbee-to-MQTT bridge.

This little project has been very successful, since now it’s very simple to touch a button whenever we clean the litter, and we can always see when the last cleaning took place. I’m very satisfied with how it came together, and how useful and functional it is.

As always, if you have any feedback, please Tweet or toot at me, or email me directly.