This repository has been archived by the owner on Oct 7, 2021. It is now read-only.
climate: Add halves when divider is at least 2 #54
Open
3v1n0
wants to merge
1
commit into
PaulAnnekov:master
Choose a base branch
from
3v1n0:fix-decimals
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3v1n0
changed the title
climate: Enable decimals when divider is at least 2
climate: Add halves when divider is at least 2
Nov 26, 2020
21 tasks
3v1n0
added a commit
to 3v1n0/ha-core
that referenced
this pull request
Nov 26, 2020
Devices may use a temperature divider of 2, in such case tuyah won't properly handle its halves values using whole precision. Fix this by checking if the device supports halves, and in such case to return such precision This needs PaulAnnekov/tuyaha#54
3v1n0
added a commit
to 3v1n0/ha-core
that referenced
this pull request
Nov 26, 2020
Devices may use a temperature divider of 2, in such case tuyah won't properly handle its halves values using whole precision. Fix this by checking if the device supports halves, and in such case to return such precision This needs PaulAnnekov/tuyaha#54
Various climate devices use a temperature divider of 2, and they do allow use of halves values, however current tuyaha doesn't allow this. As per this, add an has_halves function that will return true for multiple of 2, while fix target_temperature_step() so that it returns the proper value depending we support decimals or halves
matitalatina
reviewed
Dec 8, 2020
@@ -157,7 +163,10 @@ def set_temperature(self, temperature): | |||
divider = self._divider or 1 | |||
|
|||
if not self.has_decimal(): | |||
temp_val = round(float(temperature)) | |||
if self.has_halves(): | |||
temp_val = round(float(temperature) * 20.0) / 20.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the magic number 20 mean?
I don't understand what you're doing here, at the end you'll have some decimal values here. So It's the same as round(number, 1)
.
For example: temperature=17.7
round(float(17.7) * 20.0) / 20.0 = 17.7
matitalatina
reviewed
Dec 8, 2020
@@ -76,6 +76,10 @@ def has_decimal(self): | |||
"""Return if temperature values support decimal""" | |||
return self._divider >= 10 | |||
|
|||
def has_halves(self): | |||
"""Return if temperature values support halves""" | |||
return self._divider % 2 == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Divider can be overridden by home assistant.
If someone wants to divide by 3, he will not have halves.
What the reason behind using this divider to know that the device support halves?
I think that this PR should be closed because obsolete. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Various climate devices use a temperature divider of 2, and they do
allow use of halves values, however current tuyaha doesn't allow this.
As per this, add an has_halves function that will return true for
multiple of 2, while fix target_temperature_step() so that it returns
the proper value depending we support decimals or halves