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

Merged
merged 5 commits into from Oct 7, 2018

Conversation

@amelchio
Member

amelchio commented Oct 6, 2018

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):

lifx:
  light:
    server: 10.0.2.14
    broadcast: 10.0.2.255

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

@amelchio amelchio requested a review from home-assistant/core as a code owner Oct 6, 2018

@wafflebot wafflebot bot added the in progress label Oct 6, 2018

@amelchio amelchio referenced this pull request Oct 6, 2018

Merged

Move lifx to own component #6565

2 of 2 tasks complete
@MartinHjelmare

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',)

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Oct 7, 2018

Member

We normally use a list here.

This comment has been minimized.

@amelchio

amelchio Oct 7, 2018

Member

Oh, I thought that looked odd. (It was copied from the Cast migration but I see now that this is not the normal way.)

@amelchio

This comment has been minimized.

Member

amelchio commented Oct 7, 2018

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.

@balloob

This comment has been minimized.

Member

balloob commented Oct 7, 2018

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(

This comment has been minimized.

@balloob

balloob Oct 7, 2018

Member

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?

This comment has been minimized.

@amelchio

amelchio Oct 7, 2018

Member

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', {}))

This comment has been minimized.

@balloob

balloob Oct 7, 2018

Member

Validation in component

This comment has been minimized.

@amelchio

amelchio Oct 7, 2018

Member

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,

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Oct 7, 2018

Member

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)

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Oct 7, 2018

Member

Use async_create_task.

amelchio added some commits Oct 7, 2018

@MartinHjelmare

Looks good!

@MartinHjelmare MartinHjelmare merged commit 086c715 into home-assistant:dev Oct 7, 2018

5 checks passed

Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.1%) to 93.519%
Details

@wafflebot wafflebot bot removed the in progress label Oct 7, 2018

@balloob balloob referenced this pull request Oct 26, 2018

Merged

0.81 #17809

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment