mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Add zone devices to AnthemAV (#107192)
This commit is contained in:
parent
394385fdeb
commit
5fe96390f5
@ -50,6 +50,7 @@ class AnthemAVR(MediaPlayerEntity):
|
|||||||
"""Entity reading values from Anthem AVR protocol."""
|
"""Entity reading values from Anthem AVR protocol."""
|
||||||
|
|
||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
|
_attr_name = None
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
_attr_device_class = MediaPlayerDeviceClass.RECEIVER
|
_attr_device_class = MediaPlayerDeviceClass.RECEIVER
|
||||||
_attr_icon = "mdi:audio-video"
|
_attr_icon = "mdi:audio-video"
|
||||||
@ -77,18 +78,23 @@ class AnthemAVR(MediaPlayerEntity):
|
|||||||
self._zone_number = zone_number
|
self._zone_number = zone_number
|
||||||
self._zone = avr.zones[zone_number]
|
self._zone = avr.zones[zone_number]
|
||||||
if zone_number > 1:
|
if zone_number > 1:
|
||||||
self._attr_name = f"zone {zone_number}"
|
unique_id = f"{mac_address}_{zone_number}"
|
||||||
self._attr_unique_id = f"{mac_address}_{zone_number}"
|
self._attr_unique_id = unique_id
|
||||||
|
self._attr_device_info = DeviceInfo(
|
||||||
|
identifiers={(DOMAIN, unique_id)},
|
||||||
|
name=f"Zone {zone_number}",
|
||||||
|
manufacturer=MANUFACTURER,
|
||||||
|
model=model,
|
||||||
|
via_device=(DOMAIN, mac_address),
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self._attr_name = None
|
|
||||||
self._attr_unique_id = mac_address
|
self._attr_unique_id = mac_address
|
||||||
|
self._attr_device_info = DeviceInfo(
|
||||||
self._attr_device_info = DeviceInfo(
|
identifiers={(DOMAIN, mac_address)},
|
||||||
identifiers={(DOMAIN, mac_address)},
|
name=name,
|
||||||
name=name,
|
manufacturer=MANUFACTURER,
|
||||||
manufacturer=MANUFACTURER,
|
model=model,
|
||||||
model=model,
|
)
|
||||||
)
|
|
||||||
self.set_states()
|
self.set_states()
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
|
@ -22,7 +22,7 @@ from tests.common import MockConfigEntry
|
|||||||
("entity_id", "entity_name"),
|
("entity_id", "entity_name"),
|
||||||
[
|
[
|
||||||
("media_player.anthem_av", "Anthem AV"),
|
("media_player.anthem_av", "Anthem AV"),
|
||||||
("media_player.anthem_av_zone_2", "Anthem AV zone 2"),
|
("media_player.zone_2", "Zone 2"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_zones_loaded(
|
async def test_zones_loaded(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user