Migrate Freebox to has_entity_name and key-based unique IDs#169860
Open
Migrate Freebox to has_entity_name and key-based unique IDs#169860
Conversation
Contributor
|
Hey there @hacf-fr/reviewers, @Quentame, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
b0f98ed to
36d2694
Compare
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
Adopt
_attr_has_entity_name = Trueacross all Freebox entities and switch unique IDs from name-based to key-based. This unlocks the bronze quality scalehas-entity-namerule and is a stepping stone for further quality scale work in a follow-up PR.Static entity names use
translation_keywith strings instrings.json. Dynamic names (RAID array id, partition label) usetranslation_placeholders. Temperature probes are special: the unique ID uses the APIid(e.g.temp_cpum) for stability, while the displayed name uses the APIname(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
Freebox download speedrate_downFreebox upload speedrate_upFreebox missed callsmissedFreebox <probe name><probe id>Température CPU M)Reboot FreeboxrebootMark calls as readmark_calls_as_readFreebox WiFiwifiAll 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:
Système d'alarmeSystème d'alarmeCaméra entréeCaméra entréeDétecteurDétecteurOuverture porteOuverture porteDétecteur CouvercleDétecteur CoverTélécommande Niveau de batterieTélécommande BatteryThe cover removed should use
tamperdevice class but it will be a breaking change so I didn't want to do this in this PR.Other cleanups in this PR
icon=attributes moved toicons.json. The Wi-Fi switch now flips betweenmdi:wifiandmdi:wifi-offbased on state.services.yamldeleted. Therebootservice was removed in Remove deprecated freebox reboot service #144303 and the file was left as an empty stub._sensor_nameto_endpoint_nameinbinary_sensor.pysince the value is an API endpoint identifier, not a display name.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: