Skip to content

Commit

Permalink
support multiple virtuals
Browse files Browse the repository at this point in the history
  • Loading branch information
YeonV committed Dec 29, 2020
1 parent 18ea651 commit a397887
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
11 changes: 8 additions & 3 deletions custom_components/ledfxrm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,11 +492,16 @@ async def async_blade_on(self, state):
self._hs = state.get("hs_color")
return None

async def async_virtual_on(self, state):
# logging.warning("CHECK THIS: %s", state)
async def async_virtual_on(self, state, virtual):
test = next(
v
for v in self.virtuals.get("virtuals").get("list")
if v.get("name") == virtual.split("Virtual: ")[1]
)
# logging.warning("CHECK THIS: %s", test)

testcolor = color_hs_to_RGB(state.get("hs_color")[0], state.get("hs_color")[1])
b = self.virtuals.get("virtuals").get("list")[0].get("items")
b = test.get("items")
c = sorted(b, key=lambda x: x.get("order_number"))
# logging.warning("B: %s \n C: %s \n\n", b, c)
for key in c:
Expand Down
14 changes: 2 additions & 12 deletions custom_components/ledfxrm/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ async def async_turn_on(self, **kwargs): # pylint: disable=unused-argument
# kwargs,
# )
if "hs_color" in kwargs:
await self.coordinator.api.async_virtual_on(kwargs)
await self.coordinator.api.async_virtual_on(kwargs, self.name)
self._hs = kwargs["hs_color"]
if "effect" in kwargs:
# logging.warning(
Expand Down Expand Up @@ -443,12 +443,7 @@ async def async_turn_off(self, **kwargs): # pylint: disable=unused-argument
@property
def unique_id(self):
"""Return a unique ID to use for this entity."""
return self.config_entry.entry_id + "." + self.virtual.get("name")

@property
def name(self):
"""Return the name of the light."""
return "⮑ " + self.virtual.get("name")
return self.config_entry.entry_id + ".virtual-" + self.virtual.get("name")

@property
def supported_features(self) -> int:
Expand All @@ -471,11 +466,6 @@ def assumed_state(self):
"""Return the name of the switch."""
return True

@property
def unique_id(self):
"""Return a unique ID to use for this entity."""
return self.config_entry.entry_id + ".virtual-light"

@property
def name(self):
"""Return the name of the light."""
Expand Down

0 comments on commit a397887

Please sign in to comment.