mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Fix hue groups on older hubs (#4884)
This commit is contained in:
parent
da6bdf275e
commit
832f9737a8
@ -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,7 +163,10 @@ 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
|
||||||
|
|
||||||
api_groups = api.get('groups')
|
if skip_groups:
|
||||||
|
api_groups = {}
|
||||||
|
else:
|
||||||
|
api_groups = api.get('groups')
|
||||||
|
|
||||||
if not isinstance(api_groups, dict):
|
if not isinstance(api_groups, dict):
|
||||||
_LOGGER.error("Got unexpected result from Hue API")
|
_LOGGER.error("Got unexpected result from Hue API")
|
||||||
@ -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…
x
Reference in New Issue
Block a user