Fix hue groups on older hubs (#4884)
This commit is contained in:
parent
da6bdf275e
commit
832f9737a8
1 changed files with 13 additions and 1 deletions
|
@ -143,10 +143,13 @@ def setup_bridge(host, hass, add_devices, filename, allow_unreachable):
|
||||||
|
|
||||||
lights = {}
|
lights = {}
|
||||||
lightgroups = {}
|
lightgroups = {}
|
||||||
|
skip_groups = False
|
||||||
|
|
||||||
@util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
|
@util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
|
||||||
def update_lights():
|
def update_lights():
|
||||||
"""Update the Hue light objects with latest info from the bridge."""
|
"""Update the Hue light objects with latest info from the bridge."""
|
||||||
|
nonlocal skip_groups
|
||||||
|
|
||||||
try:
|
try:
|
||||||
api = bridge.get_api()
|
api = bridge.get_api()
|
||||||
except socket.error:
|
except socket.error:
|
||||||
|
@ -160,6 +163,9 @@ def setup_bridge(host, hass, add_devices, filename, allow_unreachable):
|
||||||
_LOGGER.error("Got unexpected result from Hue API")
|
_LOGGER.error("Got unexpected result from Hue API")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if skip_groups:
|
||||||
|
api_groups = {}
|
||||||
|
else:
|
||||||
api_groups = api.get('groups')
|
api_groups = api.get('groups')
|
||||||
|
|
||||||
if not isinstance(api_groups, dict):
|
if not isinstance(api_groups, dict):
|
||||||
|
@ -185,6 +191,12 @@ def setup_bridge(host, hass, add_devices, filename, allow_unreachable):
|
||||||
lights[light_id].schedule_update_ha_state()
|
lights[light_id].schedule_update_ha_state()
|
||||||
|
|
||||||
for lightgroup_id, info in api_groups.items():
|
for lightgroup_id, info in api_groups.items():
|
||||||
|
if 'state' not in info:
|
||||||
|
_LOGGER.warning('Group info does not contain state. '
|
||||||
|
'Please update your hub.')
|
||||||
|
skip_groups = True
|
||||||
|
break
|
||||||
|
|
||||||
if lightgroup_id not in lightgroups:
|
if lightgroup_id not in lightgroups:
|
||||||
lightgroups[lightgroup_id] = HueLight(
|
lightgroups[lightgroup_id] = HueLight(
|
||||||
int(lightgroup_id), info, bridge, update_lights,
|
int(lightgroup_id), info, bridge, update_lights,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue