From ec6a1f91376966a4161512c59d4ed32039e90acc Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Wed, 2 Sep 2020 11:59:51 +0200 Subject: [PATCH] Add support for receiver and speaker device classes (#38381) These are now officially supported by google --- homeassistant/components/google_assistant/const.py | 3 +++ homeassistant/components/media_player/__init__.py | 3 ++- tests/components/google_assistant/test_smart_home.py | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/google_assistant/const.py b/homeassistant/components/google_assistant/const.py index 88b704eb518..339f4ab27ab 100644 --- a/homeassistant/components/google_assistant/const.py +++ b/homeassistant/components/google_assistant/const.py @@ -80,6 +80,7 @@ TYPE_ALARM = f"{PREFIX_TYPES}SECURITYSYSTEM" TYPE_SETTOP = f"{PREFIX_TYPES}SETTOP" TYPE_HUMIDIFIER = f"{PREFIX_TYPES}HUMIDIFIER" TYPE_DEHUMIDIFIER = f"{PREFIX_TYPES}DEHUMIDIFIER" +TYPE_RECEIVER = f"{PREFIX_TYPES}AUDIO_VIDEO_RECEIVER" SERVICE_REQUEST_SYNC = "request_sync" HOMEGRAPH_URL = "https://homegraph.googleapis.com/" @@ -144,6 +145,8 @@ DEVICE_CLASS_TO_GOOGLE_TYPES = { (binary_sensor.DOMAIN, binary_sensor.DEVICE_CLASS_OPENING): TYPE_SENSOR, (binary_sensor.DOMAIN, binary_sensor.DEVICE_CLASS_WINDOW): TYPE_SENSOR, (media_player.DOMAIN, media_player.DEVICE_CLASS_TV): TYPE_TV, + (media_player.DOMAIN, media_player.DEVICE_CLASS_SPEAKER): TYPE_SPEAKER, + (media_player.DOMAIN, media_player.DEVICE_CLASS_RECEIVER): TYPE_RECEIVER, (sensor.DOMAIN, sensor.DEVICE_CLASS_TEMPERATURE): TYPE_SENSOR, (sensor.DOMAIN, sensor.DEVICE_CLASS_HUMIDITY): TYPE_SENSOR, (humidifier.DOMAIN, humidifier.DEVICE_CLASS_HUMIDIFIER): TYPE_HUMIDIFIER, diff --git a/homeassistant/components/media_player/__init__.py b/homeassistant/components/media_player/__init__.py index 70eda4329c6..886f0170a06 100644 --- a/homeassistant/components/media_player/__init__.py +++ b/homeassistant/components/media_player/__init__.py @@ -127,8 +127,9 @@ SCAN_INTERVAL = timedelta(seconds=10) DEVICE_CLASS_TV = "tv" DEVICE_CLASS_SPEAKER = "speaker" +DEVICE_CLASS_RECEIVER = "receiver" -DEVICE_CLASSES = [DEVICE_CLASS_TV, DEVICE_CLASS_SPEAKER] +DEVICE_CLASSES = [DEVICE_CLASS_TV, DEVICE_CLASS_SPEAKER, DEVICE_CLASS_RECEIVER] DEVICE_CLASSES_SCHEMA = vol.All(vol.Lower, vol.In(DEVICE_CLASSES)) diff --git a/tests/components/google_assistant/test_smart_home.py b/tests/components/google_assistant/test_smart_home.py index cf25c79efdb..1aadb39d5a8 100644 --- a/tests/components/google_assistant/test_smart_home.py +++ b/tests/components/google_assistant/test_smart_home.py @@ -853,6 +853,8 @@ async def test_device_class_cover(hass, device_class, google_type): [ ("non_existing_class", "action.devices.types.SETTOP"), ("tv", "action.devices.types.TV"), + ("speaker", "action.devices.types.SPEAKER"), + ("receiver", "action.devices.types.AUDIO_VIDEO_RECEIVER"), ], ) async def test_device_media_player(hass, device_class, google_type):