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
3 changed files with 9 additions and 5 deletions
|
@ -54,6 +54,7 @@ from .const import (
|
|||
API_THERMOSTAT_MODES,
|
||||
API_THERMOSTAT_MODES_CUSTOM,
|
||||
API_THERMOSTAT_PRESETS,
|
||||
DATE_FORMAT,
|
||||
Cause,
|
||||
Inputs,
|
||||
)
|
||||
|
@ -318,7 +319,7 @@ async def async_api_activate(hass, config, directive, context):
|
|||
|
||||
payload = {
|
||||
"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(
|
||||
|
@ -342,7 +343,7 @@ async def async_api_deactivate(hass, config, directive, context):
|
|||
|
||||
payload = {
|
||||
"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(
|
||||
|
|
|
@ -13,7 +13,7 @@ from homeassistant.core import HomeAssistant, State, callback
|
|||
from homeassistant.helpers.significant_change import create_checker
|
||||
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 .messages import AlexaResponse
|
||||
|
||||
|
@ -252,7 +252,7 @@ async def async_send_doorbell_event_message(hass, config, alexa_entity):
|
|||
namespace="Alexa.DoorbellEventSource",
|
||||
payload={
|
||||
"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."""
|
||||
import re
|
||||
from uuid import uuid4
|
||||
|
||||
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 "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:
|
||||
await assert_request_calls_service(
|
||||
"Alexa.SceneController",
|
||||
|
@ -175,6 +177,7 @@ async def assert_scene_controller_works(
|
|||
cause_type = response["event"]["payload"]["cause"]["type"]
|
||||
assert cause_type == "VOICE_INTERACTION"
|
||||
assert "timestamp" in response["event"]["payload"]
|
||||
assert re.search(pattern, response["event"]["payload"]["timestamp"])
|
||||
|
||||
|
||||
async def reported_properties(hass, endpoint):
|
||||
|
|
Loading…
Add table
Reference in a new issue