Add config entry for LIFX#17201
Conversation
MartinHjelmare
left a comment
There was a problem hiding this comment.
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.
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
| REQUIREMENTS = ['aiolifx==0.6.3', 'aiolifx_effects==0.2.1'] | ||
| DEPENDENCIES = ('lifx',) |
There was a problem hiding this comment.
We normally use a list here.
There was a problem hiding this comment.
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.
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.
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.
Done. I had to remove the defaults but maybe just as well to keep those in the third party library.
| 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.
Keep DOMAIN as DOMAIN, since this is the domain (light) of this platform.
| kwargs['local_addr'] = (local_addr, 0) | ||
| coro = hass.loop.create_datagram_endpoint(lambda: lifx_discovery, **kwargs) | ||
|
|
||
| hass.async_add_job(coro) |
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:
REQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.