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

Fahrenheit Conversion Inconsistencies #73

Merged
merged 8 commits into from
Jun 26, 2024
Merged

Conversation

mag2352
Copy link
Contributor

@mag2352 mag2352 commented May 14, 2024

I understand that this is a hacky way of resolving the StopIteration problems, but this resolves the issue I have in #72. Unless someone can dedicate significant time into determining how the conversion process differs, this is enough to allow HomeAssistant to function as expected with the Gree units that I have, and this PR should not cause any issues for those who don't have these problems.

mag2352 and others added 3 commits May 14, 2024 15:49
The current limits of the temperature table are not sufficient. Given that the temperature sensor of the AC unit is reading higher than 30C, or 86F, the temperature value will not be reported correctly. Simply extending this range solves this problem. This is specifically to address the temperature sensor in the unit, not its climate-addressable range.
Copy link

codecov bot commented Jun 26, 2024

Codecov Report

Attention: Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.

Project coverage is 91.98%. Comparing base (db819b4) to head (2b100f6).
Report is 2 commits behind head on master.

Current head 2b100f6 differs from pull request most recent head 51371ec

Please upload reports for the commit 51371ec to get more accurate results.

Files Patch % Lines
greeclimate/device.py 81.81% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #73      +/-   ##
==========================================
- Coverage   92.18%   91.98%   -0.21%     
==========================================
  Files           5        5              
  Lines         678      686       +8     
==========================================
+ Hits          625      631       +6     
- Misses         53       55       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -105,7 +105,11 @@ def generate_temperature_record(temp_f):
TEMP_OFFSET = 40
TEMP_MIN_F = 46
TEMP_MAX_F = 86
TEMP_TABLE = [generate_temperature_record(x) for x in range(TEMP_MIN_F, TEMP_MAX_F + 1)]
TEMP_MIN_TABLE = 8
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the goal here is to allow the device to report temperatures outside of the settable range, MIN should also be lowered.... maybe -50, then max to 60... just to give some headroom of conceivable reasonable values.

Copy link
Contributor Author

@mag2352 mag2352 Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand your point, but if the unit inside a room is reading less than 8C, or 46F, there's a bigger issue at hand than the temperature it's reading (that is really cold, haha). Fair point, should be fine to adjust limits.

Edit: Didn't realize you suggested a limit, I'll make changes for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extended the minimum to -60 C (-76 F), and maximum to 60 C (140 F).

try:
f = next(t for t in matching_temSet if t["temRec"] == bit)
except StopIteration:
f = matching_temSet[0]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add test cases covering these lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't gotten around to that, I'll take a look at this shortly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do you have any clue why some units have discrepancies between the temSets and temRecs? Since this solution has worked fine for me on HomeAssistant, it isn't very important to actually implement, but addressing this problem would fix the root of this hacky solution.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not sure. This whole approach to supporting F feels like Gree added a feature that while trying not to break C support on existing hardware. It's seems likely that the conversion is not computed on need, I could never find a functional formula that just worked and so had to pre-compute the table for the lookup to work at all.

@cmroche
Copy link
Owner

cmroche commented Jun 26, 2024

=========================== short test summary info ============================
FAILED tests/test_device.py::test_send_temperature_out_of_range_farenheit_get[100] - assert 140 == 68
======================== 1 failed, 85 passed in 45.68s =========================

Have to remove some of the now valid ranges :)

@mag2352
Copy link
Contributor Author

mag2352 commented Jun 26, 2024

Wasn't sure if I should have touched those test cases - Thanks.

@cmroche
Copy link
Owner

cmroche commented Jun 26, 2024

Wasn't sure if I should have touched those test cases - Thanks.

No worries, looks good. I'll merge soon. Thanks for the updates.

Copy link
Owner

@cmroche cmroche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cmroche cmroche merged commit f09f3f1 into cmroche:master Jun 26, 2024
4 checks passed
github-actions bot pushed a commit that referenced this pull request Jun 26, 2024
## [1.4.2](v1.4.1...v1.4.2) (2024-06-26)

### Bug Fixes

* Fahrenheit conversion inconsistencies ([#73](#73)) ([f09f3f1](f09f3f1))
Copy link

🎉 This PR is included in version 1.4.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants