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

Add vicare config flow #56691

Merged
merged 3 commits into from Nov 22, 2021
Merged

Conversation

oischinger
Copy link
Contributor

@oischinger oischinger commented Sep 26, 2021

Proposed change

Adds Config flow / YAML deprecation for Vicare

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Config flow / YAML deprecation

  • Support discovery via MAC address

  • Support import of YAML config

  • Switch to ConfigEntry, get rid of platform setup

  • This PR fixes or closes issue:

  • This PR is related to issue:

  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@MartinHjelmare MartinHjelmare changed the title Configuration via UI Add vicare config flow Sep 26, 2021
@MartinHjelmare MartinHjelmare added this to By Code Owner in Dev Sep 27, 2021
@emontnemery
Copy link
Contributor

We require tests for config flows, please add that.

@oischinger
Copy link
Contributor Author

@emontnemery I added some config flow tests which lead me to also handle authentication erros ;)

Sorry for the force-push but the original commit was only modified to be rebased.

Also another update to latest PyVicare was necessary due to some REST API changes.

@emontnemery
Copy link
Contributor

Do the breaking changes in PyViCare have any impact on the Home Assistant vicare integration?

@emontnemery
Copy link
Contributor

There are still failing tests, please fix them.

@oischinger
Copy link
Contributor Author

Do the breaking changes in PyViCare have any impact on the Home Assistant vicare integration?

Yes, instead of having a single "Device" the API now provides a device with multiple circuits and burners.

This allowed the removal of the CONF_CIRCUIT_ID parameter since the integration can now iterate over the data provided by all circuits and create all possible sensors.

This could have been done in a separate PR but it would then involve future changes to the configuration schema. I guess we should avoid that.

@oischinger
Copy link
Contributor Author

There are still failing tests, please fix them.

Fixed. Sorry for the delay.

@oischinger
Copy link
Contributor Author

Seems Viessmann is changing things on their API and we won't be able to fix that without the latest PyViCare release (#57304)

@oischinger
Copy link
Contributor Author

@emontnemery How should we move on. Is this PR ok for a review or should we split it up into a library update PR and a config flow PR?
The problem with the latter is that the config flow PR would still need to include the changes for multiple circuits/burners. So it might not be much smaller.

@emontnemery
Copy link
Contributor

@oischinger let's split the PR in two, one adjusting for the new library and one for config flow + multiple burners

@oischinger oischinger mentioned this pull request Oct 14, 2021
22 tasks
@oischinger
Copy link
Contributor Author

PR for the library update created: #57700

oischinger added a commit to oischinger/home-assistant.io that referenced this pull request Oct 17, 2021
With PyViCare 2.8.1 a breaking change was introduced which required
changes on sensor and binary_sensor platforms. See Home Assistant Core
PR home-assistant/core#57700

As an intermediate step the circuit ID config option is still present
but ignored. Now all circuits are supported at the same time.

As a 2nd step the option will be removed completely since the integration
will introduce setup via the UI (see this PR:
home-assistant/core#56691 )
@oischinger
Copy link
Contributor Author

@emontnemery
I've split out the library PR into #57700
How should I proceed with this PR: It depends on #57700 , should I

  1. close it and reopen it once the other PR is merged?
  2. just rebase it on top of Update PyVicare to 2.13.0 #57700

I'm wondering because I doubt that it's good to have these sort of "stale" PRs around that cannot really be reviewed before the other PR isn't merged.

@emontnemery
Copy link
Contributor

You can mark this PR as "draft" and add a note in the PR-description that it will be updated once #57700 is merged 👍

@oischinger oischinger marked this pull request as draft October 18, 2021 18:10
@oischinger oischinger marked this pull request as ready for review October 25, 2021 18:29
@oischinger
Copy link
Contributor Author

un-drafting this PR.
I force-pushed the branch to rebase and get rid of all unrelated changes

@oischinger oischinger marked this pull request as draft October 25, 2021 20:36
@oischinger
Copy link
Contributor Author

Had to convert to draft again. Needs some more work

@oischinger oischinger force-pushed the vicare_config_flow branch 3 times, most recently from 019cab7 to ba8e298 Compare October 26, 2021 18:28
@oischinger oischinger marked this pull request as ready for review October 27, 2021 10:26
@oischinger
Copy link
Contributor Author

Finally I would say it's ready for review ;)

homeassistant/components/vicare/__init__.py Show resolved Hide resolved
homeassistant/components/vicare/__init__.py Show resolved Hide resolved
Comment on lines 58 to 60
vol.Optional(
CONF_SCAN_INTERVAL, default=DEFAULT_SCAN_INTERVAL
): vol.All(cv.time_period, lambda value: value.total_seconds()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we tweak the config schema when moving to a config flow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well this change is not really needed since we will delete this at a later point when yaml is officially removed from this integration.
But I still need the CONFIG_SCHEMA in init.py or are you saying I could get rid of the complete section now?

Copy link
Contributor

Choose a reason for hiding this comment

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

The CONFIG_SCHEMA is needed until the migration step is removed, I just mean there's no value added by modifying it since it's deprecated.

homeassistant/components/vicare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/vicare/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/vicare/binary_sensor.py Outdated Show resolved Hide resolved
oischinger added a commit to oischinger/ha_vicare that referenced this pull request Nov 1, 2021
This includes the current HA Core dev branch plus the vicare_config_flow PR:
home-assistant/core#56691
Config flow / YAML deprecation
- Support discovery via MAC address
- Support import of YAML config
- Switch to ConfigEntry, get rid of platform setup
@oischinger
Copy link
Contributor Author

@emontnemery
Could you please review again? Thanks alot!

Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @oischinger 👍

Dev automation moved this from By Code Owner to Reviewer approved Nov 22, 2021
@emontnemery emontnemery merged commit 38b976e into home-assistant:dev Nov 22, 2021
Dev automation moved this from Reviewer approved to Done Nov 22, 2021
@frenck
Copy link
Member

frenck commented Nov 22, 2021

I think this PR is missing a documentation PR (and should therefore not have been merged).

@oischinger Can you make sure a documentation PR is created?

@emontnemery
Copy link
Contributor

emontnemery commented Nov 22, 2021

Oops, I missed that 🤦
@oischinger you need to update the "configuration" section; remove documentation of manual configuration and add the template for config flow configuration.

@oischinger oischinger deleted the vicare_config_flow branch November 22, 2021 16:59
@github-actions github-actions bot locked and limited conversation to collaborators Nov 23, 2021
Copy link
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.

Please address the comments in a new PR. Thanks!

tests/components/vicare/test_config_flow.py Show resolved Hide resolved
homeassistant/components/vicare/__init__.py Show resolved Hide resolved
@home-assistant home-assistant unlocked this conversation Dec 2, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants