From 368bc9fddc9cb4fcc06141001a10c3a5589c8da6 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 1 Sep 2020 20:02:13 +0200 Subject: [PATCH] shorten self._lights_types construction --- custom_components/circadian_lighting/switch.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/custom_components/circadian_lighting/switch.py b/custom_components/circadian_lighting/switch.py index d15ddc78..0b0b4b2d 100755 --- a/custom_components/circadian_lighting/switch.py +++ b/custom_components/circadian_lighting/switch.py @@ -3,6 +3,7 @@ Circadian Lighting Switch for Home-Assistant. """ import logging +from itertools import repeat import voluptuous as vol @@ -166,16 +167,10 @@ class CircadianSwitch(SwitchEntity, RestoreEntity): self._disable_state = disable_state self._initial_transition = initial_transition self._only_once = only_once - - self._lights_types = {} - for light in lights_ct: - self._lights_types[light] = "ct" - for light in lights_rgb: - self._lights_types[light] = "rgb" - for light in lights_xy: - self._lights_types[light] = "xy" - for light in lights_brightness: - self._lights_types[light] = "brightness" + self._lights_types = dict(zip(lights_ct, repeat("ct"))) + self._lights_types.update(zip(lights_rgb, repeat("rgb"))) + self._lights_types.update(zip(lights_xy, repeat("xy"))) + self._lights_types.update(zip(lights_brightness, repeat("brightness"))) self._lights = list(self._lights_types.keys()) @property