Skip to content

Commit 86dfa7a

Browse files
rytilahtiballoob
authored andcommitted
[switch.flux] Allow disabling setting the brightness (home-assistant#5407)
* flux: allow disabling setting the brightness * Use separate boolean for disabling brightness adjustment * Update flux.py
1 parent 4aab72f commit 86dfa7a

File tree

1 file changed

+8
-2
lines changed
  • homeassistant/components/switch

1 file changed

+8
-2
lines changed

homeassistant/components/switch/flux.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
CONF_SUNSET_CT = 'sunset_colortemp'
3333
CONF_STOP_CT = 'stop_colortemp'
3434
CONF_BRIGHTNESS = 'brightness'
35+
CONF_DISABLE_BRIGTNESS_ADJUST = 'disable_brightness_adjust'
3536
CONF_MODE = 'mode'
3637

3738
MODE_XY = 'xy'
@@ -52,6 +53,7 @@
5253
vol.All(vol.Coerce(int), vol.Range(min=1000, max=40000)),
5354
vol.Optional(CONF_BRIGHTNESS):
5455
vol.All(vol.Coerce(int), vol.Range(min=0, max=255)),
56+
vol.Optional(CONF_DISABLE_BRIGTNESS_ADJUST): cv.boolean,
5557
vol.Optional(CONF_MODE, default=DEFAULT_MODE):
5658
vol.Any(MODE_XY, MODE_MIRED)
5759
})
@@ -88,10 +90,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
8890
sunset_colortemp = config.get(CONF_SUNSET_CT)
8991
stop_colortemp = config.get(CONF_STOP_CT)
9092
brightness = config.get(CONF_BRIGHTNESS)
93+
disable_brightness_adjust = config.get(CONF_DISABLE_BRIGTNESS_ADJUST)
9194
mode = config.get(CONF_MODE)
9295
flux = FluxSwitch(name, hass, False, lights, start_time, stop_time,
9396
start_colortemp, sunset_colortemp, stop_colortemp,
94-
brightness, mode)
97+
brightness, disable_brightness_adjust, mode)
9598
add_devices([flux])
9699

97100
def update(call=None):
@@ -106,7 +109,7 @@ class FluxSwitch(SwitchDevice):
106109

107110
def __init__(self, name, hass, state, lights, start_time, stop_time,
108111
start_colortemp, sunset_colortemp, stop_colortemp,
109-
brightness, mode):
112+
brightness, disable_brightness_adjust, mode):
110113
"""Initialize the Flux switch."""
111114
self._name = name
112115
self.hass = hass
@@ -118,6 +121,7 @@ def __init__(self, name, hass, state, lights, start_time, stop_time,
118121
self._sunset_colortemp = sunset_colortemp
119122
self._stop_colortemp = stop_colortemp
120123
self._brightness = brightness
124+
self._disable_brightness_adjust = disable_brightness_adjust
121125
self._mode = mode
122126
self.unsub_tracker = None
123127

@@ -192,6 +196,8 @@ def flux_update(self, now=None):
192196
temp = self._sunset_colortemp + temp_offset
193197
x_val, y_val, b_val = color_RGB_to_xy(*color_temperature_to_rgb(temp))
194198
brightness = self._brightness if self._brightness else b_val
199+
if self._disable_brightness_adjust:
200+
brightness = None
195201
if self._mode == MODE_XY:
196202
set_lights_xy(self.hass, self._lights, x_val,
197203
y_val, brightness)

0 commit comments

Comments
 (0)