Skip to content

Neato config flow#26579

Merged
MartinHjelmare merged 44 commits into
home-assistant:devfrom
Santobert:neato_config_flow
Oct 6, 2019
Merged

Neato config flow#26579
MartinHjelmare merged 44 commits into
home-assistant:devfrom
Santobert:neato_config_flow

Conversation

@Santobert
Copy link
Copy Markdown
Member

@Santobert Santobert commented Sep 11, 2019

Breaking Change:

Nothing's breaking. Neato can still be configured via configuration.yaml.
Changes in configuration.yaml will be noticed and the resulting configuration entry will be updated.

Description:

This PR adds config_flow to the neato integration.
Pending tasks:

  • complete the workflow
  • update documentation
  • add tests

Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#10356

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

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

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

  • The manifest file has all fields filled out correctly. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

If the code does not interact with devices:

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

@Santobert
Copy link
Copy Markdown
Member Author

I'm not entirely sure what I'm doing, so please give me hints if I'm obviously doing something wrong 🙈

@dshokouhi
Copy link
Copy Markdown
Member

ha we were both working on this? lol were you looking at the changes I had in my branch?

@Santobert
Copy link
Copy Markdown
Member Author

@dshokouhi Oh no. I wasn't aware that you were working on it. I don't know your branch either. How far are you? Does it make sense that we work together?

@dshokouhi
Copy link
Copy Markdown
Member

@Santobert I got ti to work on importing config and setting up the flow. The tests I am not sure of and I think there may be somethings missing. Feel free to snoop around here :)

https://github.com/dshokouhi/hass-neato-custom-component/tree/config_flow

@Santobert
Copy link
Copy Markdown
Member Author

Santobert commented Sep 11, 2019

@dshokouhi Great, Thank you. May I ask why do you work on a custom component instead of the official integration?

@dshokouhi
Copy link
Copy Markdown
Member

I always do custom components first to test with end users before I update to HA. I did this for testing neato fixes in the past so just keeping up the habit :)

Copy link
Copy Markdown
Member

@dshokouhi dshokouhi left a comment

Choose a reason for hiding this comment

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

Left some comments on a few things to address. One thing I am not sure about is if the components need to be updated for async_setup_platform and async_setup_entry. The below would replace line 14-21. Again not sure if its needed as the code works when I test it.

Here is an example from my camera.py file:

def async_setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Neato Camera."""
    pass
    
    
async def async_setup_entry(hass, entry, async_add_entities):
    """Setup the Neato camera using config entry."""
    dev = []
    for robot in hass.data[NEATO_ROBOTS]:
        if 'maps' in robot.traits:
            dev.append(NeatoCleaningMap(hass, robot))
    _LOGGER.debug("Adding robots for cleaning maps %s", dev)
    async_add_entities(dev, True)

Comment thread homeassistant/components/neato/.translations/en.json
Comment thread homeassistant/components/neato/__init__.py Outdated
Comment thread homeassistant/components/neato/__init__.py Outdated
Comment thread homeassistant/components/neato/config_flow.py Outdated
Comment thread homeassistant/components/neato/config_flow.py Outdated
Comment thread homeassistant/components/neato/strings.json
Copy link
Copy Markdown
Member

@dshokouhi dshokouhi left a comment

Choose a reason for hiding this comment

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

Looking a lot better now the form loads without the translation error too :) Couple more comments and I think it should be ready for the real review once CI passes and it needs tests for the config flow and a docs PR

Comment thread homeassistant/components/neato/__init__.py Outdated
Comment thread homeassistant/components/neato/.translations/en.json Outdated
Comment thread homeassistant/components/neato/config_flow.py Outdated
Comment thread homeassistant/components/neato/config_flow.py Outdated
Comment thread homeassistant/components/neato/__init__.py Outdated
Copy link
Copy Markdown
Member

@dshokouhi dshokouhi left a comment

Choose a reason for hiding this comment

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

Just need to remove some of the changes as its out of scope for the config flow PR, we should fix these things in a subsequent PR. Its best to break things down because we already have a lot of changes.

Comment thread homeassistant/components/neato/switch.py Outdated
Comment thread homeassistant/components/neato/camera.py Outdated
Comment thread homeassistant/components/neato/camera.py Outdated
@Santobert
Copy link
Copy Markdown
Member Author

Santobert commented Sep 13, 2019

@frenck I've updated the documentation here:
home-assistant/home-assistant.io#10356

I think we can remove that label now.

@Santobert Santobert changed the title WIP: Neato config flow Neato config flow Sep 13, 2019
Copy link
Copy Markdown
Member

@dshokouhi dshokouhi left a comment

Choose a reason for hiding this comment

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

Looks good to me now, I think its ready for review from a member with merge rights now :)

Comment thread homeassistant/components/neato/switch.py
Comment thread homeassistant/components/neato/__init__.py Outdated
Comment thread homeassistant/components/neato/__init__.py Outdated
Comment thread homeassistant/components/neato/camera.py Outdated
@Santobert
Copy link
Copy Markdown
Member Author

@balloob @MartinHjelmare I did some research and found that the life360 integration also deletes and recreates the outdated entries.
https://github.com/home-assistant/home-assistant/blob/2307cac942d4f5b1cef5bdf4a11d9baa5160791c/homeassistant/components/life360/__init__.py#L187

Personally, I think it's perfectly fine to do this. If a user changes things in configuration.yaml, he should expect that previous changes from the UI will be lost.

@MartinHjelmare MartinHjelmare added the second-opinion-wanted Add this label when a reviewer needs a second opinion from another member. label Oct 3, 2019
@balloob
Copy link
Copy Markdown
Member

balloob commented Oct 5, 2019

Not only will you lose changes from the UI, you also lose your entity ID customizations. This means that all your automations break, scripts break, scenes break. I can guarantee you that peope will be pissed ;)

@MartinHjelmare MartinHjelmare removed the second-opinion-wanted Add this label when a reviewer needs a second opinion from another member. label Oct 6, 2019
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Great!

@MartinHjelmare
Copy link
Copy Markdown
Member

Can be merged when build passes.

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Sorry, noticed the coverage wasn't 100%.

Comment thread homeassistant/components/neato/config_flow.py Outdated
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Good!

@Santobert
Copy link
Copy Markdown
Member Author

🎉

@MartinHjelmare MartinHjelmare merged commit bd6bbcd into home-assistant:dev Oct 6, 2019
@Santobert Santobert deleted the neato_config_flow branch October 6, 2019 11:06
@Santobert Santobert restored the neato_config_flow branch October 6, 2019 11:19
@Santobert Santobert deleted the neato_config_flow branch October 6, 2019 13:06
@lock lock Bot locked and limited conversation to collaborators Oct 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants