Update Hue platform to aiohue 1.5.0, and re-implement logic for duplicate scene names. (#14653)

This commit is contained in:
MizterB 2018-05-28 10:21:00 -04:00 committed by Paulus Schoutsen
parent 9044a9157f
commit 9a87e62e0e
4 changed files with 18 additions and 6 deletions

View File

@ -17,7 +17,7 @@ from .bridge import HueBridge
# Loading the config flow file will register the flow
from .config_flow import configured_hosts
REQUIREMENTS = ['aiohue==1.3.0']
REQUIREMENTS = ['aiohue==1.5.0']
_LOGGER = logging.getLogger(__name__)

View File

@ -124,9 +124,21 @@ class HueBridge(object):
(group for group in self.api.groups.values()
if group.name == group_name), None)
scene_id = next(
(scene.id for scene in self.api.scenes.values()
if scene.name == scene_name), None)
# The same scene name can exist in multiple groups.
# In this case, activate first scene that contains the
# the exact same light IDs as the group
scenes = []
for scene in self.api.scenes.values():
if scene.name == scene_name:
scenes.append(scene)
if len(scenes) == 1:
scene_id = scenes[0].id
else:
group_lights = sorted(group.lights)
for scene in scenes:
if group_lights == scene.lights:
scene_id = scene.id
break
# If we can't find it, fetch latest info.
if not updated and (group is None or scene_id is None):

View File

@ -86,7 +86,7 @@ aiodns==1.1.1
aiohttp_cors==0.7.0
# homeassistant.components.hue
aiohue==1.3.0
aiohue==1.5.0
# homeassistant.components.sensor.imap
aioimaplib==0.7.13

View File

@ -35,7 +35,7 @@ aioautomatic==0.6.5
aiohttp_cors==0.7.0
# homeassistant.components.hue
aiohue==1.3.0
aiohue==1.5.0
# homeassistant.components.notify.apns
apns2==0.3.0