From f2514c0bdeb67be25d3308936449d59affde07f4 Mon Sep 17 00:00:00 2001 From: Jan Rieger Date: Thu, 4 Jan 2024 21:26:12 +0100 Subject: [PATCH] Migrate AVM FRITZ!Box Call monitor to has entity name (#99752) * Migrate AVM FRITZ!Box Call monitor to has entity name * Update homeassistant/components/fritzbox_callmonitor/strings.json Co-authored-by: Joost Lekkerkerker * Update homeassistant/components/fritzbox_callmonitor/strings.json Co-authored-by: Joost Lekkerkerker * Update sensor.py * Update sensor.py * Update strings.json * Use translation placeholders --------- Co-authored-by: Joost Lekkerkerker --- homeassistant/components/fritzbox_callmonitor/sensor.py | 9 ++++----- .../components/fritzbox_callmonitor/strings.json | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/fritzbox_callmonitor/sensor.py b/homeassistant/components/fritzbox_callmonitor/sensor.py index cc239895c38238..03ac98419c17dc 100644 --- a/homeassistant/components/fritzbox_callmonitor/sensor.py +++ b/homeassistant/components/fritzbox_callmonitor/sensor.py @@ -56,18 +56,16 @@ async def async_setup_entry( FRITZBOX_PHONEBOOK ] - phonebook_name: str = config_entry.title phonebook_id: int = config_entry.data[CONF_PHONEBOOK] prefixes: list[str] | None = config_entry.options.get(CONF_PREFIXES) serial_number: str = config_entry.data[SERIAL_NUMBER] host: str = config_entry.data[CONF_HOST] port: int = config_entry.data[CONF_PORT] - name = f"{fritzbox_phonebook.fph.modelname} Call Monitor {phonebook_name}" unique_id = f"{serial_number}-{phonebook_id}" sensor = FritzBoxCallSensor( - name=name, + phonebook_name=config_entry.title, unique_id=unique_id, fritzbox_phonebook=fritzbox_phonebook, prefixes=prefixes, @@ -82,13 +80,14 @@ class FritzBoxCallSensor(SensorEntity): """Implementation of a Fritz!Box call monitor.""" _attr_icon = ICON_PHONE + _attr_has_entity_name = True _attr_translation_key = DOMAIN _attr_device_class = SensorDeviceClass.ENUM _attr_options = list(CallState) def __init__( self, - name: str, + phonebook_name: str, unique_id: str, fritzbox_phonebook: FritzBoxPhonebook, prefixes: list[str] | None, @@ -103,7 +102,7 @@ def __init__( self._monitor: FritzBoxCallMonitor | None = None self._attributes: dict[str, str | list[str]] = {} - self._attr_name = name.title() + self._attr_translation_placeholders = {"phonebook_name": phonebook_name} self._attr_unique_id = unique_id self._attr_native_value = CallState.IDLE self._attr_device_info = DeviceInfo( diff --git a/homeassistant/components/fritzbox_callmonitor/strings.json b/homeassistant/components/fritzbox_callmonitor/strings.json index ac36942eec2dc7..9bfb1a6a7a01ff 100644 --- a/homeassistant/components/fritzbox_callmonitor/strings.json +++ b/homeassistant/components/fritzbox_callmonitor/strings.json @@ -44,6 +44,7 @@ "entity": { "sensor": { "fritzbox_callmonitor": { + "name": "Call monitor {phonebook_name}", "state": { "ringing": "Ringing", "dialing": "Dialing",