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.
When changing the color of a light, Abode will sometimes return a hue value that is off by 1 resulting in a warning log message, "Set color mismatch for device...". In an attempt to reduce unnecessary logging messages (mostly to reduce extraneous logging messages in Home Assistant), this pull request makes a slight modification to the comparison of the requested and response object hue value using the math standard library. The
isclose
method (added in Python 3.5) is used withabs_tol
set to1
. This way, if the values are ever anything greater than 1.0, the warning log message will appear, which shouldn't happen unless something is really off. If the values are equal to or less than 1.0, the warning log message will not appear. I've only seen this "issue" with the hue value, hence the reason I only made the change there.Edit: Just spent more time than I'd like to admit on confusion with the
or
operator. The parenthesis around the entireif
statement led me down the wrong path, then trying to format the code so the line wasn't too long confused me even more. It should be correct now.math.isclose(response_object["hue"], int(hue), abs_tol=1)
will returnTrue
if the difference between the hue values are less than or equal to 1.So basically my logic is, if not true (i.e. the difference between the hue values are greater than 1) or the saturation values don't match, then log the warning. Clear as mud.... I need some sleep.