Automating My Air Conditioner
I may earn commissions from purchases made through affiliate links in this post.
I have a dumb window air conditioner in my bedroom. It's dumb in the sense that it doesn't have a built-in thermometer, so it's unable to maintain a constant temperature.
Edit: Someone helpfully pointed out that my unit does have the ability to self-regulate. Looking at some customer reviews, I do see some complaints that it doesn't work very well on this model. But still, I should have read the manual instead of assuming that the top knob is just a static control. My bad!
If I leave it on overnight, it eventually makes the room too cold. I decided to automate it using an air quality monitor and a smart plug.
Next, I had to figure out how to turn the air conditioner on and off. I investigated smart plugs but didn't find any with APIs that are intended for public use.
Most of the plugs integrated with voice assistants like Alexa and Google Home. However, I couldn't find APIs for the voice assistants either. Voice control and the respective mobile apps seemed like the only ways to interact with them.
I ended up buying a Kasa smart plug.
Kasa doesn't provide a documented API, but other people have reverse engineered how Kasa's mobile apps work, so I can use this Node.js package to control my plug remotely. Thanks to this package, it was easy to get things working.
Before going to sleep, I turn my air conditioner on to the low setting. Through the night, my VPS cron job checks the current temperature every 10 minutes. If the temperature is above 75°F, the job turns the smart plug on. If the temperature is under 73°F, the job turns the smart plug off.
This setup has worked well for me for the past summer. After the first night, it was very satisfying to check the Awair app and see that the temperature bounced between the two thresholds.
It would have been much easier to spend a little more money in the first place to buy an air conditioner that has a built-in thermometer.
I learned later that I also could have used IFTTT, which has an Awair integration, with a high temperature trigger and a low temperature trigger. I could have linked these triggers to the Kasa integration to turn the smart plug on and off.
But doing it through the APIs myself was much more fun!