Skip to content

Fixes an issue with OpenUV config import failing#17831

Merged
bachya merged 4 commits intohome-assistant:devfrom
bachya:fix-17830
Oct 27, 2018
Merged

Fixes an issue with OpenUV config import failing#17831
bachya merged 4 commits intohome-assistant:devfrom
bachya:fix-17830

Conversation

@bachya
Copy link
Copy Markdown
Contributor

@bachya bachya commented Oct 26, 2018

Description:

Fixes an issue where OpenUV would fail in 0.81 when it was defined in configuration.yaml without specific latitude/longitude/elevation (i.e., relying on the default HASS latitude/longitude/elevation):

  1. Config data is imported from configuration.yaml.
  2. Default latitude/longitude/elevation doesn't populate properly.
  3. Subsequent API calls fail.

In addition to fixing the bug, this PR makes it so that the latitude/longitude/elevation aren't stored in the config entry unless they are explicitly provided; if the HASS latitude/longitude/elevation ever changes, users shouldn't have to reconfigure this flow.

Until this is pushed out, the issue can be fixed by deleting and re-creating the OpenUV config entry (note that this will have to occur each time HASS restarts). @balloob Given this, would love to have this fix in 0.81.1.

Breaking Change: It's possible that users of OpenUV may have to delete and recreate the config entry.

Related issue (if applicable): fixes #17830

Pull request in home-assistant.io with documentation (if applicable): N/A

Example entry for configuration.yaml (if applicable):

openuv:
  api_key: !secret openuv_api_key

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

@bachya bachya added this to the 0.81.1 milestone Oct 26, 2018
@bachya bachya self-assigned this Oct 26, 2018
@ghost ghost added the in progress label Oct 26, 2018
@bachya bachya requested a review from MartinHjelmare October 26, 2018 22:31
@bachya
Copy link
Copy Markdown
Contributor Author

bachya commented Oct 26, 2018

@MartinHjelmare Would love your eyes on this given our conversation on the last one. Having the defaults as part of the config entry schema didn't cover a case, which caused this issue. Thoughts on my suggested route forward?

@bachya bachya removed the request for review from MartinHjelmare October 27, 2018 01:13
@bachya bachya changed the title Fixes an issue with OpenUV config import failing WIP: Fixes an issue with OpenUV config import failing Oct 27, 2018
@bachya bachya changed the title WIP: Fixes an issue with OpenUV config import failing Fixes an issue with OpenUV config import failing Oct 27, 2018
@bachya bachya requested a review from MartinHjelmare October 27, 2018 02:56
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.

What was the problem?

return await self._show_form({CONF_API_KEY: 'invalid_api_key'})

if user_input.get(CONF_LATITUDE):
user_input[CONF_LATITUDE] = user_input[CONF_LATITUDE]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand this.

CONF_SCAN_INTERVAL: conf[CONF_SCAN_INTERVAL],
}

if conf.get(CONF_LATITUDE):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if CONF_LATITUDE in conf:

@ghost ghost assigned balloob Oct 27, 2018
Copy link
Copy Markdown

@houndci-bot houndci-bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

Traceback (most recent call last):
Traceback (most recent call last):
  File "/home/linters/.local/bin/flake8", line 7, in 
    from flake8.main.cli import main
ModuleNotFoundError: No module named 'flake8'

Copy link
Copy Markdown

@houndci-bot houndci-bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

Traceback (most recent call last):
Traceback (most recent call last):
  File "/home/linters/.local/bin/flake8", line 7, in 
    from flake8.main.cli import main
ModuleNotFoundError: No module named 'flake8'

@balloob
Copy link
Copy Markdown
Member

balloob commented Oct 27, 2018

I've addressed your comments, waiting for tests to pass.

@bachya
Copy link
Copy Markdown
Contributor Author

bachya commented Oct 27, 2018

@MartinHjelmare See #17830 for what the issue was.

@balloob Thanks for the assistance. Since tests are passing, I'm going to get this off our plate.

@bachya bachya merged commit a22aad5 into home-assistant:dev Oct 27, 2018
@ghost ghost removed the in progress label Oct 27, 2018
@MartinHjelmare
Copy link
Copy Markdown
Member

It doesn't explain why the defaults in the form didn't work. Do you know?

@bachya
Copy link
Copy Markdown
Contributor Author

bachya commented Oct 27, 2018

The defaults didn’t work when you were importing configuration from configuration.yaml. If the openuv section of configuration.yaml didn’t specify a latitude and longitude, for example, the import step in the config flow didn’t attach the schema’s default (HASS latitude and longitude). The defaults only seemed to apply when somebody configured the config flow from scratch.

@MartinHjelmare
Copy link
Copy Markdown
Member

Thanks! I see it now.

balloob pushed a commit that referenced this pull request Oct 27, 2018
* Fixes an issue with OpenUV config import failing

* Update

* Update __init__.py

* Update config_flow.py
@balloob balloob mentioned this pull request Oct 27, 2018
@exxamalte
Copy link
Copy Markdown
Contributor

exxamalte commented Oct 28, 2018

I'm confused. My openuv configuration was working prior to 0.81.0/.1 as expected.
After I upgraded to 0.81.0 I had 2 entries for OpenUV in the "Integrations" section - one with the 4 entities I had before and one saying "None, None" without entities. Entities were updating once after a restart and then I saw failing updates, Status 500 errors, etc.
After I upgraded to 0.81.1 and without changing my configuration file, I was now welcomed with "New devices discovered" which turned out to be OpenUV. A click on "Configure" starts with asking me for my API key.
Does that mean that OpenUV does not support being configured via file anymore at all?

@home-assistant home-assistant locked as resolved and limited conversation to collaborators Oct 28, 2018
@balloob
Copy link
Copy Markdown
Member

balloob commented Oct 28, 2018

@exxamalte solved PRs are not the place for this.

@bachya bachya deleted the fix-17830 branch October 28, 2018 16:02
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.

OpenUV throws 500 errors in 0.81

6 participants