Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add limitlessled night light effect #12567

Merged
merged 1 commit into from
Feb 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion homeassistant/components/light/limitlessled.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

LED_TYPE = ['rgbw', 'rgbww', 'white', 'bridge-led', 'dimmer']

EFFECT_NIGHT = 'night'

RGB_BOUNDARY = 40

WHITE = [255, 255, 255]
Expand Down Expand Up @@ -166,12 +168,16 @@ def __init__(self, group, config):
from limitlessled.group.rgbww import RgbwwGroup
if isinstance(group, WhiteGroup):
self._supported = SUPPORT_LIMITLESSLED_WHITE
self._effect_list = [EFFECT_NIGHT]
elif isinstance(group, DimmerGroup):
self._supported = SUPPORT_LIMITLESSLED_DIMMER
self._effect_list = []
elif isinstance(group, RgbwGroup):
self._supported = SUPPORT_LIMITLESSLED_RGB
self._effect_list = [EFFECT_COLORLOOP, EFFECT_NIGHT, EFFECT_WHITE]
elif isinstance(group, RgbwwGroup):
self._supported = SUPPORT_LIMITLESSLED_RGBWW
self._effect_list = [EFFECT_COLORLOOP, EFFECT_NIGHT, EFFECT_WHITE]

self.group = group
self.config = config
Expand Down Expand Up @@ -231,6 +237,11 @@ def supported_features(self):
"""Flag supported features."""
return self._supported

@property
def effect_list(self):
"""Return the list of supported effects for this light."""
return self._effect_list

# pylint: disable=arguments-differ
@state(False)
def turn_off(self, transition_time, pipeline, **kwargs):
Expand All @@ -243,6 +254,12 @@ def turn_off(self, transition_time, pipeline, **kwargs):
@state(True)
def turn_on(self, transition_time, pipeline, **kwargs):
"""Turn on (or adjust property of) a group."""
# The night effect does not need a turned on light
if kwargs.get(ATTR_EFFECT) == EFFECT_NIGHT:
if EFFECT_NIGHT in self._effect_list:
pipeline.night_light()
return

pipeline.on()

# Set up transition.
Expand Down Expand Up @@ -282,7 +299,7 @@ def turn_on(self, transition_time, pipeline, **kwargs):
pipeline.flash(duration=duration)

# Add effects.
if ATTR_EFFECT in kwargs and self._supported & SUPPORT_EFFECT:
if ATTR_EFFECT in kwargs and self._effect_list:
if kwargs[ATTR_EFFECT] == EFFECT_COLORLOOP:
from limitlessled.presets import COLORLOOP
self.repeating = True
Expand Down