···170170171171 if groups is None:
172172 all_groups = bridge.get_group()
173173+ if isinstance(all_groups, list):
174174+ # hue api returns errors as a list, e.g. [{"error": {"description": "..."}}]
175175+ errors = [g.get("error", {}).get("description") for g in all_groups if "error" in g]
176176+ if errors:
177177+ raise RuntimeError(f"hue bridge error: {'; '.join(errors)}")
178178+ raise RuntimeError(f"unexpected response from bridge: {all_groups}")
173179 groups = [
174180 info["name"]
175181 for gid, info in all_groups.items()