Enable Alexa state reporting by default (#63802)

This commit is contained in:
Erik Montnemery 2022-01-18 08:01:43 +01:00 committed by GitHub
parent 737ac7cb7c
commit 9718fd2534
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 4 deletions

View File

@ -23,7 +23,7 @@ PREF_GOOGLE_DEFAULT_EXPOSE = "google_default_expose"
PREF_TTS_DEFAULT_VOICE = "tts_default_voice" PREF_TTS_DEFAULT_VOICE = "tts_default_voice"
DEFAULT_TTS_DEFAULT_VOICE = ("en-US", "female") DEFAULT_TTS_DEFAULT_VOICE = ("en-US", "female")
DEFAULT_DISABLE_2FA = False DEFAULT_DISABLE_2FA = False
DEFAULT_ALEXA_REPORT_STATE = False DEFAULT_ALEXA_REPORT_STATE = True
DEFAULT_GOOGLE_REPORT_STATE = True DEFAULT_GOOGLE_REPORT_STATE = True
DEFAULT_EXPOSED_DOMAINS = [ DEFAULT_EXPOSED_DOMAINS = [
"climate", "climate",

View File

@ -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_entity_configs={"light.kitchen": entity_conf},
alexa_default_expose=["light"], alexa_default_expose=["light"],
alexa_enabled=True, alexa_enabled=True,
alexa_report_state=False,
) )
conf = alexa_config.CloudAlexaConfig( conf = alexa_config.CloudAlexaConfig(
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub 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): async def test_alexa_config_report_state(hass, cloud_prefs, cloud_stub):
"""Test Alexa config should expose using prefs.""" """Test Alexa config should expose using prefs."""
await cloud_prefs.async_update(
alexa_report_state=False,
)
conf = alexa_config.CloudAlexaConfig( conf = alexa_config.CloudAlexaConfig(
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub 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) aioclient_mock.post("http://example.com/alexa_endpoint", text="", status=202)
await cloud_prefs.async_update(
alexa_report_state=False,
)
conf = alexa_config.CloudAlexaConfig( conf = alexa_config.CloudAlexaConfig(
hass, hass,
ALEXA_SCHEMA({}), ALEXA_SCHEMA({}),
@ -273,6 +280,9 @@ def patch_sync_helper():
async def test_alexa_update_expose_trigger_sync(hass, cloud_prefs, cloud_stub): async def test_alexa_update_expose_trigger_sync(hass, cloud_prefs, cloud_stub):
"""Test Alexa config responds to updating exposed entities.""" """Test Alexa config responds to updating exposed entities."""
await cloud_prefs.async_update(
alexa_report_state=False,
)
await alexa_config.CloudAlexaConfig( await alexa_config.CloudAlexaConfig(
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub
).async_initialize() ).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): async def test_alexa_update_report_state(hass, cloud_prefs, cloud_stub):
"""Test Alexa config responds to reporting state.""" """Test Alexa config responds to reporting state."""
await cloud_prefs.async_update(
alexa_report_state=False,
)
conf = alexa_config.CloudAlexaConfig( conf = alexa_config.CloudAlexaConfig(
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub
) )

View File

@ -8,7 +8,11 @@ import pytest
from homeassistant.components.cloud import DOMAIN from homeassistant.components.cloud import DOMAIN
from homeassistant.components.cloud.client import CloudClient 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.const import CONTENT_TYPE_JSON
from homeassistant.core import State from homeassistant.core import State
from homeassistant.setup import async_setup_component 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"] cloud = hass.data["cloud"]
resp = await cloud.client.async_alexa_message( resp = await cloud.client.async_alexa_message(

View File

@ -401,7 +401,7 @@ async def test_websocket_status(
"google_default_expose": None, "google_default_expose": None,
"alexa_default_expose": None, "alexa_default_expose": None,
"alexa_entity_configs": {}, "alexa_entity_configs": {},
"alexa_report_state": False, "alexa_report_state": True,
"google_report_state": True, "google_report_state": True,
"remote_enabled": False, "remote_enabled": False,
"tts_default_voice": ["en-US", "female"], "tts_default_voice": ["en-US", "female"],