Skip to content

Migrate Freebox to has_entity_name and key-based unique IDs#169860

Open
piitaya wants to merge 3 commits intodevfrom
freebox_entity_naming
Open

Migrate Freebox to has_entity_name and key-based unique IDs#169860
piitaya wants to merge 3 commits intodevfrom
freebox_entity_naming

Conversation

@piitaya
Copy link
Copy Markdown
Member

@piitaya piitaya commented May 5, 2026

Proposed change

Adopt _attr_has_entity_name = True across all Freebox entities and switch unique IDs from name-based to key-based. This unlocks the bronze quality scale has-entity-name rule and is a stepping stone for further quality scale work in a follow-up PR.

Static entity names use translation_key with strings in strings.json. Dynamic names (RAID array id, partition label) use translation_placeholders. Temperature probes are special: the unique ID uses the API id (e.g. temp_cpum) for stability, while the displayed name uses the API name (e.g. Température CPU M) since probe names are localized in French and vary per Freebox model.
I will do the translation in lokalise so French users doesn't loose translation when they update.

Existing entities are migrated in at setup, before platform forwarding. Users keep their entity IDs, history, and automations.

Migration map

Platform Old unique ID suffix New unique ID suffix Display name
sensor Freebox download speed rate_down Download speed
sensor Freebox upload speed rate_up Upload speed
sensor Freebox missed calls missed Missed calls
sensor Freebox <probe name> <probe id> API name (e.g. Température CPU M)
button Reboot Freebox reboot Reboot
button Mark calls as read mark_calls_as_read Mark calls as read
switch Freebox WiFi wifi Wi-Fi

All unique IDs are prefixed with the router MAC. Temperature probes preserve the (id, name) pairing returned by the live API.

Display name changes for home accessory entities

Home accessories now display their device name only, with sub-entities (cover removal, battery) explicitly named:

Entity Old display New display
Alarm Système d'alarme Système d'alarme
Camera Caméra entrée Caméra entrée
PIR motion Détecteur Détecteur
DWS door Ouverture porte Ouverture porte
Cover removed Détecteur Couvercle Détecteur Cover
Home accessory battery Télécommande Niveau de batterie Télécommande Battery

The cover removed should use tamper device class but it will be a breaking change so I didn't want to do this in this PR.

Other cleanups in this PR

  • Hardcoded icon= attributes moved to icons.json. The Wi-Fi switch now flips between mdi:wifi and mdi:wifi-off based on state.
  • services.yaml deleted. The reboot service was removed in Remove deprecated freebox reboot service #144303 and the file was left as an empty stub.
  • Renamed _sensor_name to _endpoint_name in binary_sensor.py since the value is an API endpoint identifier, not a display name.

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:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

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 diff between library versions and ideally a link to the changelog/release notes 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 May 5, 2026

Hey there @hacf-fr/reviewers, @Quentame, mind taking a look at this pull request as it has been labeled with an integration (freebox) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of freebox can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign freebox Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@piitaya piitaya requested a review from Copilot May 6, 2026 07:43
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

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Comment on lines +39 to +46
for platform, old_suffix, new_key in _STATIC_UNIQUE_ID_MIGRATIONS:
old_uid = f"{mac} {old_suffix}"
new_uid = f"{mac} {new_key}"
if entity_id := entity_registry.async_get_entity_id(platform, DOMAIN, old_uid):
_LOGGER.debug(
"Migrating %s unique_id from %s to %s", entity_id, old_uid, new_uid
)
entity_registry.async_update_entity(entity_id, new_unique_id=new_uid)
Comment on lines 59 to 62
async def async_update_signal(self) -> None:
"""Update signal."""
self._node = self._router.home_devices[self._id]
# Update name
if self._sub_node is None:
self._attr_name = self._node["label"].strip()
else:
self._attr_name = (
self._node["label"].strip() + " " + self._sub_node["label"].strip()
)
self.async_write_ha_state()
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.

3 participants