-
A tale of two IP addresses
04/12/2019 at 17:59 • 0 commentsIt was the best of scripts, it was the worst of scripts. Ok, mostly it was the worst. I don't actually know python so that doesn't help.
I built some fancy error handling into my script so that if it doesn't find the bulbs right away it keeps trying until it connects before starting the main loop that waits for button presses. I also added some code to reconnect if it can't find the bulbs when trying to send them commands. Yay! No more breaks in the script.
Except it never connected. It just kept trying and trying and trying. I finally looked up the IP addresses for my bulbs. Imagine my surprise when they were different than they used to be! That's when I remembered that the utility company recently cut power for a few hours to do repairs. When my router came back online, it reassigned IP addresses.
Now I know I could easily work around this by setting fixed addresses for my bulbs, but that isn't user friendly to other people who want to use my project. I guess I'll have to double down and figure out how to find bulbs by MAC address instead.
Bleh.
I'll let you know if it ever works. Meanwhile my new code is awesome. I'm still afraid of my power supply thing that I bought for $3 and I might never actually test it for fear of burning my house down.
-
Error handling!
04/11/2019 at 01:47 • 0 commentsHey guys. So I've been thinking about my python code lately and I've realized that it really sucks. I understand now exactly why my script never seemed to work with rc.local or most other methods of auto starting. It throws exceptions like Kobe throws 3-pointers. Is Kobe still relevant? I don't watch sports.
Anyways... what I really need is some error handling. I finally read up on handling errors in python and it's super convenient. I've made a new roadmap for my script with new, better loops and real error handling. I just need ten minutes or so to sit down and rewrite it. Maybe after the baby goes to bed. Once it's all updated, it should run better, look cleaner, and be able to start from rc.local!
-
It works, completely
03/28/2019 at 08:11 • 0 commentsMy run on boot issues are a result of the script failing when it couldn't connect to the bulbs. I tried adding a timer before it connected in hopes that it would give other tasks time to initialize. No luck.
Eventually, I discovered daemontools. It automatically runs what you tell it to, but it will restart the script if it fails. Finally! Now all I have to do is give power to the pi and my switch works without any further setup. All that's left is printing the parts in white and putting it in the wall. I guess I should test my power supply first as well.
This project is almost complete!
-
It works. Mostly
03/27/2019 at 13:43 • 0 commentsThe new code using the flux_led library works perfectly. It turns the lights on and off with so little delay it might as well be a normal switch. This is exactly what I wanted!
The problem now is that I can't get it to run on boot. I tried rc.local, which worked with my old code. Nope. I tried crontab. Nothing. I even tried systemd. Nothing seems to make it run on boot. I'll have to dig through the boot logs for clues.
At least it works if I SSH in and start it through the terminal.
-
Better code!
03/26/2019 at 05:12 • 0 commentsYou guys!
I just discovered the flux_led python library. It's compatible with almost all cheapo smart bulbs including my magiclight bulbs. This is a game changer! I can use this script library to directly control the bulbs from my pi zero instead of using IFTTT as a middle man. This had loads of benefits so I'm taking some time to rewrite my script. It will be more code but should be totally worth it.
-
Prototype is mostly built. Test video linked.
03/09/2019 at 23:03 • 0 commentsTest of the prototype. I printed the plastic faceplate and buttons, and got the pushbutton switches mounted. I didn't have the right size standoffs for the pi so that will come in a few days. The connection is good though and it works as it should. My next step is testing the 5V power supply I bought for this project.