From cacc542f38172a1c036cee557f1e4c787e8788f7 Mon Sep 17 00:00:00 2001 From: shred86 Date: Sun, 16 Feb 2020 21:16:55 -0800 Subject: [PATCH 1/3] Fix for hue logging issue --- abodepy/devices/light.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/abodepy/devices/light.py b/abodepy/devices/light.py index 736ac77..39d3652 100644 --- a/abodepy/devices/light.py +++ b/abodepy/devices/light.py @@ -1,6 +1,7 @@ """Abode light device.""" import json import logging +import math from abodepy.exceptions import AbodeException @@ -74,8 +75,12 @@ 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) + if not ( + math.isclose(response_object["hue"], int(hue), abs_tol=1) + or response_object["saturation"] != int(saturation) + ): + _LOGGER.warning( ("Set color mismatch for device %s. " "Request val: %s, Response val: %s "), From 5820cbb77e83a56d604c45170d3a003a07fcdea9 Mon Sep 17 00:00:00 2001 From: shred86 Date: Sun, 16 Feb 2020 21:40:25 -0800 Subject: [PATCH 2/3] Fix for saturation comparison --- abodepy/devices/light.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abodepy/devices/light.py b/abodepy/devices/light.py index 39d3652..8fef007 100644 --- a/abodepy/devices/light.py +++ b/abodepy/devices/light.py @@ -78,7 +78,7 @@ def set_color(self, color): # Abode will sometimes return hue value off by 1 (rounding error) if not ( math.isclose(response_object["hue"], int(hue), abs_tol=1) - or response_object["saturation"] != int(saturation) + or response_object["saturation"] == int(saturation) ): _LOGGER.warning( From 760e6fadb55abc83a78469bc66c41e69fd692c43 Mon Sep 17 00:00:00 2001 From: shred86 Date: Sun, 16 Feb 2020 22:46:27 -0800 Subject: [PATCH 3/3] Yet another fix for comparison confusion --- abodepy/devices/light.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/abodepy/devices/light.py b/abodepy/devices/light.py index 8fef007..aea45d0 100644 --- a/abodepy/devices/light.py +++ b/abodepy/devices/light.py @@ -76,11 +76,10 @@ def set_color(self, color): raise AbodeException((ERROR.SET_STATUS_DEV_ID)) # Abode will sometimes return hue value off by 1 (rounding error) - if not ( - math.isclose(response_object["hue"], int(hue), abs_tol=1) - or response_object["saturation"] == int(saturation) - ): - + 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 "),