-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
Import Influxdb integration level configuration into ConfigEntry #134463
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
base: dev
Are you sure you want to change the base?
Conversation
|
Hey there @mdegat01, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
2c5fd6b to
057e22a
Compare
There was a problem hiding this 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 :)
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
b9d52c6 to
c61519e
Compare
|
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). |
9584ba0 to
d85e04c
Compare
a25c1be to
fe5a8c0
Compare
95640b2 to
46b27d5
Compare
|
I added the 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. |
85f08c7 to
e10e1f8
Compare
|
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. |
|
Not stale |
There was a problem hiding this 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
| def _generate_event_to_json( | ||
| conf: dict, | ||
| ) -> Callable[[Event], dict[str, Any] | None]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| default_yaml: dict[str, Any] = { | |
| default_filter_settings: dict[str, Any] = { |
| CONF_INCLUDE: influx_yaml.get(CONF_INCLUDE, default_yaml), | ||
| CONF_EXCLUDE: influx_yaml.get(CONF_EXCLUDE, default_yaml), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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() |
There was a problem hiding this comment.
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.
| return self.async_show_form( | ||
| step_id="configure_v1", data_schema=schema, errors=errors | ||
| ) |
There was a problem hiding this comment.
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
| return self.async_show_form( | ||
| step_id="configure_v2", data_schema=schema, errors=errors | ||
| ) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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,
)
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
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: