Skip to content

Consolidate config flow components#20635

Merged
balloob merged 6 commits into
devfrom
consolidate
Feb 1, 2019
Merged

Consolidate config flow components#20635
balloob merged 6 commits into
devfrom
consolidate

Conversation

@balloob
Copy link
Copy Markdown
Member

@balloob balloob commented Jan 31, 2019

Description:

Consolidate all config flow components to the new component layout. Eventually we want to do this for all integrations but this was an easy list to get started. No more spreading them out. So change binary_sensor/X.py to X/binary_sensor.py.

Wrote a small script to do this, we can use it for other components too:

import pathlib
import sys
import subprocess


def main(comp):
    comps_path = pathlib.Path('./homeassistant/components')

    comp_path = comps_path / comp

    # Check if it is lutron.py and so needs a rename
    if not comp_path.is_dir():
        comp_path.mkdir()
        subprocess.run(f'git mv {comps_path / f"{comp}.py"} {comp_path / "__init__.py"}', shell=True)

    for platform in comps_path.glob(f'*/{comp}.py'):
        new_path = (platform.parent.parent / comp / f"{platform.parts[-2]}.py")
        subprocess.run(f'git mv {platform} {new_path}', shell=True)


if __name__ == '__main__':
    if len(sys.argv) == 2:
        main(sys.argv[1])
    else:
        print("Run consolidate.py <component name>")
        sys.exit(1)

@Kane610
Copy link
Copy Markdown
Member

Kane610 commented Jan 31, 2019

UniFi device tracker isn't part of the config entry yet, so it should be kept apart

@Kane610
Copy link
Copy Markdown
Member

Kane610 commented Jan 31, 2019

Shouldn't the tests be moved as well?

@ghost ghost assigned balloob Jan 31, 2019
@ghost ghost added the in progress label Jan 31, 2019
@amelchio
Copy link
Copy Markdown
Contributor

amelchio commented Feb 1, 2019

Maybe I'm just slow but could you write a note as to why we are doing this, and why only for config flows components?

@bratanon
Copy link
Copy Markdown
Contributor

bratanon commented Feb 1, 2019

Does this also affects custom component structure?

@Kane610
Copy link
Copy Markdown
Member

Kane610 commented Feb 1, 2019

This is for config flow, custom components can't use config flow structure (at least not yet)

@balloob
Copy link
Copy Markdown
Member Author

balloob commented Feb 1, 2019

@bratanon custom components can already use the new structure too.

@balloob balloob merged commit ec57db7 into dev Feb 1, 2019
@ghost ghost removed the in progress label Feb 1, 2019
@delete-merged-branch delete-merged-branch Bot deleted the consolidate branch February 1, 2019 23:45
@amelchio
Copy link
Copy Markdown
Contributor

amelchio commented Feb 2, 2019

What is happening here? I currently have no idea, should I recommend one or the other setup for new contributors?

@balloob balloob mentioned this pull request Feb 2, 2019
3 tasks
@balloob
Copy link
Copy Markdown
Member Author

balloob commented Feb 2, 2019

Follow up on home-assistant/architecture#124 and #19948

The future is lifx/light.py

@balloob
Copy link
Copy Markdown
Member Author

balloob commented Feb 2, 2019

(this is already live in 0.86 btw)

@amelchio
Copy link
Copy Markdown
Contributor

amelchio commented Feb 2, 2019

I understand that. I didn’t understand the selection of components though.

Now I see that you updated the description to mention that this was just an easy way to get started. Thanks.

@balloob
Copy link
Copy Markdown
Member Author

balloob commented Feb 2, 2019

@amelchio oops, I updated the description as a response to your comment but forgot to mention that.

@balloob balloob mentioned this pull request Feb 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants