Set station name as device name in GIOS#155741
Conversation
|
Hey there @bieniu, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
|
@bieniu I'm wondering if it would be worth moving the code for other migrations to the core/homeassistant/components/gios/__init__.py Lines 31 to 41 in 1bba819 |
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the GIOS integration from user-configurable device names to automatically using station names from the API. The config entry is bumped from version 1 to version 2, with a migration path that preserves user-customized names.
Key changes:
- Removes the
CONF_NAMEfield from config flow and config entry data - Implements device name translation using the station name from the API
- Adds config entry migration from v1 to v2 that preserves user-provided names in
name_by_user
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| homeassistant/components/gios/init.py | Adds async_migrate_entry function to migrate v1 config entries to v2, moving user-provided names to device.name_by_user |
| homeassistant/components/gios/config_flow.py | Removes CONF_NAME field from config flow and bumps VERSION to 2 |
| homeassistant/components/gios/sensor.py | Updates GiosSensor to use translatable device names from API instead of CONF_NAME |
| homeassistant/components/gios/strings.json | Adds device translation template for station names |
| tests/components/gios/init.py | Updates test config entries to version 2 without CONF_NAME |
| tests/components/gios/test_config_flow.py | Removes CONF_NAME from test config |
| tests/components/gios/test_init.py | Adds migration test with parametrized scenarios and updates existing tests to version 2 |
| tests/components/gios/test_sensor.py | Updates entity IDs in tests to match new naming pattern |
| tests/components/gios/snapshots/test_sensor.ambr | Updates snapshot entity IDs and friendly names |
| tests/components/gios/snapshots/test_diagnostics.ambr | Updates diagnostic snapshot to version 2 without CONF_NAME |
| "homeassistant.components.gios.coordinator.Gios._get_indexes", | ||
| return_value=indexes, | ||
| ), | ||
| ): |
There was a problem hiding this comment.
I'd like to avoid code duplication here, but I'll take care of that during the test refactor. See:
#155603 (comment)
| await init_integration(hass) | ||
|
|
||
| state = hass.states.get("sensor.home_pm2_5") | ||
| state = hass.states.get("sensor.station_test_name_1_pm2_5") |
There was a problem hiding this comment.
We have a lot of changes in entity Ids in this PR, but that's okay because we don't change unique_id, so HA can still links entities
| """Config flow for GIOS.""" | ||
|
|
||
| VERSION = 1 | ||
| VERSION = 2 |
There was a problem hiding this comment.
As we discussed, I don't like the idea of incrementing the version for such a minor change and preventing users from downgrading if they need to. I'd try increasing only the minor_version.
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Breaking change
Proposed change
Previously, users could set custom device name using the
Namefield during configuration. This violates the guidelines, as the device name should be determined automatically and, if needed, the user can change it from the interface.It is not breaking change, as we have migration that copy user-defined name from config entry to field
name_by_userin device, but it is a forward-incompatible change.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: