From 0e2ead682679eca1049916dfe16eb2d68cc44f07 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 16 Aug 2018 01:23:22 +0200 Subject: [PATCH] Default to configured lights if no lights/groups args are passed to Hue delta actions --- platypush/plugins/light/hue/__init__.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/platypush/plugins/light/hue/__init__.py b/platypush/plugins/light/hue/__init__.py index a08fa7cd..115cb937 100644 --- a/platypush/plugins/light/hue/__init__.py +++ b/platypush/plugins/light/hue/__init__.py @@ -397,7 +397,11 @@ class LightHuePlugin(LightPlugin): if group['name'] in groups ]) else: - raise RuntimeError('Please specify either a list of lights or groups') + bri = statistics.mean([ + light['state']['bri'] + for light in self.bridge.get_light().values() + if light['name'] in self.lights + ]) delta *= (self.MAX_BRI/100) if bri+delta < 0: @@ -434,7 +438,11 @@ class LightHuePlugin(LightPlugin): if group['name'] in groups ]) else: - raise RuntimeError('Please specify either a list of lights or groups') + sat = statistics.mean([ + light['state']['sat'] + for light in self.bridge.get_light().values() + if light['name'] in self.lights + ]) delta *= (self.MAX_SAT/100) if sat+delta < 0: @@ -471,7 +479,11 @@ class LightHuePlugin(LightPlugin): if group['name'] in groups ]) else: - raise RuntimeError('Please specify either a list of lights or groups') + hue = statistics.mean([ + light['state']['hue'] + for light in self.bridge.get_light().values() + if light['name'] in self.lights + ]) delta *= (self.MAX_HUE/100) if hue+delta < 0: