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.
This commit is contained in:
Phil Cole
2017-07-26 22:25:41 +01:00
parent 8043c83da9
commit db7fe47ec7

View File

@@ -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')