Taming a terrible AC with the power of IoT
Some time ago I wrote a post about taming a terrible soundbar with the power of Internet of Things. The solution used a Wi-Fi connected infrared repeater, which simulated buttons on the soundbar remote being pressed in specific order and with specific delay.
I don't have that soundbar anymore. I upgraded it to a more sane and up to date soundbar with HDMI ARC, meaning it turns on together with the TV. No need for extra remote or extra actions.
But there's always opportunity to make some dumb devices smarter! This time, the main character is my air conditioning unit.
My AC kinda sucks
Most air conditioners can be easily controlled with a remote, which communicates with the unit via infrared signals. When you press a button on the remote, it usually emits the current state of the air conditioner (mode, temperature, fan speed and so on).
Not only did I manage to tame my previous soundbar this way, I had some success with air conditioners as well. Unfortunately, my current AC can only be controlled with a panel that's wired into the wall. It doesn't have a remote. It doesn't accept any infrared or radio signals from the outside world.

The manufacturer, Mitsubishi, sells an expansion pack which would enhance it with Wi-Fi capabilities, allowing to easily plug it into rest of my smart home ecosystem. One downside: it costs around $350 per one air conditioner. Another downside: due to legal requirements it needs to be installed by a qualified serviceman, who's likely going to charge another three digits amount for that.
Surely we can do better cheaper?
The finger
Enter a device called switch bot or finger bot. It's a box with a small arm which uses an internal motor to move it up and down. Upon a command, it can press a button. Pretty simple.
I got mine on Aliexpress for about $18, and there are plenty of clones with different pricing:

And here it is in action, on the AC control panel, turning it on and off:
The device on its own doesn't have any connectivity other than Bluetooth. Which means you can either manually control it with your phone when you're in its range...
...or you can connect it to the world with a Bluetooth gateway, which in turn connects to the Wi-Fi and the cloud. Now that's set up, you can toggle the power button from anywhere in the world. In my case, it's

Now we can automate the AC. It's just the matter of turning it on and off, right?
Quirks
One thing I didn't mention is that this AC seems kind of dumb when it comes to automatically turning off. It will reach the set temperature, and then continue cooling the air down. I once set it to 21 degrees, and it kept blasting cold air until the temperature in the room reached freezing 17 degrees.
Or, after cooling down the room, will keep blowing room-temperature air, generating unnecessary noise and using unnecessary electricity.
To my advantage, I have plenty of Zigbee and Bluetooth temperature sensors, all feeding data into Home Assistant. I can create a more precise and fine-tuned mechanism for controlling the AC. Basically I want to forget about turning it on and off — the machinery should do it for me.
There's another important thing: outside air and air in a room with AC turned on shouldn't generally mix. I want the AC to turn on only if the balcony is closed, as well as turn off whenever someone opens the balcony door.
The script
Here's the Home Assistant automation as of now:

Let's go over it.
Triggers: the AC will turn on whenever any of two specific temperature sensors goes above 24 degrees (but only when the balcony door is closed). Moreover, it will also turn on if the balcony door is closed (but only when the temperature is high enough). See below conditions for more details.
It took me a while to realise that an automation is triggered by change of state, not by state itself. In our case, closing the balcony door or temperature crossing 24 degrees will start the automation.
There's a risk that if, for whatever reason, Home Assistant restarts (or the automation is disabled or edited), and the temperature is above 24 degrees and nobody touches the balcony door, the AC will never turn on. No idea how likely of a scenario this is yet, so I'm going to not worry about it for now.
Conditions: the time condition is fairly straightforward. The AC should operate only during daytime, as usually there's nobody in the living room during the night.
The other two conditions mirror the above triggers. If either of them fires (eg. the balcony is closed), that doesn't necessarily mean that we want the AC to turn on. It should happen only if both the balcony is closed and the temperature is high enough.
Actions: it's a very simple loop. Turn the AC on, run it for some time, then turn it off either when it reaches desired temperature (here: 22.5 degrees), or after an hour and half. My thinking is that even it doesn't get cold enough during that time, it will decrease from the threshold of 24 degrees.
If it stays below 24 degrees, great, maybe a bit of electricity was saved. It it rises again, the automation will turn the AC on again. It will generate a chart like this, which anyone messing with PID controllers should recognise:

Moreover, the automation loop will also break when the balcony door is opened and kept open for more than a minute. Reasoning here is this indicates clear intent to keep the balcony door open, and let the outside air in — in which case the AC should not operate.
Downsides
The main downside of this solution is that the switch bot can press only one button on the AC panel: power. (Unless I get more switch bots, but no idea how many of them would reasonably fit on that panel.) That means settings like fan speed, temperature, mode etc. can't be controlled remotely, either by myself or Home Assistant.
Fortunately, I see myself adjusting these fairly rarely — twice per year maybe? Once when summer turns into winter (mode: cool -> heat), and reverse 6 months alater.
This is something I could have if I got the original Wi-Fi module. The downside of that would be forking out hundreds of dollars on the module and hundreds of dollars on installation, vs $18 I spent on the switch bot. I think the tradeoff is worth it.