Skip to content

Set station name as device name in GIOS#155762

Merged
bieniu merged 9 commits into
home-assistant:devfrom
mik-laj:gios-fix-5
Dec 15, 2025
Merged

Set station name as device name in GIOS#155762
bieniu merged 9 commits into
home-assistant:devfrom
mik-laj:gios-fix-5

Conversation

@mik-laj
Copy link
Copy Markdown
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
Copy Markdown
Contributor

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
Copy link
Copy Markdown
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

Comment thread homeassistant/components/gios/sensor.py Outdated
},
"device": {
"station": {
"name": "Station {station_name}"
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread homeassistant/components/gios/sensor.py Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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
frenck
frenck previously requested changes Nov 23, 2025
Comment thread homeassistant/components/gios/config_flow.py
Comment thread homeassistant/components/gios/coordinator.py Outdated
@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
Comment thread homeassistant/components/gios/coordinator.py Outdated
Comment thread homeassistant/components/gios/coordinator.py Outdated
Comment thread homeassistant/components/gios/coordinator.py Outdated
Comment thread homeassistant/components/gios/coordinator.py Outdated
Comment thread homeassistant/components/gios/config_flow.py Outdated
@home-assistant home-assistant Bot marked this pull request as draft November 24, 2025 20:46
@bieniu
Copy link
Copy Markdown
Member

bieniu commented Nov 24, 2025

Documentation should be updated

obraz

@mik-laj
Copy link
Copy Markdown
Contributor Author

mik-laj commented Nov 24, 2025

Documentation should be updated

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

Comment thread homeassistant/components/gios/config_flow.py
Comment thread homeassistant/components/gios/coordinator.py Outdated
Comment thread tests/components/gios/snapshots/test_diagnostics.ambr
@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
@mik-laj
Copy link
Copy Markdown
Contributor Author

mik-laj commented Nov 28, 2025

The integration still have 100% coverage.

============================================================ tests coverage ============================================================
___________________________________________ coverage: platform linux, python 3.13.9-final-0 ____________________________________________

Name                                             Stmts   Miss  Cover   Missing
------------------------------------------------------------------------------
homeassistant/components/gios/__init__.py           43      0   100%
homeassistant/components/gios/config_flow.py        37      0   100%
homeassistant/components/gios/const.py              20      0   100%
homeassistant/components/gios/coordinator.py        33      0   100%
homeassistant/components/gios/diagnostics.py         8      0   100%
homeassistant/components/gios/sensor.py             56      0   100%
homeassistant/components/gios/system_health.py      10      0   100%
------------------------------------------------------------------------------
TOTAL                                              207      0   100%
------------------------------------------------------- snapshot report summary --------------------------------------------------------
31 snapshots passed.

Results (1.46s):
      20 passed

Copy link
Copy Markdown
Member

@bieniu bieniu left a comment

Choose a reason for hiding this comment

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

Looks good, thanks @mik-laj

The coverage reduction reported by codecov is not related to gios integration.

@bieniu
Copy link
Copy Markdown
Member

bieniu commented Dec 15, 2025

Requested changes have been addressed, I'm dismissing previous reviews.

@bieniu bieniu dismissed stale reviews from joostlek and frenck December 15, 2025 13:54

Tests pass

@bieniu bieniu merged commit ef0add1 into home-assistant:dev Dec 15, 2025
36 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants