From db7fe47ec72a4907f8a59ebfb47bc4a6dfa41e89 Mon Sep 17 00:00:00 2001 From: Phil Cole Date: Wed, 26 Jul 2017 22:25:41 +0100 Subject: [PATCH] Expose hue group 0 to HA #8652 If allow_hue_groups is set expose "All Hue Lights" group for "special group 0". This does add an additional Hue API call for every refresh (approx 30 secs) to get the status of the special group 0 because it's not included in the full API pull that currently occurs. --- homeassistant/components/light/hue.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/homeassistant/components/light/hue.py b/homeassistant/components/light/hue.py index cdbea7d2194..be3eea60453 100644 --- a/homeassistant/components/light/hue.py +++ b/homeassistant/components/light/hue.py @@ -206,6 +206,18 @@ def setup_bridge(host, hass, add_devices, filename, allow_unreachable, _LOGGER.error("Got unexpected result from Hue API") return + if not skip_groups: + # Group ID 0 is a special group in the hub for all lights, but it's not + # returned by api.get('groups'), so explicity get it and include it. + # See https://developers.meethue.com/documentation/groups-api#21_get_all_groups + all_lamps = bridge.get_group(0) + if not isinstance(all_lamps, dict): + _LOGGER.error("Got unexpected result from Hue API for group 0") + return + # Hue hub returns name of group 0 as "Group 0", so rename for ease of use in HA + all_lamps['name'] = "All Hue Lights" + api_groups["0"] = all_lamps + new_lights = [] api_name = api.get('config').get('name')