mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Fix Hue groups with same names (#5737)
* Revert "Fix hue lightgroups not syncing state (#5702)" * Use light_id in unique_id for Hue groups * Make sure HueLight unique_id is unique * Update hue.py * Update hue.py * Update hue.py
This commit is contained in:
parent
f774538e66
commit
f0da576315
@ -200,8 +200,7 @@ def setup_bridge(host, hass, add_devices, filename, allow_unreachable,
|
|||||||
|
|
||||||
for light_id, info in api_lights.items():
|
for light_id, info in api_lights.items():
|
||||||
if light_id not in lights:
|
if light_id not in lights:
|
||||||
lights[light_id] = HueLight(hass,
|
lights[light_id] = HueLight(int(light_id), info,
|
||||||
int(light_id), info,
|
|
||||||
bridge, update_lights,
|
bridge, update_lights,
|
||||||
bridge_type, allow_unreachable,
|
bridge_type, allow_unreachable,
|
||||||
allow_in_emulated_hue)
|
allow_in_emulated_hue)
|
||||||
@ -219,7 +218,6 @@ def setup_bridge(host, hass, add_devices, filename, allow_unreachable,
|
|||||||
|
|
||||||
if lightgroup_id not in lightgroups:
|
if lightgroup_id not in lightgroups:
|
||||||
lightgroups[lightgroup_id] = HueLight(
|
lightgroups[lightgroup_id] = HueLight(
|
||||||
hass,
|
|
||||||
int(lightgroup_id), info, bridge, update_lights,
|
int(lightgroup_id), info, bridge, update_lights,
|
||||||
bridge_type, allow_unreachable, allow_in_emulated_hue,
|
bridge_type, allow_unreachable, allow_in_emulated_hue,
|
||||||
True)
|
True)
|
||||||
@ -282,11 +280,10 @@ def request_configuration(host, hass, add_devices, filename,
|
|||||||
class HueLight(Light):
|
class HueLight(Light):
|
||||||
"""Representation of a Hue light."""
|
"""Representation of a Hue light."""
|
||||||
|
|
||||||
def __init__(self, hass, light_id, info, bridge, update_lights,
|
def __init__(self, light_id, info, bridge, update_lights,
|
||||||
bridge_type, allow_unreachable, allow_in_emulated_hue,
|
bridge_type, allow_unreachable, allow_in_emulated_hue,
|
||||||
is_group=False):
|
is_group=False):
|
||||||
"""Initialize the light."""
|
"""Initialize the light."""
|
||||||
self.hass = hass
|
|
||||||
self.light_id = light_id
|
self.light_id = light_id
|
||||||
self.info = info
|
self.info = info
|
||||||
self.bridge = bridge
|
self.bridge = bridge
|
||||||
@ -304,8 +301,14 @@ class HueLight(Light):
|
|||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the ID of this Hue light."""
|
"""Return the ID of this Hue light."""
|
||||||
return "{}.{}".format(
|
lid = self.info.get('uniqueid')
|
||||||
self.__class__, self.info.get('uniqueid', self.name))
|
|
||||||
|
if lid is None:
|
||||||
|
default_type = 'Group' if self.is_group else 'Light'
|
||||||
|
ltype = self.info.get('type', default_type)
|
||||||
|
lid = '{}.{}.{}'.format(self.name, ltype, self.light_id)
|
||||||
|
|
||||||
|
return '{}.{}'.format(self.__class__, lid)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user