Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@RobBie1221
Copy link
Contributor

Proposed change

Import integration level configuration for influxdb integration into ConfigEntry. Implement load/unload entry functions. Platform level setup will be dealt with in a different PR, as well as full config/option flow.

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

  • This PR fixes or closes issue: fixes #
  • 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
  • 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
Copy link

home-assistant bot commented Jan 2, 2025

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

Code owner commands

Code owners of influxdb 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 influxdb 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.

@RobBie1221 RobBie1221 force-pushed the influxdb_configentry branch from 2c5fd6b to 057e22a Compare January 2, 2025 15:35
Copy link
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

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

Hey @RobBie1221, I've seen your name around! If you feel like it, feel free to drop me a message on Discord :)

@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft January 17, 2025 10:25
@RobBie1221 RobBie1221 force-pushed the influxdb_configentry branch from b9d52c6 to c61519e Compare January 26, 2025 19:23
@RobBie1221 RobBie1221 marked this pull request as ready for review January 26, 2025 19:34
@home-assistant home-assistant bot requested a review from joostlek January 26, 2025 19:34
@RobBie1221
Copy link
Contributor Author

RobBie1221 commented Jan 26, 2025

I addressed review comments. I also made a change to creating the config entry, I split the data and options (data that we later want to change via option flow is now stored in the options part of the config entry).

@RobBie1221 RobBie1221 force-pushed the influxdb_configentry branch 2 times, most recently from 9584ba0 to d85e04c Compare February 1, 2025 11:21
@home-assistant home-assistant bot marked this pull request as draft February 25, 2025 13:40
@RobBie1221 RobBie1221 force-pushed the influxdb_configentry branch from a25c1be to fe5a8c0 Compare April 12, 2025 07:32
@RobBie1221 RobBie1221 force-pushed the influxdb_configentry branch from 95640b2 to 46b27d5 Compare May 15, 2025 17:12
@RobBie1221 RobBie1221 marked this pull request as ready for review May 16, 2025 19:54
@home-assistant home-assistant bot requested a review from joostlek May 16, 2025 19:54
@RobBie1221
Copy link
Contributor Author

I added the user_step as requested. The import is now one-time. New entries can be made via UI. The options are still fully in yaml.

Let me know if we want to push this directly to dev or to an intermediary branch. I did not do docs yet, if we push directly to dev, docs need to be updated.

@home-assistant home-assistant bot marked this pull request as draft June 23, 2025 15:55
@RobBie1221 RobBie1221 force-pushed the influxdb_configentry branch from 85f08c7 to e10e1f8 Compare June 24, 2025 19:45
@RobBie1221 RobBie1221 marked this pull request as ready for review June 24, 2025 19:46
@home-assistant home-assistant bot requested a review from joostlek June 24, 2025 19:46
@github-actions
Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

@github-actions github-actions bot added the stale label Aug 23, 2025
@RobBie1221
Copy link
Contributor Author

Not stale

@github-actions github-actions bot removed the stale label Aug 24, 2025
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.

I think this looks good, some comments though

Comment on lines +208 to +210
def _generate_event_to_json(
conf: dict,
) -> Callable[[Event], dict[str, Any] | None]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def _generate_event_to_json(
conf: dict,
) -> Callable[[Event], dict[str, Any] | None]:
def _generate_event_to_json(conf: dict) -> Callable[[Event], dict[str, Any] | None]:

hass_config = await conf_util.async_hass_config_yaml(hass)

influx_yaml = CONFIG_SCHEMA(hass_config).get(DOMAIN, {})
default_yaml: dict[str, Any] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
default_yaml: dict[str, Any] = {
default_filter_settings: dict[str, Any] = {

Comment on lines +524 to +525
CONF_INCLUDE: influx_yaml.get(CONF_INCLUDE, default_yaml),
CONF_EXCLUDE: influx_yaml.get(CONF_EXCLUDE, default_yaml),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
CONF_INCLUDE: influx_yaml.get(CONF_INCLUDE, default_yaml),
CONF_EXCLUDE: influx_yaml.get(CONF_EXCLUDE, default_yaml),
CONF_INCLUDE: influx_yaml.get(CONF_INCLUDE, default_filter_settings),
CONF_EXCLUDE: influx_yaml.get(CONF_EXCLUDE, default_filter_settings),

"""Unload a config entry."""
influx_thread = entry.runtime_data

influx_thread.shutdown()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not async safe, wrap it in an executor, and await the executor job from an asyncio.timeout context manager to avoid hanging this task forever.

Comment on lines +201 to +203
return self.async_show_form(
step_id="configure_v1", data_schema=schema, errors=errors
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use add_suggested_values_to_schema so the user doesn't need to fill in the entire form again

Comment on lines +231 to +233
return self.async_show_form(
step_id="configure_v2", data_schema=schema, errors=errors
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use add_suggested_values_to_schema so the user doesn't need to fill in the entire form again


conf_entries = hass.config_entries.async_entries(DOMAIN)

assert len(conf_entries) == 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this meant to test that import is working?

Copy link
Contributor

Choose a reason for hiding this comment

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

Add a test showing we won't create a second config entry if a config entry already exists and there is influxdb configuration in yaml.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should ask the user to remove configuration keys which are imported from yaml.
For example like this:

CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN: vol.All(
            cv.deprecated(CONF_API_VERSION),  # Deprecated in HA Core 2025.10
            cv.deprecated(CONF_HOST),   # Deprecated in HA Core 2025.10
            ...
            INFLUX_SCHEMA,
        )
    },
    extra=vol.ALLOW_EXTRA,
)

@joostlek joostlek marked this pull request as draft September 30, 2025 13:54
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