Migrate Elgato to new entity naming style (#74590)

This commit is contained in:
Franck Nijhof 2022-07-09 23:41:04 +02:00 committed by GitHub
parent 81e7eb623b
commit 0f813b61c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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()