-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
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 config entry for LIFX #17201
Add config entry for LIFX #17201
Conversation
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.
There's no config schema for the component. Better add that and let the core do the config validation instead of doing that later in the platform.
@@ -30,9 +32,10 @@ | |||
|
|||
_LOGGER = logging.getLogger(__name__) | |||
|
|||
REQUIREMENTS = ['aiolifx==0.6.3', 'aiolifx_effects==0.2.1'] | |||
DEPENDENCIES = ('lifx',) |
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.
We normally use a list here.
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.
Oh, I thought that looked odd. (It was copied from the Cast migration but I see now that this is not the normal way.)
I refrained from moving more stuff into the component in order to keep the PR small. If you think it's better to move the config schema in this PR, I can work on that. |
Since config validation is part of the component, it should be there. |
Deprecated. | ||
""" | ||
_LOGGER.warning('Loading LIFX via light platform config is deprecated.') | ||
await _async_setup_platform( |
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.
Since lifx is a dependency, configuring via a platform will set up the lifx component and load the config entry. If we also call this, we end up setting it up twice?
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.
I removed the backwards compatibility now.
async def async_setup_entry(hass, config_entry, async_add_entities): | ||
"""Set up LIFX from a config entry.""" | ||
try: | ||
config = vol.Schema(CONFIG)(hass.data[LIFX_DOMAIN].get('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.
Validation in component
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.
Done. I had to remove the defaults but maybe just as well to keep those in the third party library.
@@ -17,12 +18,12 @@ | |||
from homeassistant.components.light import ( | |||
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS_PCT, ATTR_COLOR_NAME, ATTR_COLOR_TEMP, | |||
ATTR_EFFECT, ATTR_HS_COLOR, ATTR_KELVIN, ATTR_RGB_COLOR, ATTR_TRANSITION, | |||
ATTR_XY_COLOR, COLOR_GROUP, DOMAIN, LIGHT_TURN_ON_SCHEMA, PLATFORM_SCHEMA, | |||
ATTR_XY_COLOR, COLOR_GROUP, DOMAIN as LIGHT_DOMAIN, LIGHT_TURN_ON_SCHEMA, |
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.
Keep DOMAIN
as DOMAIN
, since this is the domain (light) of this platform.
local_addr = config.get(CONF_SERVER) | ||
if local_addr is not None: | ||
kwargs['local_addr'] = (local_addr, 0) | ||
coro = hass.loop.create_datagram_endpoint(lambda: lifx_discovery, **kwargs) | ||
|
||
hass.async_add_job(coro) |
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.
Use async_create_task
.
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.
Looks good!
Description:
This is a minimal PR to add a config entry for LIFX. I plan additional PRs for a more complete experience.
Breaking change: LIFX can now be configured from the integrations page in the config panel and advanced configuration is available through the
lifx:
component configuration. Configuring LIFX via light platform config no longer works.Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#6565
Example entry for
configuration.yaml
(if applicable):Checklist:
tox
.If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.