mitsubishi2MQTT
mitsubishi2MQTT copied to clipboard
Set temperature off by one degree
I have several N series mini splits using this library on D1 mini v2 clones. One annoyance I've noticed is that the web interface (and of course MQTT) always report a "set" temperature that is one degree higher than set by the IR remote control.
For example, if I turn on the unit and set the temperature to 69 degrees F with the IR remote, the web interface says it's set to 70 degrees F.
Actually I wonder if this is a rounding error, or a problem converting Celsius to Fahrenheit. When I set the temperature to 68 degrees via the IR remote, it also shows up at 68 via MQTT. But when I change it to 69 via the remote, it jumps to 70 in MQTT.
68 F is exactly equal to 20 C, so it makes sense that would get represented accurately.
And 69 F = 20.5555555 C, which, if rounded to the nearest degree C is 21 C, and 21 C is 69.8 F, which rounds to 70.
So I think your explanation of the issue as a rounding problem is spot on. It's just a matter of figuring out where in the code the issue happens, and/or how to fix it. My best guess is that something in the code is using the step size (which you have presumably set to 1 degree F) to round in celsius, not just in Fahrenheit.
To help with debugging, could you make a table of various temperatures (in F) input by the remote, and how they show up in MQTT? Then switch your mitsubishi2mqtt configuration to use Celsius with a step size of 0.5 degrees, and then report how various temperatures (in F) set by the remote are reported (in C) to MQTT. Maybe also try configuring mitsubishi2mqtt to use Fahrenheit with a step size of 0.5 degrees and try the same?
The F/C conversion scale repeats every 9 degrees F / 5 degrees C. So a range of maybe 12 consecutive degrees F (like 66 to 78) would be enough input to see all the possible ways of rounding.
Some of the discussion at https://github.com/SwiCago/HeatPump/issues/51 might be relevant here.
Oh yeah, C-F conversion is pretty clearly the issue. Based on the code and the discussion in https://github.com/SwiCago/HeatPump/issues/51, it sounds like all heat pumps (even in USA) internally track temperature in Celsius, presumably in 0.5 degree increments. The remotes perform some F-C conversion on the fly when working in Fahrenheit mode, and whatever algorithm they use is different than ours. Possible because one of these libraries is dropping the decimal and treating the temps as ints.
I'll try to take a closer look at this later and get the data you asked for.
Here is the data for heating mode.
IR remote setpoint (F) | MQTT setpoint (F) | MQTT setpoint (C) |
---|---|---|
72 | 73 | 22.5 |
71 | 72 | 22.0 |
70 | 71 | 21.5 |
69 | 70 | 21.0 |
68 | 68 | 20.0 |
67 | 66 | 19.0 |
66 | 65 | 18.5 |
Trying to debug this made me even more confused. The Swicago code explicitly rounds up or down by a half degree depending on mode, which might explain this, but mitsubishi2mqtt uses its own conversion code which rounds to the nearest degree and should be more precise. So 🤷
Sounds like a similar issues to https://github.com/gysmo38/mitsubishi2MQTT/issues/175 It might be to do with the use of "toInt()" instead of "toFloat()", which causes an issue due to dropping decimal places when rounding.