project 06 · ac fix
The AC that died every 56 minutes
One air conditioner went unavailable roughly every 56 minutes, and only came back when someone opened the vendor app.
root cause
- The library had no retry: one failed poll = device unavailable.
- It leaked a socket on every timeout or error. The ESP-based Wi-Fi module only has a handful of sockets, so it eventually locked up.
- It also did a single
read(1024)and called partial responses "invalid".
fix
A small module that monkey-patches the transport: per-device lock, read until Content-Length, always close the socket. Plus 3 retries and a 10-minute grace period on the last known state. Code.
result
The unit that dropped every ~56 minutes: zero drops in 27+ hours. Then I did it properly: the fix went into the library itself, with tests that fail on the old code, and was sent upstream: daikin-br/pyiotdevice#2.