From 0f813b61c376046a9169eb47e5fc3676246992c6 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sat, 9 Jul 2022 23:41:04 +0200 Subject: [PATCH] Migrate Elgato to new entity naming style (#74590) --- homeassistant/components/elgato/entity.py | 2 ++ homeassistant/components/elgato/light.py | 1 - tests/components/elgato/test_button.py | 10 +++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/elgato/entity.py b/homeassistant/components/elgato/entity.py index 8927f8d71c0..16d3ac78e81 100644 --- a/homeassistant/components/elgato/entity.py +++ b/homeassistant/components/elgato/entity.py @@ -12,6 +12,8 @@ from .const import DOMAIN class ElgatoEntity(Entity): """Defines an Elgato entity.""" + _attr_has_entity_name = True + def __init__(self, client: Elgato, info: Info, mac: str | None) -> None: """Initialize an Elgato entity.""" self.client = client diff --git a/homeassistant/components/elgato/light.py b/homeassistant/components/elgato/light.py index e13119c2887..2a9f63a83d7 100644 --- a/homeassistant/components/elgato/light.py +++ b/homeassistant/components/elgato/light.py @@ -80,7 +80,6 @@ class ElgatoLight( self._attr_min_mireds = 143 self._attr_max_mireds = 344 - self._attr_name = info.display_name or info.product_name self._attr_supported_color_modes = {ColorMode.COLOR_TEMP} self._attr_unique_id = info.serial_number diff --git a/tests/components/elgato/test_button.py b/tests/components/elgato/test_button.py index 2ab3d7ee7c4..1f673bc6f44 100644 --- a/tests/components/elgato/test_button.py +++ b/tests/components/elgato/test_button.py @@ -25,12 +25,12 @@ async def test_button_identify( device_registry = dr.async_get(hass) entity_registry = er.async_get(hass) - state = hass.states.get("button.identify") + state = hass.states.get("button.frenck_identify") assert state assert state.attributes.get(ATTR_ICON) == "mdi:help" assert state.state == STATE_UNKNOWN - entry = entity_registry.async_get("button.identify") + entry = entity_registry.async_get("button.frenck_identify") assert entry assert entry.unique_id == "CN11A1A00001_identify" assert entry.entity_category == EntityCategory.CONFIG @@ -53,14 +53,14 @@ async def test_button_identify( await hass.services.async_call( BUTTON_DOMAIN, SERVICE_PRESS, - {ATTR_ENTITY_ID: "button.identify"}, + {ATTR_ENTITY_ID: "button.frenck_identify"}, blocking=True, ) assert len(mock_elgato.identify.mock_calls) == 1 mock_elgato.identify.assert_called_with() - state = hass.states.get("button.identify") + state = hass.states.get("button.frenck_identify") assert state assert state.state == "2021-11-13T11:48:00+00:00" @@ -79,7 +79,7 @@ async def test_button_identify_error( await hass.services.async_call( BUTTON_DOMAIN, SERVICE_PRESS, - {ATTR_ENTITY_ID: "button.identify"}, + {ATTR_ENTITY_ID: "button.frenck_identify"}, blocking=True, ) await hass.async_block_till_done()