-
-
Notifications
You must be signed in to change notification settings - Fork 37.9k
Add effects to iGlo Lights #12365
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
Merged
+28
−22
Merged
Add effects to iGlo Lights #12365
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,13 +10,14 @@ | |
| import voluptuous as vol | ||
|
|
||
| from homeassistant.components.light import ( | ||
| ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_RGB_COLOR, PLATFORM_SCHEMA, | ||
| SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR, Light) | ||
| ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_RGB_COLOR, | ||
| SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR, SUPPORT_EFFECT, | ||
| PLATFORM_SCHEMA, Light) | ||
| from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT | ||
| import homeassistant.helpers.config_validation as cv | ||
| import homeassistant.util.color as color_util | ||
|
|
||
| REQUIREMENTS = ['iglo==1.1.3'] | ||
| REQUIREMENTS = ['iglo==1.2.5'] | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
@@ -46,10 +47,6 @@ def __init__(self, name, host, port): | |
| from iglo import Lamp | ||
| self._name = name | ||
| self._lamp = Lamp(0, host, port) | ||
| self._on = True | ||
| self._brightness = 255 | ||
| self._rgb = (0, 0, 0) | ||
| self._color_temp = 0 | ||
|
|
||
| @property | ||
| def name(self): | ||
|
|
@@ -59,12 +56,12 @@ def name(self): | |
| @property | ||
| def brightness(self): | ||
| """Return the brightness of this light between 0..255.""" | ||
| return int((self._brightness / 200.0) * 255) | ||
| return int((self._lamp.state['brightness'] / 200.0) * 255) | ||
|
|
||
| @property | ||
| def color_temp(self): | ||
| """Return the color temperature.""" | ||
| return color_util.color_temperature_kelvin_to_mired(self._color_temp) | ||
| return color_util.color_temperature_kelvin_to_mired(self._lamp.state['white']) | ||
|
|
||
| @property | ||
| def min_mireds(self): | ||
|
|
@@ -81,21 +78,32 @@ def max_mireds(self): | |
| @property | ||
| def rgb_color(self): | ||
| """Return the RGB value.""" | ||
| return self._rgb | ||
| return self._lamp.state['rgb'] | ||
|
|
||
| @property | ||
| def effect(self): | ||
| """Return the current effect.""" | ||
| return self._lamp.state['effect'] | ||
|
|
||
| @property | ||
| def effect_list(self): | ||
| """Return the list of supported effects.""" | ||
| return self._lamp.effect_list | ||
|
|
||
| @property | ||
| def supported_features(self): | ||
| """Flag supported features.""" | ||
| return SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR | ||
| return (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | | ||
| SUPPORT_RGB_COLOR | SUPPORT_EFFECT) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. continuation line under-indented for visual indent |
||
|
|
||
| @property | ||
| def is_on(self): | ||
| """Return true if light is on.""" | ||
| return self._on | ||
| return self._lamp.state['on'] | ||
|
|
||
| def turn_on(self, **kwargs): | ||
| """Turn the light on.""" | ||
| if not self._on: | ||
| if not self.is_on: | ||
| self._lamp.switch(True) | ||
| if ATTR_BRIGHTNESS in kwargs: | ||
| brightness = int((kwargs[ATTR_BRIGHTNESS] / 255.0) * 200.0) | ||
|
|
@@ -113,14 +121,11 @@ def turn_on(self, **kwargs): | |
| self._lamp.white(kelvin) | ||
| return | ||
|
|
||
| if ATTR_EFFECT in kwargs: | ||
| effect = kwargs[ATTR_EFFECT] | ||
| self._lamp.effect(effect) | ||
| return | ||
|
|
||
| def turn_off(self, **kwargs): | ||
| """Turn the light off.""" | ||
| self._lamp.switch(False) | ||
|
|
||
| def update(self): | ||
| """Update light status.""" | ||
| state = self._lamp.state() | ||
| self._on = state['on'] | ||
| self._brightness = state['brightness'] | ||
| self._rgb = state['rgb'] | ||
| self._color_temp = state['white'] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (86 > 79 characters)