From 24add3f7667558f402aba18ec269007349cbbac1 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Fri, 11 Aug 2023 05:09:26 +0200 Subject: [PATCH] Migrate Doorbird to has entity name (#98161) --- homeassistant/components/doorbird/button.py | 4 ++-- homeassistant/components/doorbird/camera.py | 10 +++++----- homeassistant/components/doorbird/entity.py | 2 ++ homeassistant/components/doorbird/strings.json | 13 +++++++++++++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/doorbird/button.py b/homeassistant/components/doorbird/button.py index ad1356023fc..fb13a6f5be3 100644 --- a/homeassistant/components/doorbird/button.py +++ b/homeassistant/components/doorbird/button.py @@ -85,9 +85,9 @@ class DoorBirdButton(DoorBirdEntity, ButtonEntity): self.entity_description = entity_description if self._relay == IR_RELAY: - self._attr_name = f"{self._doorstation.name} IR" + self._attr_name = "IR" else: - self._attr_name = f"{self._doorstation.name} Relay {self._relay}" + self._attr_name = f"Relay {self._relay}" self._attr_unique_id = f"{self._mac_addr}_{self._relay}" def press(self) -> None: diff --git a/homeassistant/components/doorbird/camera.py b/homeassistant/components/doorbird/camera.py index 5983e639851..c1c8a622af8 100644 --- a/homeassistant/components/doorbird/camera.py +++ b/homeassistant/components/doorbird/camera.py @@ -49,7 +49,7 @@ async def async_setup_entry( doorstation_info, device.live_image_url, "live", - f"{doorstation.name} Live", + "live", doorstation.doorstation_events, _LIVE_INTERVAL, device.rtsp_live_video_url, @@ -59,7 +59,7 @@ async def async_setup_entry( doorstation_info, device.history_image_url(1, "doorbell"), "last_ring", - f"{doorstation.name} Last Ring", + "last_ring", [], _LAST_VISITOR_INTERVAL, ), @@ -68,7 +68,7 @@ async def async_setup_entry( doorstation_info, device.history_image_url(1, "motionsensor"), "last_motion", - f"{doorstation.name} Last Motion", + "last_motion", [], _LAST_MOTION_INTERVAL, ), @@ -85,7 +85,7 @@ class DoorBirdCamera(DoorBirdEntity, Camera): doorstation_info, url, camera_id, - name, + translation_key, doorstation_events, interval, stream_url=None, @@ -94,7 +94,7 @@ class DoorBirdCamera(DoorBirdEntity, Camera): super().__init__(doorstation, doorstation_info) self._url = url self._stream_url = stream_url - self._attr_name = name + self._attr_translation_key = translation_key self._last_image: bytes | None = None if self._stream_url: self._attr_supported_features = CameraEntityFeature.STREAM diff --git a/homeassistant/components/doorbird/entity.py b/homeassistant/components/doorbird/entity.py index ca0958af0ce..65431e38be1 100644 --- a/homeassistant/components/doorbird/entity.py +++ b/homeassistant/components/doorbird/entity.py @@ -16,6 +16,8 @@ from .util import get_mac_address_from_doorstation_info class DoorBirdEntity(Entity): """Base class for doorbird entities.""" + _attr_has_entity_name = True + def __init__(self, doorstation, doorstation_info): """Initialize the entity.""" super().__init__() diff --git a/homeassistant/components/doorbird/strings.json b/homeassistant/components/doorbird/strings.json index 44fd07c405e..ceaf1a891ee 100644 --- a/homeassistant/components/doorbird/strings.json +++ b/homeassistant/components/doorbird/strings.json @@ -33,5 +33,18 @@ "unknown": "[%key:common::config_flow::error::unknown%]", "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]" } + }, + "entity": { + "camera": { + "live": { + "name": "live" + }, + "last_ring": { + "name": "Last ring" + }, + "last_motion": { + "name": "Last motion" + } + } } }