From 9718fd253480bcf9e5dc263b4a29d0b2789f423e Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 18 Jan 2022 08:01:43 +0100 Subject: [PATCH] Enable Alexa state reporting by default (#63802) --- homeassistant/components/cloud/const.py | 2 +- tests/components/cloud/test_alexa_config.py | 13 +++++++++++++ tests/components/cloud/test_client.py | 8 ++++++-- tests/components/cloud/test_http_api.py | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/cloud/const.py b/homeassistant/components/cloud/const.py index 90b7cbf7bc9..ce3ecf6271d 100644 --- a/homeassistant/components/cloud/const.py +++ b/homeassistant/components/cloud/const.py @@ -23,7 +23,7 @@ PREF_GOOGLE_DEFAULT_EXPOSE = "google_default_expose" PREF_TTS_DEFAULT_VOICE = "tts_default_voice" DEFAULT_TTS_DEFAULT_VOICE = ("en-US", "female") DEFAULT_DISABLE_2FA = False -DEFAULT_ALEXA_REPORT_STATE = False +DEFAULT_ALEXA_REPORT_STATE = True DEFAULT_GOOGLE_REPORT_STATE = True DEFAULT_EXPOSED_DOMAINS = [ "climate", diff --git a/tests/components/cloud/test_alexa_config.py b/tests/components/cloud/test_alexa_config.py index 0b5000a9ad4..9e24eaa764d 100644 --- a/tests/components/cloud/test_alexa_config.py +++ b/tests/components/cloud/test_alexa_config.py @@ -50,6 +50,7 @@ async def test_alexa_config_expose_entity_prefs(hass, cloud_prefs, cloud_stub): alexa_entity_configs={"light.kitchen": entity_conf}, alexa_default_expose=["light"], alexa_enabled=True, + alexa_report_state=False, ) conf = alexa_config.CloudAlexaConfig( hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub @@ -86,6 +87,9 @@ async def test_alexa_config_expose_entity_prefs(hass, cloud_prefs, cloud_stub): async def test_alexa_config_report_state(hass, cloud_prefs, cloud_stub): """Test Alexa config should expose using prefs.""" + await cloud_prefs.async_update( + alexa_report_state=False, + ) conf = alexa_config.CloudAlexaConfig( hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub ) @@ -175,6 +179,9 @@ async def test_alexa_config_fail_refresh_token( }, ) aioclient_mock.post("http://example.com/alexa_endpoint", text="", status=202) + await cloud_prefs.async_update( + alexa_report_state=False, + ) conf = alexa_config.CloudAlexaConfig( hass, ALEXA_SCHEMA({}), @@ -273,6 +280,9 @@ def patch_sync_helper(): async def test_alexa_update_expose_trigger_sync(hass, cloud_prefs, cloud_stub): """Test Alexa config responds to updating exposed entities.""" + await cloud_prefs.async_update( + alexa_report_state=False, + ) await alexa_config.CloudAlexaConfig( hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub ).async_initialize() @@ -360,6 +370,9 @@ async def test_alexa_entity_registry_sync(hass, mock_cloud_login, cloud_prefs): async def test_alexa_update_report_state(hass, cloud_prefs, cloud_stub): """Test Alexa config responds to reporting state.""" + await cloud_prefs.async_update( + alexa_report_state=False, + ) conf = alexa_config.CloudAlexaConfig( hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub ) diff --git a/tests/components/cloud/test_client.py b/tests/components/cloud/test_client.py index c3890fb17ec..f56a1c86d4d 100644 --- a/tests/components/cloud/test_client.py +++ b/tests/components/cloud/test_client.py @@ -8,7 +8,11 @@ import pytest from homeassistant.components.cloud import DOMAIN from homeassistant.components.cloud.client import CloudClient -from homeassistant.components.cloud.const import PREF_ENABLE_ALEXA, PREF_ENABLE_GOOGLE +from homeassistant.components.cloud.const import ( + PREF_ALEXA_REPORT_STATE, + PREF_ENABLE_ALEXA, + PREF_ENABLE_GOOGLE, +) from homeassistant.const import CONTENT_TYPE_JSON from homeassistant.core import State from homeassistant.setup import async_setup_component @@ -47,7 +51,7 @@ async def test_handler_alexa(hass): }, ) - mock_cloud_prefs(hass) + mock_cloud_prefs(hass, {PREF_ALEXA_REPORT_STATE: False}) cloud = hass.data["cloud"] resp = await cloud.client.async_alexa_message( diff --git a/tests/components/cloud/test_http_api.py b/tests/components/cloud/test_http_api.py index 9fe17b489cf..d3d71666bf2 100644 --- a/tests/components/cloud/test_http_api.py +++ b/tests/components/cloud/test_http_api.py @@ -401,7 +401,7 @@ async def test_websocket_status( "google_default_expose": None, "alexa_default_expose": None, "alexa_entity_configs": {}, - "alexa_report_state": False, + "alexa_report_state": True, "google_report_state": True, "remote_enabled": False, "tts_default_voice": ["en-US", "female"],