Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 2, 2024
1 parent 25f8406 commit 5d680b4
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions custom_components/adaptive_lighting/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1588,27 +1588,34 @@ async def update_hue_run(self, service_data: ServiceData):
return

_LOGGER.debug(
"%s: Will updates scenes containing %s",
self._name,
self.hue_keyword,
"%s: Will updates scenes containing %s",
self._name,
self.hue_keyword,
)
await self.hue_bridge.initialize()
for scene_id in self.hue_bridge.scenes:
scene = self.hue_bridge.scenes[scene_id]
if self.hue_keyword in scene.name:
color_temp = color_temperature_kelvin_to_mired(service_data[ATTR_COLOR_TEMP_KELVIN])
color_temp = color_temperature_kelvin_to_mired(
service_data[ATTR_COLOR_TEMP_KELVIN]
)
brightness = round(254 * self._settings["brightness_pct"] / 100)
_LOGGER.debug(
"%s: Updating %s with values bri:%s, color_temp:%s",
self._name,
scene.name,
brightness,
color_temp
color_temp,
)
lightstates = await scene.lightstates
for light_id in scene.lights:
try:
await scene.set_lightstate(id=light_id,on=lightstates[light_id]["on"],bri=brightness,ct=color_temp)
await scene.set_lightstate(
id=light_id,
on=lightstates[light_id]["on"],
bri=brightness,
ct=color_temp,
)
except Exception:
_LOGGER.exception(
"Cannot update scene %s",
Expand Down

0 comments on commit 5d680b4

Please sign in to comment.