Version 1 was written in Swift and ran on a Raspberry Pi. It worked but was kind of a waste of a whole Raspberry Pi.
Version 2 was written in MicroPython on a Wemos D1 Mini. It was flakey and required connecting to USB to update.
Version 3 still runs on a D1 but moves all automation logic to the server so updates are super easy.
After running my errands today I rewarded myself by rewriting my IoT rotary phone as an Arduino sketch.
This is the third rewrite, and so far the best version. It uses MQTT to send messages to my home automation server.
The previous ones called the server API directly which meant actions were annoying to change.
https://gist.github.com/emorydunn/51ca944db5efd395f00ef4770368f233
childhood movies, animal cruelty Show more
This was filed over two years ago by some thoroughly unhelpful person called @emorydunn.
I decided to run the server as an XCP service, because it’s a nice easy way to make little sub-processes in macOS. All of that actually worked quite nicely, except for one fundamental part of the application: Apple Events, which have to be called on the main thread. Unfortunately in an XPC service the main thread is blocked by the service listener, meaning the Apple Events can’t run.
I decided to put all of the logic for the application into the server and have the client communicate over TCP, even if the client was the process that actually _started_ the server. The reason being there would be no difference between a local client and a remote one, just the IP address it would connect to.
Photographer, maker, and general nerd.