CodeSOD: Heating Up Note

CodeSOD: Heating Up

Mini-split systems are popular for retrofitting older homes due to their cost-effectiveness and energy efficiency, but their reliance on IR remotes complicates integration with home automation. A common issue arises from the temperature conversion logic within these systems, particularly when converting between Celsius and Fahrenheit. An open-source project attempting to integrate mini-splits into home automation revealed a flawed temperature conversion method.The project's code uses lookup tables for Celsius to Fahrenheit and Fahrenheit to Celsius conversions. These tables contain specific, often inaccurate, mappings, leading to discrepancies compared to standard conversion formulas. For instance, 18C is incorrectly mapped to 65F instead of the more accurate 64F (when rounded). The design of these lookup tables suggests an attempt to approximate conversions rather than precise mathematical calculations.The author initially believed this was a naive optimization by the hobby project, but a comment in the code clarifies these are "direct mappings based on the remote." This indicates that the inaccuracies stem from the remote control itself. The remote likely uses lookup tables due to limitations of its embedded microcontroller, which may not handle floating-point calculations efficiently.Consequently, when a user sets a temperature like 72F on the remote, the remote internally translates it to an approximate Celsius value (e.g., 22.5C) before sending the command to the unit. This approximation, while "good enough" in most contexts, creates inconsistencies for precise automation. The fundamental problem, according to the author, isn't the hobby project's code or the remote itself, but rather the continued use of non-standard units (Fahrenheit) globally, which necessitates these imprecise conversions.