This might not be the case for everyone, but certainly for me, with an indoor cat in a 2 bedroom apartment without a naturally ventilated place to keep her litter box.
The hero/villain of the story
Her name is Dua and she is a cuddly & playful rescue tortie cat. Dua loves to play with her mouse toys and adores wet food, the latter of which is likely the reason I'm writing this post π΅βπ«
I have her litter box in my second bathroom's shower. The bathroom has an extractor fan that runs when the bathroom light is on, but she refuses to hasn't figured out how to turn it on and off each time she goes #2... Annoying, right?
Automating the extractor fan
To mitigate the smell I wanted the lights to turn on when Dua goes in her litter box. To do this I put together a few things:
Clone the repo in a folder, install dependencies and then run in background
# Install requirements
pip install -r requirements.txt
# Run in background# TODO: Find/Document a better way to do this
TRIGGER_URL="<webhook_url>" python main.py &
Otherwise add TRIGGER_URL = "<webhook_url>" to an .env file and the script will pick it up.
The script writes its own PID to pid.txt so it can be used. Examples:
# Follow output of background process
tail -f /proc/$(cat pid.txt)/fd/1
# Kill processkill -9 $(cat pid.txt)
The script was inspired by this Raspberry Pi Foundation article and uses their suggested example layout. The sensor needs 5v (Vcc) and Ground (Gnd), so PIN 2 and PIN 6 work well. Connect the sensor's output (Out) toβ¦
With all of this in place I went a step further and added Opentelemetry to track the stats of how often the routine was being triggered on Honeycomb.
I wanted to know if I was turning on the bathroom lights over false positives from the motion sensor, but after some tests it simply serves the purpose of telling how often she goes in her litter box.
Interestingly, I can tell she goes in her litter box (# of motion sensor triggers) on average ~8.5 times per day. I don't think many cat owners can say they know this about their feline friends. I do remember and took inspiration from Aaron Patterson doing something similar a long time ago though.