Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed calculation of temperature with decimals #177

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gaspo
Copy link

@gaspo gaspo commented Dec 5, 2024

The reported temperature was wrong - decimal part never went ove 0.4.
Im not sure if this is general issue for more devices, or its just me, but I managed to find the culprit in for my Midea AC.

The temperature in payload is rounded to 0.5, but the fraction part is set to full range 0.0-0.9. When adding it up, it results in incorrect values: 25.5+0.9 = 26.4 instead of 25.9 and in fact it never reaches values 25.5 - 25.9
I need to round the intergral part of temperature to 0.0 to get the correct result.

payload from my AC:
c001ae647f7f00000000006541120099000000000000000100000000a9

The temperature in payload is rounded to 0.5 but the fraction part is set to full range 0.0-0.9.  When adding it up, it results in incorrect values: 25.5+0.9 = 26.4 instead of 25.9 and in fact it never reaches values 25.5 - 25.9

I need to round the intergral part of temperature to 0.0 to get the correct result.
@mill1000
Copy link
Owner

mill1000 commented Dec 6, 2024

Thanks for the possible solution.

I've review a few of the available references (Lua, JS, other Github projects), and the results seem mixed. A lot of the JS specifically calculates the floating point value, with a few exceptions. The other GH projects mostly use floats as well except for notably https://github.com/midea-lan/midea-local.

@mill1000
Copy link
Owner

mill1000 commented Dec 6, 2024

Either way, to consider merging this change the unit tests need to be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants