mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Filter speak notify entity for WHA devices in Alexa Devices (#146688)
This commit is contained in:
parent
434cd95a66
commit
6a1e3b60ee
@ -7,6 +7,7 @@ from dataclasses import dataclass
|
|||||||
from typing import Any, Final
|
from typing import Any, Final
|
||||||
|
|
||||||
from aioamazondevices.api import AmazonDevice, AmazonEchoApi
|
from aioamazondevices.api import AmazonDevice, AmazonEchoApi
|
||||||
|
from aioamazondevices.const import SPEAKER_GROUP_FAMILY
|
||||||
|
|
||||||
from homeassistant.components.notify import NotifyEntity, NotifyEntityDescription
|
from homeassistant.components.notify import NotifyEntity, NotifyEntityDescription
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -22,6 +23,7 @@ PARALLEL_UPDATES = 1
|
|||||||
class AmazonNotifyEntityDescription(NotifyEntityDescription):
|
class AmazonNotifyEntityDescription(NotifyEntityDescription):
|
||||||
"""Alexa Devices notify entity description."""
|
"""Alexa Devices notify entity description."""
|
||||||
|
|
||||||
|
is_supported: Callable[[AmazonDevice], bool] = lambda _device: True
|
||||||
method: Callable[[AmazonEchoApi, AmazonDevice, str], Awaitable[None]]
|
method: Callable[[AmazonEchoApi, AmazonDevice, str], Awaitable[None]]
|
||||||
subkey: str
|
subkey: str
|
||||||
|
|
||||||
@ -31,6 +33,7 @@ NOTIFY: Final = (
|
|||||||
key="speak",
|
key="speak",
|
||||||
translation_key="speak",
|
translation_key="speak",
|
||||||
subkey="AUDIO_PLAYER",
|
subkey="AUDIO_PLAYER",
|
||||||
|
is_supported=lambda _device: _device.device_family != SPEAKER_GROUP_FAMILY,
|
||||||
method=lambda api, device, message: api.call_alexa_speak(device, message),
|
method=lambda api, device, message: api.call_alexa_speak(device, message),
|
||||||
),
|
),
|
||||||
AmazonNotifyEntityDescription(
|
AmazonNotifyEntityDescription(
|
||||||
@ -58,6 +61,7 @@ async def async_setup_entry(
|
|||||||
for sensor_desc in NOTIFY
|
for sensor_desc in NOTIFY
|
||||||
for serial_num in coordinator.data
|
for serial_num in coordinator.data
|
||||||
if sensor_desc.subkey in coordinator.data[serial_num].capabilities
|
if sensor_desc.subkey in coordinator.data[serial_num].capabilities
|
||||||
|
and sensor_desc.is_supported(coordinator.data[serial_num])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user