Skip to content
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

Allow split component definitions in packages #16177

Merged
merged 2 commits into from
Sep 24, 2018
Merged

Allow split component definitions in packages #16177

merged 2 commits into from
Sep 24, 2018

Conversation

thomasloven
Copy link
Contributor

@thomasloven thomasloven commented Aug 24, 2018

Description:

Two different configuration styles are described in
https://www.home-assistant.io/docs/configuration/devices/#style-2-list-each-device-separately

But only one is allowed in packages according to
https://www.home-assistant.io/docs/configuration/packages/

This change allows "Style 2" configuration in packages.

Related issue: N/A

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#6075

Example entry for configuration.yaml (if applicable):

homeassistant:
  packages: !include dir_named packages

packages/my_package.yaml

sensor first:
  - platform: template
    sensors:
      my_sensor_1:
        value_template: 1

sensor second:
  - platform: template
    sensors:
      my_sensor_2:
        value_template: 2

Checklist:

  • The code change is tested and works locally.

  • Local tests pass with tox. Your PR cannot be merged unless tests pass
    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.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@thomasloven thomasloven requested a review from a team as a code owner August 24, 2018 18:58
@homeassistant
Copy link
Contributor

Hi @thomasloven,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@homeassistant homeassistant added cla-needed core small-pr PRs with less than 30 lines. labels Aug 24, 2018
@ghost ghost added the in progress label Aug 24, 2018
@@ -130,7 +130,7 @@

PACKAGES_CONFIG_SCHEMA = vol.Schema({
cv.slug: vol.Schema( # Package names are slugs
{cv.slug: vol.Any(dict, list, None)}) # Only slugs for component names
{cv.string: vol.Any(dict, list, None)}) # Only slugs for component names

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (81 > 79 characters)

@homeassistant
Copy link
Contributor

Hi @thomasloven,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

Copy link
Contributor

@amelchio amelchio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have looked at this PR before but not commented because I could not believe that such a simple change could work. It was actually less typing to make it work than it was to describe that it did not work.

This area of the code is unknown to me but now I looked at the PR more closely and I don't see why it wouldn't work. That is awesome.

I only have a few suggestions for the comments and you can feel free to ignore those since comment style is subjective anyway.

However, some tests should be added (to tests/test_config.py). I think we will want a test with several entries for the same component being merged in (like light 1:, light 2:) since that was one situation I was wondering about.

homeassistant/config.py Outdated Show resolved Hide resolved
homeassistant/config.py Outdated Show resolved Hide resolved
@thomasloven
Copy link
Contributor Author

Thanks. I agree, it's suspiciously simple.

I'll look at implementing a test of some sort too. Thanks for the pointer on where to start!

@thomasloven
Copy link
Contributor Author

I've added a test that checks that components like light 1: and light 2: are added to the configuration. Making sure they are read correctly, and that the actual configurations are merged is the responsibility of async_process_component_config and not related to my changes.

@balloob balloob merged commit ad47ece into home-assistant:dev Sep 24, 2018
@ghost ghost removed the in progress label Sep 24, 2018
@balloob
Copy link
Member

balloob commented Sep 24, 2018

Congrats on your first PR merged 🎉

@thomasloven
Copy link
Contributor Author

Thank you!

fabaff pushed a commit to home-assistant/home-assistant.io that referenced this pull request Sep 24, 2018
@balloob balloob mentioned this pull request Sep 28, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed core small-pr PRs with less than 30 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants