Upgrade arcam_fmj to entity naming (#82586)
This commit is contained in:
parent
f1ffb25d99
commit
25c7754edb
2 changed files with 13 additions and 19 deletions
|
@ -61,6 +61,7 @@ class ArcamFmj(MediaPlayerEntity):
|
|||
"""Representation of a media device."""
|
||||
|
||||
_attr_should_poll = False
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -70,9 +71,7 @@ class ArcamFmj(MediaPlayerEntity):
|
|||
) -> None:
|
||||
"""Initialize device."""
|
||||
self._state = state
|
||||
self._device_name = device_name
|
||||
self._attr_name = f"{device_name} - Zone: {state.zn}"
|
||||
self._uuid = uuid
|
||||
self._attr_name = f"Zone {state.zn}"
|
||||
self._attr_supported_features = (
|
||||
MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
|
@ -87,6 +86,14 @@ class ArcamFmj(MediaPlayerEntity):
|
|||
self._attr_supported_features |= MediaPlayerEntityFeature.SELECT_SOUND_MODE
|
||||
self._attr_unique_id = f"{uuid}-{state.zn}"
|
||||
self._attr_entity_registry_enabled_default = state.zn == 1
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={
|
||||
(DOMAIN, uuid),
|
||||
},
|
||||
manufacturer="Arcam",
|
||||
model="Arcam FMJ AVR",
|
||||
name=device_name,
|
||||
)
|
||||
|
||||
@property
|
||||
def state(self) -> MediaPlayerState:
|
||||
|
@ -95,19 +102,6 @@ class ArcamFmj(MediaPlayerEntity):
|
|||
return MediaPlayerState.ON
|
||||
return MediaPlayerState.OFF
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return a device description for device registry."""
|
||||
return DeviceInfo(
|
||||
identifiers={
|
||||
(DOMAIN, self._uuid),
|
||||
(DOMAIN, self._state.client.host, self._state.client.port), # type: ignore[arg-type]
|
||||
},
|
||||
manufacturer="Arcam",
|
||||
model="Arcam FMJ AVR",
|
||||
name=self._device_name,
|
||||
)
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Once registered, add listener for events."""
|
||||
await self._state.start()
|
||||
|
|
|
@ -20,7 +20,7 @@ from homeassistant.const import (
|
|||
ATTR_NAME,
|
||||
)
|
||||
|
||||
from .conftest import MOCK_HOST, MOCK_NAME, MOCK_PORT, MOCK_UUID
|
||||
from .conftest import MOCK_HOST, MOCK_UUID
|
||||
|
||||
MOCK_TURN_ON = {
|
||||
"service": "switch.turn_on",
|
||||
|
@ -41,7 +41,6 @@ async def test_properties(player, state):
|
|||
ATTR_NAME: f"Arcam FMJ ({MOCK_HOST})",
|
||||
ATTR_IDENTIFIERS: {
|
||||
("arcam_fmj", MOCK_UUID),
|
||||
("arcam_fmj", MOCK_HOST, MOCK_PORT),
|
||||
},
|
||||
ATTR_MODEL: "Arcam FMJ AVR",
|
||||
ATTR_MANUFACTURER: "Arcam",
|
||||
|
@ -102,7 +101,8 @@ async def test_mute_volume(player, state, mute):
|
|||
|
||||
async def test_name(player):
|
||||
"""Test name."""
|
||||
assert player.name == f"{MOCK_NAME} - Zone: 1"
|
||||
data = await update(player)
|
||||
assert data.attributes["friendly_name"] == "Zone 1"
|
||||
|
||||
|
||||
async def test_update(player, state):
|
||||
|
|
Loading…
Add table
Reference in a new issue