Tuesday, December 19, 2023

Making my environment more portable

 I have a bit more than a few Linux hosts on my LAN and most of my work's computer systems are Linux as well. I wanted to have something to synchronize my bash, tmux, and vim settings everywhere I work. I crafted a simple "env" project with a setup script which replaces these configuration files with softlinks to files in the project. I use git to first clone the project and then run setup to get everything in place.

I also found that I was occasionally updating these setting files. Obviously I used git to keep track of these changes. I took this a step further and put a function in my bash profile to check if the env project has any upstream changes to pull. This is a very rudimentary synchronization system and does quite nicely to keep my environment consistent wherever I roam.

Monday, December 18, 2023

Watering the cat




 I took some time off at the end of 2023. I had a chance to resurrect some of my old projects including the notorious water fountain for the cat. I've been enjoying accomplishing various things with resources I already have on hand, so I dusted off a raspi3 and the Intel Movidius stick I have and set to work putting the project back together. This time around I already had a hole in the countertop, so I wasn't going to bother with the wireless or battery power aspects of the concept.

I had bought a nice fountain with an infrared sensor which worked very well for the past 4 years (except for just one tubing blowout that happened when I was home, and the manufacturer was extremely responsive sent a new tube and it never happened again). However, nowadays I often find myself occupying that section of my counter (espresso workstation), and so the cat fountain would often trigger. Also it ate counterspace.

I used a very quick and dirty setup to accomplish the task, looping the control through home assistant via an MQTT sensor published by the raspi, which was linked through a simple automation to a Zigbee relay. With the sensor state and relay state coupled, all I had to do was resurrect the old stream_ty python script and ask ChatGPT to make me a nice MQTT sensor class to send updates to Home Assistant. I had to make sure to ask for the class to do LWT and keepalive and to retry if it lost connection. I also had to make sure it sent a config json to the config topic for automatic discovery.

Since I already had the water spout and under-sink plumbing, valve and a new hole in the counter (from plumbing the espresso machine), I was able to check the box on this task in a couple of days (after screwing around with a raspi zero, which didn't work in the end...). It's interesting that when I looked into running tiny yolo on the raspi 3 it seems like I could probably have done this without the Movidius... maybe I'll try someday.