-
-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
Adding color support to template light #12439
Conversation
I wanted to add color to the template light for a project and I thought I could submit it. I don't know much of the rest of the code of the project but the changes work so far on my installation.
self._state = None | ||
|
||
self._color = color | ||
#TODO input check for colors |
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.
block comment should start with '# '
@@ -156,9 +184,12 @@ def name(self): | |||
@property | |||
def supported_features(self): | |||
"""Flag supported features.""" | |||
if self._level_script is not None: | |||
if self._level_script is not None and self._color_script is not None: | |||
return SUPPORT_RGB_COLOR |SUPPORT_BRIGHTNESS |
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.
missing whitespace around operator
|
||
def __init__(self, hass, device_id, friendly_name, state_template, | ||
icon_template, entity_picture_template, on_action, | ||
off_action, level_action, level_template, entity_ids): | ||
off_action, level_action, level_template, color_action, color_template, entity_ids): |
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 (101 > 79 characters)
@@ -96,7 +112,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): | |||
LightTemplate( | |||
hass, device, friendly_name, state_template, | |||
icon_template, entity_picture_template, on_action, | |||
off_action, level_action, level_template, entity_ids) | |||
off_action, level_action, level_template, color_action, color_template, entity_ids) |
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 (99 > 79 characters)
@@ -11,7 +11,7 @@ | |||
|
|||
from homeassistant.core import callback | |||
from homeassistant.components.light import ( | |||
ATTR_BRIGHTNESS, ENTITY_ID_FORMAT, Light, SUPPORT_BRIGHTNESS) | |||
ATTR_BRIGHTNESS, ATTR_RGB_COLOR, ENTITY_ID_FORMAT, Light, SUPPORT_BRIGHTNESS, SUPPORT_RGB_COLOR) |
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 (100 > 79 characters)
These modifications go along [this pull request](home-assistant/core#12439). I added an example for a common classes of IR remote lights.
|
||
def __init__(self, hass, device_id, friendly_name, state_template, | ||
icon_template, entity_picture_template, on_action, | ||
off_action, level_action, level_template, entity_ids): | ||
off_action, level_action, level_template, |
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.
trailing whitespace
@@ -96,7 +113,8 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): | |||
LightTemplate( | |||
hass, device, friendly_name, state_template, | |||
icon_template, entity_picture_template, on_action, | |||
off_action, level_action, level_template, entity_ids) | |||
off_action, level_action, level_template, |
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.
trailing whitespace
@@ -11,7 +11,8 @@ | |||
|
|||
from homeassistant.core import callback | |||
from homeassistant.components.light import ( | |||
ATTR_BRIGHTNESS, ENTITY_ID_FORMAT, Light, SUPPORT_BRIGHTNESS) | |||
ATTR_BRIGHTNESS, ATTR_RGB_COLOR, ENTITY_ID_FORMAT, Light, |
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.
trailing whitespace
I encounter errors once I updated the code to the latest version and I have no idea of why it behaves like this. Here is the error in my configuration : I tried to tweak the schema but nothing seems to fit. Can someone with more understanding of the global picture point me in the right direction ? Should I take this issue to the forums ? |
I figured out the errors (bad merge of changes I guess). It works in my installation like a charm and I would like for it to be merged in the main code in order to be able to update without worries. Thanks for the great software ! |
These modifications go along [this pull request](home-assistant/core#12439). I added an example for a common classes of IR remote lights.
Is there any additional step required to merge this ? I would like to be able to update my installation. |
Using SUPPORT_COLOR instead of the deprecated SUPPORT_RGB_COLOR
I would appreciate a lot that this code gets merged because maintaining it outside of the main code is become a regular hassle. Thanks in advance. |
Apparently RGB colors are not a thing anymore in the light environment ? Help would be greatly appreciated. |
Code LGTM, but:
|
Forgot about something: We have since standardised around Hue, have a look at other light platforms like MQTT: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/light/mqtt.py |
Is there any update on this? @grea09, I've tried to use this version as custom component but for some reason the component stopped working after merging your changes. |
I will try to correct this code once I get more available time. The code needs to take the recent changes to work and is defunct for now with the latest version of HA. |
This PR seems to have gone stale. Please re-open it when you want to proceed. |
I wanted to add color to the template light for a project and I thought I could submit it. I don't know much of the rest of the code of the project but the changes work so far on my installation.
Description:
Related issue (if applicable): fixes https://community.home-assistant.io/t/light-template-colors/33937/2
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>
Example entry for
configuration.yaml
(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests passREQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass