Skip to content

Commit

Permalink
Fix for hue logging issue (#64)
Browse files Browse the repository at this point in the history
* Fix for hue logging issue

* Fix for saturation comparison

* Yet another fix for comparison confusion
  • Loading branch information
shred86 authored Feb 17, 2020
1 parent c4108ec commit d294c57
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions abodepy/devices/light.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Abode light device."""
import json
import logging
import math

from abodepy.exceptions import AbodeException

Expand Down Expand Up @@ -74,8 +75,11 @@ def set_color(self, color):
if response_object['idForPanel'] != self.device_id:
raise AbodeException((ERROR.SET_STATUS_DEV_ID))

if (response_object['hue'] != int(hue) or
response_object['saturation'] != int(saturation)):
# Abode will sometimes return hue value off by 1 (rounding error)
hue_comparison = math.isclose(response_object["hue"],
int(hue), abs_tol=1)
if not hue_comparison or (response_object["saturation"]
!= int(saturation)):
_LOGGER.warning(
("Set color mismatch for device %s. "
"Request val: %s, Response val: %s "),
Expand Down

0 comments on commit d294c57

Please sign in to comment.