gysmo38 / mitsubishi2MQTT

Mitsubishi to MQTT with ESP8266 module
GNU Lesser General Public License v2.1
413 stars 141 forks source link

Correct Fahrenheit/Celsius conversions to match MA Remote Controller #272

Closed dsstewa closed 2 months ago

dsstewa commented 4 months ago

Pull Request Summary: Improved Temperature Conversion Functions

Overview

This pull request enhances the toCelsius function to include precise mappings for specific Fahrenheit to Celsius conversions required by the project. It also introduces a new toFahrenheit function to map Celsius values back to Fahrenheit. The changes ensure that temperature conversions align with the desired setpoints for both IR remote control and MA Remote Dispaly.

Changes Made

  1. Enhanced toCelsius Function:

    • Implemented a lookup table to map specific Fahrenheit values to their corresponding Celsius values.
    • Included mappings for the following Fahrenheit setpoints:
      • 61°F to 88°F in Fahrenheit setpoints incremented by 1°F.
      • Each mapping corresponds to the appropriate Celsius value (e.g., 72°F -> 22.5°C, 73°F -> 23.0°C).
    • The function defaults to a general conversion formula for values not explicitly listed in the table.
  2. Enhanced toFahrenheit Function:

    • Created a reverse lookup table to map specific Celsius values back to their corresponding Fahrenheit values.
    • Included mappings for the following Celsius setpoints:
      • 16.0°C to 30.5°C in Celsius setpoints incremented by 0.5°C.
      • Each mapping corresponds to the appropriate Fahrenheit value (e.g., 22.5°C -> 72°F, 23.0°C -> 73°F).
    • The function defaults to a general conversion formula and rounds the result to the nearest integer for values not explicitly listed in the table.

Code Implementation

Impact

These improvements significantly enhance the functionality and reliability of temperature conversions within the codebase.

danepowell commented 4 months ago

@gysmo38 can you please approve the workflow so we can get a test build to flash?

dsstewa commented 4 months ago

@danepowell I have successfully flashed the updated version to three units: a 9k Ceiling Cassette, a 9k High Wall, and a 24k Air Handler. Everything is functioning perfectly. It's particularly satisfying because I have an MA controller on the air handler, and previously, the temperature discrepancies between the units and the controller were very frustrating.


danepowell commented 4 months ago

This is awesome, thanks so much! I don't have time for a thorough code review, but it looks good at first glance, and I've installed it on five heat pumps and it solves #200

pzbitskiy commented 3 months ago

I also confirm now HA Fahrenheit temperature numbers match to IR remote display Fahrenheit numbers (MSZ-GLXX unit).

gysmo38 commented 2 months ago

Thank you for your PR :)