mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 02:07:54 +00:00
Move alexa integration to use dt_util (#26723)
This commit is contained in:
parent
770eeaf82f
commit
1041b10616
@ -1,5 +1,4 @@
|
|||||||
"""Alexa capabilities."""
|
"""Alexa capabilities."""
|
||||||
from datetime import datetime
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -16,6 +15,7 @@ from homeassistant.const import (
|
|||||||
import homeassistant.components.climate.const as climate
|
import homeassistant.components.climate.const as climate
|
||||||
from homeassistant.components import light, fan, cover
|
from homeassistant.components import light, fan, cover
|
||||||
import homeassistant.util.color as color_util
|
import homeassistant.util.color as color_util
|
||||||
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
API_TEMP_UNITS,
|
API_TEMP_UNITS,
|
||||||
@ -109,7 +109,7 @@ class AlexaCapibility:
|
|||||||
"name": prop_name,
|
"name": prop_name,
|
||||||
"namespace": self.name(),
|
"namespace": self.name(),
|
||||||
"value": prop_value,
|
"value": prop_value,
|
||||||
"timeOfSample": datetime.now().strftime(DATE_FORMAT),
|
"timeOfSample": dt_util.utcnow().strftime(DATE_FORMAT),
|
||||||
"uncertaintyInMilliseconds": 0,
|
"uncertaintyInMilliseconds": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""Support for Alexa skill service end point."""
|
"""Support for Alexa skill service end point."""
|
||||||
import copy
|
import copy
|
||||||
from datetime import datetime
|
|
||||||
import logging
|
import logging
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import homeassistant.util.dt as dt_util
|
||||||
from homeassistant.components import http
|
from homeassistant.components import http
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import template
|
from homeassistant.helpers import template
|
||||||
@ -89,7 +89,7 @@ class AlexaFlashBriefingView(http.HomeAssistantView):
|
|||||||
else:
|
else:
|
||||||
output[ATTR_REDIRECTION_URL] = item.get(CONF_DISPLAY_URL)
|
output[ATTR_REDIRECTION_URL] = item.get(CONF_DISPLAY_URL)
|
||||||
|
|
||||||
output[ATTR_UPDATE_DATE] = datetime.now().strftime(DATE_FORMAT)
|
output[ATTR_UPDATE_DATE] = dt_util.utcnow().strftime(DATE_FORMAT)
|
||||||
|
|
||||||
briefing.append(output)
|
briefing.append(output)
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Alexa message handlers."""
|
"""Alexa message handlers."""
|
||||||
from datetime import datetime
|
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
|
|
||||||
@ -28,6 +27,7 @@ from homeassistant.const import (
|
|||||||
TEMP_FAHRENHEIT,
|
TEMP_FAHRENHEIT,
|
||||||
)
|
)
|
||||||
import homeassistant.util.color as color_util
|
import homeassistant.util.color as color_util
|
||||||
|
import homeassistant.util.dt as dt_util
|
||||||
from homeassistant.util.decorator import Registry
|
from homeassistant.util.decorator import Registry
|
||||||
from homeassistant.util.temperature import convert as convert_temperature
|
from homeassistant.util.temperature import convert as convert_temperature
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ async def async_api_activate(hass, config, directive, context):
|
|||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"cause": {"type": Cause.VOICE_INTERACTION},
|
"cause": {"type": Cause.VOICE_INTERACTION},
|
||||||
"timestamp": "%sZ" % (datetime.utcnow().isoformat(),),
|
"timestamp": f"{dt_util.utcnow().replace(tzinfo=None).isoformat()}Z",
|
||||||
}
|
}
|
||||||
|
|
||||||
return directive.response(
|
return directive.response(
|
||||||
@ -299,7 +299,7 @@ async def async_api_deactivate(hass, config, directive, context):
|
|||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"cause": {"type": Cause.VOICE_INTERACTION},
|
"cause": {"type": Cause.VOICE_INTERACTION},
|
||||||
"timestamp": "%sZ" % (datetime.utcnow().isoformat(),),
|
"timestamp": f"{dt_util.utcnow().replace(tzinfo=None).isoformat()}Z",
|
||||||
}
|
}
|
||||||
|
|
||||||
return directive.response(
|
return directive.response(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user