mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Correct Alexa scene activation (#56469)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
d4864f5750
commit
097fae0348
@ -54,6 +54,7 @@ from .const import (
|
|||||||
API_THERMOSTAT_MODES,
|
API_THERMOSTAT_MODES,
|
||||||
API_THERMOSTAT_MODES_CUSTOM,
|
API_THERMOSTAT_MODES_CUSTOM,
|
||||||
API_THERMOSTAT_PRESETS,
|
API_THERMOSTAT_PRESETS,
|
||||||
|
DATE_FORMAT,
|
||||||
Cause,
|
Cause,
|
||||||
Inputs,
|
Inputs,
|
||||||
)
|
)
|
||||||
@ -318,7 +319,7 @@ async def async_api_activate(hass, config, directive, context):
|
|||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"cause": {"type": Cause.VOICE_INTERACTION},
|
"cause": {"type": Cause.VOICE_INTERACTION},
|
||||||
"timestamp": f"{dt_util.utcnow().replace(tzinfo=None).isoformat()}Z",
|
"timestamp": dt_util.utcnow().strftime(DATE_FORMAT),
|
||||||
}
|
}
|
||||||
|
|
||||||
return directive.response(
|
return directive.response(
|
||||||
@ -342,7 +343,7 @@ async def async_api_deactivate(hass, config, directive, context):
|
|||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"cause": {"type": Cause.VOICE_INTERACTION},
|
"cause": {"type": Cause.VOICE_INTERACTION},
|
||||||
"timestamp": f"{dt_util.utcnow().replace(tzinfo=None).isoformat()}Z",
|
"timestamp": dt_util.utcnow().strftime(DATE_FORMAT),
|
||||||
}
|
}
|
||||||
|
|
||||||
return directive.response(
|
return directive.response(
|
||||||
|
@ -13,7 +13,7 @@ from homeassistant.core import HomeAssistant, State, callback
|
|||||||
from homeassistant.helpers.significant_change import create_checker
|
from homeassistant.helpers.significant_change import create_checker
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from .const import API_CHANGE, DOMAIN, Cause
|
from .const import API_CHANGE, DATE_FORMAT, DOMAIN, Cause
|
||||||
from .entities import ENTITY_ADAPTERS, AlexaEntity, generate_alexa_id
|
from .entities import ENTITY_ADAPTERS, AlexaEntity, generate_alexa_id
|
||||||
from .messages import AlexaResponse
|
from .messages import AlexaResponse
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ async def async_send_doorbell_event_message(hass, config, alexa_entity):
|
|||||||
namespace="Alexa.DoorbellEventSource",
|
namespace="Alexa.DoorbellEventSource",
|
||||||
payload={
|
payload={
|
||||||
"cause": {"type": Cause.PHYSICAL_INTERACTION},
|
"cause": {"type": Cause.PHYSICAL_INTERACTION},
|
||||||
"timestamp": f"{dt_util.utcnow().replace(tzinfo=None).isoformat()}Z",
|
"timestamp": dt_util.utcnow().strftime(DATE_FORMAT),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
"""Tests for the Alexa integration."""
|
"""Tests for the Alexa integration."""
|
||||||
|
import re
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from homeassistant.components.alexa import config, smart_home
|
from homeassistant.components.alexa import config, smart_home
|
||||||
@ -162,7 +163,8 @@ async def assert_scene_controller_works(
|
|||||||
)
|
)
|
||||||
assert response["event"]["payload"]["cause"]["type"] == "VOICE_INTERACTION"
|
assert response["event"]["payload"]["cause"]["type"] == "VOICE_INTERACTION"
|
||||||
assert "timestamp" in response["event"]["payload"]
|
assert "timestamp" in response["event"]["payload"]
|
||||||
|
pattern = r"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.0Z"
|
||||||
|
assert re.search(pattern, response["event"]["payload"]["timestamp"])
|
||||||
if deactivate_service:
|
if deactivate_service:
|
||||||
await assert_request_calls_service(
|
await assert_request_calls_service(
|
||||||
"Alexa.SceneController",
|
"Alexa.SceneController",
|
||||||
@ -175,6 +177,7 @@ async def assert_scene_controller_works(
|
|||||||
cause_type = response["event"]["payload"]["cause"]["type"]
|
cause_type = response["event"]["payload"]["cause"]["type"]
|
||||||
assert cause_type == "VOICE_INTERACTION"
|
assert cause_type == "VOICE_INTERACTION"
|
||||||
assert "timestamp" in response["event"]["payload"]
|
assert "timestamp" in response["event"]["payload"]
|
||||||
|
assert re.search(pattern, response["event"]["payload"]["timestamp"])
|
||||||
|
|
||||||
|
|
||||||
async def reported_properties(hass, endpoint):
|
async def reported_properties(hass, endpoint):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user