mac-zhou / midea-ac-py

Home Assistant Custom Integration for Midea Group(Hualing, Senville, Klimaire, AirCon, Century, Pridiom, Thermocore, Comfee, Toshiba, Carrier, Goodman, Friedrich, Samsung, Kenmore, Trane, Lennox, LG and much more) Air Conditioners via LAN.
MIT License
531 stars 102 forks source link

Celsius to Fahrenheit conversion #83

Closed corecoding closed 3 years ago

corecoding commented 3 years ago

I think the Celsius to Fahrenheit (and possibly back to Celsius) is causing conversion issues.

For example:

When I set the thermostat to 66F in home assistant, it goes to 64F. When I set the thermostat to 73F in home assistant, it goes to 72F. When I set the thermostat to 75F in home assistant, it goes to 73F.

I wrote some PHP code that I think shows what is happening:

for ($f=65;$f<=75;$f++) { $c = 5/9 * ($f - 32); $c2 = intval($c); $f2 = round($c2 * (9/5) + 32); echo "From Fahrenheit $f into Celsius float $c, cast to int $c2, finally back to Fahrenheit $f2\n"; }

The output is as follows: From Fahrenheit 65 into Celsius float 18.333333333333, cast to int 18, finally back to Fahrenheit 64 From Fahrenheit 66 into Celsius float 18.888888888889, cast to int 18, finally back to Fahrenheit 64 From Fahrenheit 67 into Celsius float 19.444444444444, cast to int 19, finally back to Fahrenheit 66 From Fahrenheit 68 into Celsius float 20, cast to int 20, finally back to Fahrenheit 68 From Fahrenheit 69 into Celsius float 20.555555555556, cast to int 20, finally back to Fahrenheit 68 From Fahrenheit 70 into Celsius float 21.111111111111, cast to int 21, finally back to Fahrenheit 70 From Fahrenheit 71 into Celsius float 21.666666666667, cast to int 21, finally back to Fahrenheit 70 From Fahrenheit 72 into Celsius float 22.222222222222, cast to int 22, finally back to Fahrenheit 72 From Fahrenheit 73 into Celsius float 22.777777777778, cast to int 22, finally back to Fahrenheit 72 From Fahrenheit 74 into Celsius float 23.333333333333, cast to int 23, finally back to Fahrenheit 73 From Fahrenheit 75 into Celsius float 23.888888888889, cast to int 23, finally back to Fahrenheit 73

Interestingly, temperatures 65, 67, 68, 69, 70, 71, 72, 74 seem to work okay.

mac-zhou commented 3 years ago

when you use APP to control, is it ok?

corecoding commented 3 years ago

Yes, the Midea app itself works perfectly.

mac-zhou commented 3 years ago

i need more logs. please add to configs

logger:
  default: info
  logs:
    custom_components.midea_ac: debug
    msmart: debug

Remember the operating time, set the thermostat to 65F in home assistant and then set 66F.

corecoding commented 3 years ago

I ran this command: tail -f home-assistant.log > debug.log. Then changed the temperature as you said. Hopefully this is what you are looking for.

corecoding commented 3 years ago

I was poking around a bit with climate.py. I noticed on this line https://github.com/mac-zhou/midea-ac-py/blob/ca5b583e2b26099950e507586c28656c861b9cb9/custom_components/midea_ac/climate.py#L106 that farenheit_unit was spelled incorrectly. When I change it to fahrenheit_unit, my unit changes to Celsius everytime I change the temperature. Same issue mentioned over at https://community.home-assistant.io/t/any-support-for-midea-a-c/18742/141?u=93coder

corecoding commented 3 years ago

I have figured out the issue after reading the msmart code. Here is a PR that fixes it for me. https://github.com/mac-zhou/midea-ac-py/pull/87

mac-zhou commented 3 years ago

I was poking around a bit with climate.py. I noticed on this line

https://github.com/mac-zhou/midea-ac-py/blob/ca5b583e2b26099950e507586c28656c861b9cb9/custom_components/midea_ac/climate.py#L106

that farenheit_unit was spelled incorrectly. When I change it to fahrenheit_unit, my unit changes to Celsius everytime I change the temperature. Same issue mentioned over at https://community.home-assistant.io/t/any-support-for-midea-a-c/18742/141?u=93coder

:) i will change to fahrenheit_unit in next version of msmart

corecoding commented 3 years ago

Looks like you pushed the changes. Thank you! Confirming it works via HACS.