Skip to content

Conversation

@mik-laj
Copy link
Contributor

@mik-laj mik-laj commented Nov 3, 2025

Breaking change

Proposed change

This change supersedes: #155741

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

  • I understand the code I am submitting and can explain how it works.
  • 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.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

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 Nov 3, 2025

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

Code owner commands

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

@mik-laj mik-laj force-pushed the gios-fix-5 branch 2 times, most recently from c05e0af to 1156200 Compare November 4, 2025 07:09
@mik-laj mik-laj marked this pull request as ready for review November 16, 2025 20:04
@mik-laj mik-laj requested a review from bieniu as a code owner November 16, 2025 20:04
Copilot AI review requested due to automatic review settings November 16, 2025 20:04
Copilot finished reviewing on behalf of mik-laj November 16, 2025 20:05
Copy link
Contributor

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 removes the user-configurable device name from the GIOS integration config flow and instead uses the station name from the GIOS API. For backward compatibility, existing configurations with a custom name will continue to use it, while new setups will use the station name with translation support.

Key changes:

  • Config flow no longer allows users to set custom device names
  • Device names are now derived from the station name via API (with translation support for new configs)
  • Backward compatibility maintained for existing configs with CONF_NAME in their data

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
homeassistant/components/gios/config_flow.py Removed CONF_NAME import and name field from config flow schema
homeassistant/components/gios/sensor.py Updated device info creation to use station name with translation support, while maintaining backward compatibility for existing configs with custom names
homeassistant/components/gios/strings.json Added device translation key for station name formatting
tests/components/gios/conftest.py Updated mock config entry to remove CONF_NAME from test data
tests/components/gios/test_config_flow.py Removed CONF_NAME import and from test config data
tests/components/gios/test_init.py Added test for device naming behavior based on config data (with/without CONF_NAME)
tests/components/gios/test_sensor.py Updated entity IDs in tests to reflect new naming based on station name
tests/components/gios/snapshots/*.ambr Updated snapshots to reflect new entity naming scheme
Comments suppressed due to low confidence (1)

homeassistant/components/gios/sensor.py:18

  • The CONF_NAME import is still present but is now only used with .get() method on line 187. Since this is for backward compatibility with existing config entries, the import is actually still needed and should remain. However, it would be clearer to add a comment explaining this is kept for backward compatibility with existing configurations.
from homeassistant.const import CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONF_NAME

},
"device": {
"station": {
"name": "Station {station_name}"
Copy link
Member

Choose a reason for hiding this comment

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

TBH I see no reason to add the word "Station" to the device name. Other integrations simply use the name/location of the measurement/weather station.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the prefix.

else:
device_info_kwargs["translation_key"] = "station"
device_info_kwargs["translation_placeholders"] = {"station_name": station_name}
self._attr_device_info = DeviceInfo(**device_info_kwargs)
Copy link
Member

Choose a reason for hiding this comment

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

I would move the creation of device info to the coordinator module:

self.device_info = DeviceInfo(
    entry_type=DeviceEntryType.SERVICE,
    identifiers={(DOMAIN, str(gios.station_id))},
    manufacturer=MANUFACTURER,
    name=config_entry.data.get(CONF_NAME) or gios.station_name,
    configuration_url=URL.format(station_id=gios.station_id),
)

and only add here self._attr_device_info = coordinator.device_info

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved device info to coordinator.

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.

Tests are failing

@home-assistant home-assistant bot marked this pull request as draft November 21, 2025 23:08
@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.

@mik-laj mik-laj marked this pull request as ready for review November 23, 2025 18:39
@home-assistant home-assistant bot requested a review from joostlek November 23, 2025 18:39
mode=SelectSelectorMode.DROPDOWN,
),
),
vol.Optional(CONF_NAME, default=self.hass.config.location_name): str,
Copy link
Member

Choose a reason for hiding this comment

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

Name was removed here, but not removed from the translations file (string.json), which still needs to be cleaned up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Removed.

)

station_id = gios.station_id
assert station_id is not None
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't be using assert in production code. In general the use means we either have a logic error (or could improve logic) or there might be a typing issue/improvement that could result the need for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have this check here because the API client can be initialized with an optional station_id parameter, but in our case, the client is always initialized with a specific station ID. The client without a station ID is used in config_flow to retrieve the list of available stations.
https://github.com/bieniu/gios/blob/871ea652a27216f87645a0161b823f500cd7a944/gios/__init__.py#L51
Here is Gios client initialization code:

gios = await Gios.create(websession, station_id)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added if TYPE_CHECKING to avoid this code in production code.

@home-assistant home-assistant bot marked this pull request as draft November 23, 2025 19:42
@mik-laj mik-laj marked this pull request as ready for review November 23, 2025 22:28
@home-assistant home-assistant bot requested a review from frenck November 23, 2025 22:28
@home-assistant home-assistant bot marked this pull request as draft November 24, 2025 20:46
@bieniu
Copy link
Member

bieniu commented Nov 24, 2025

Documentation should be updated

obraz

@mik-laj
Copy link
Contributor Author

mik-laj commented Nov 24, 2025

Documentation should be updated

Here is PR: home-assistant/home-assistant.io#41588

dict({
'config_entry': dict({
'data': dict({
'name': 'Home',
Copy link
Member

Choose a reason for hiding this comment

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

name should remain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Member

Choose a reason for hiding this comment

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

Please align the config entry for tests; sometimes the name is there, sometimes it's not. And I think we should leave the station name as Home to prove that the "old" tests pass with the new code.

One more thing... please, if you think the PR is ready, click Ready for review button. Without that, it's unclear whether to look at the changes or wait because you're still working.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2025-11-26 at 17 34 04 We don't have a `name` field in this object and this is expected as now the user cannot pass a `name` field during integration setup. The name is automatically generated as it is core of this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing that out. I appreciate the reminder. I was planning to take one more pass over everything before marking the PR as ready for review.

Also, thanks for being so consistent and thorough with the reviews.

@mik-laj mik-laj marked this pull request as ready for review November 26, 2025 17:03
@home-assistant home-assistant bot requested a review from bieniu November 26, 2025 17:03
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