8000 Add config flow to compensation helper by gjohansson-ST · Pull Request #147928 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Add config flow to compensation helper #147928

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

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft

Conversation

gjohansson-ST
Copy link
Member
@gjohansson-ST gjohansson-ST commented Jul 2, 2025

Proposed change

Adds config flow to compensation now when we have a way to provide multiple sets of inputs (extension of ObjectSelector)

New attempt from feedback in #121857

Needs #147929

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)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

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
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format 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.

To help with the load of incoming pull requests:

@home-assistant home-assistant bot added cla-signed config-flow This integration migrates to the UI by adding a config flow core integration: compensation new-feature labels Jul 2, 2025
@home-assistant
Copy link
home-assistant bot commented Jul 2, 2025

Hey there @Petro31, mind taking a look at this pull request as it has been labeled with an integration (compensation) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of compensation can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign compensation Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@Petro31
Copy link
Contributor
Petro31 commented Jul 2, 2025

Heads up, I overhauled a bit of the integration in a separate PR that just got merged. A bit of bad timing! Sorry

@Petro31
Copy link
Contributor
Petro31 commented Jul 2, 2025

If you want, I can assist with this cleanup.

@gjohansson-ST
Copy link
Member Author

No worries, this PR doesn't work anyway as my intention was only to have a working solution for the config flow to start with (with the extension of the `ObjectSelector). I will clean it up once #147929 gets merged in.

Copy link
Contributor
@NoRi2909 NoRi2909 left a comment

Choose a reason for hiding this comment

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

A few quick comments on the strings

@frenck

This comment was marked as duplicate.

@frenck frenck requested a review from Copilot July 3, 2025 19:03
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a UI-driven config flow to the Compensation integration, enabling multiple data point inputs via an ObjectSelector, wiring up entry setup/unload, and updating the manifest.

  • Extend ObjectSelector with serialize() for voluptuous serialization
  • Implement config_flow.py with SchemaConfigFlowHandler and options validation
  • Add async_setup_entry, async_unload_entry, and update listener in __init__.py and sensor.py

Reviewed Changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
helpers/selector.py Allow ObjectSelector to serialize nested Selector instances
components/compensation/strings.json Add translation strings for config and options steps
components/compensation/config_flow.py Define setup and options schemas and flow handler for UI configuration
components/compensation/init.py Refactor setup to support config entries (async_setup_entry)
components/compensation/sensor.py Add async_setup_entry to create sensor from config entry
components/compensation/manifest.json Declare config_flow support and set integration_type
components/compensation/const.py Define PLATFORMS list for entry setup
Comments suppressed due to low confidence (2)

homeassistant/components/compensation/config_flow.py:1

  • Update the module docstring to reflect the Compensation integration rather than "statistics".
"""Config flow for statistics."""

homeassistant/helpers/selector.py:1137

  • The name Required is not imported in this file, which will cause a NameError. Add from typing import Required (or from typing_extensions import Required) at the top.
    selector: Required[Selector | dict]

@gjohansson-ST
Copy link
Member Author

@Petro31 it should now be in a state where I appreciate if you give it a test run that it works as expected.
I will do another review once my dependent PR has merged and we can finalize this.

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.

4 participants
0