arnaud
(arnaud)
January 9, 2020, 6:45pm
1
Hello,
I try to grab the time of an alarm configured on my echo.
My goal is to get the time of the alarm to start my AC 1 hour before.
I use Alexa Media Player to get the data.
Example of the data I get from the parser :
“originalDate”: “2020-01-10”, “originalTime”: “06:45:00.000”, “personProfile”: null, “provider”: null, “rRuleData”: null, “recurrenceEligibility”: false, “recurringPattern”: “XXXX-WD”,
So the next alarm will be tomorrow morning a 6:45am local time (Montréal) of my echo.
The state of my sensor is : 2020-01-10T06:45:00+00:00
And I think HA think it’s GMT because on my lovelcace I see :
Alexa - Echo Dot Next Alarm in 12h but in Montreal right now it’s 13h30 so 6h45 is not in 12h but in 17h so 5h of error.
So I looked at the time of my HA : sensor.date_time = 2020-01-09, 13:39 sensor.time_utc = 18:40 sensor.date_time_iso = 2020-01-09T13:41:00
I can’t find any explanation why HA shows 5h of error
And if I try to use the data in node red I also have an error of 5h …
Any idea ?
If “2010-01-10” + “06:45:00.000” is supposed to be in EST, then the state of your sensor seems to be misinterpreting it, because “+00:00” means UTC, not EST. What is the HA config for that sensor?
arnaud
(arnaud)
January 9, 2020, 7:02pm
3
Nothing …
It a sensor created by Alexa Media Player integration.
So i didn’t put anything in my config.
Well then it seems like it has a bug.
arnaud
(arnaud)
January 9, 2020, 7:08pm
5
Yes.
I just see other bug report on github for timezone.
Anyway to correct the sensor in HA ? (sensor = sensor +5h)
I don’t know anything about the Alexa Media Player integration. But you could always create a template sensor that calculates the correct time.
Out of curiosity, what do you get if you enter the following into the Template Editor:
{{ now().tzinfo }}
{{ now().astimezone().tzinfo }}
petro
(Petro)
January 9, 2020, 7:11pm
8
Did you check your logs? Are you getting a warning about your timezone not being set in alexa?
That might be your problem. The time zone setting in the OS, or docker, or whatever HA is running in, is set incorrectly.
petro
(Petro)
January 9, 2020, 7:13pm
10
if you’re interested…
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: Apache-2.0
"""
Alexa Devices Sensors.
For more details about this platform, please refer to the documentation at
https://community.home-assistant.io/t/echo-devices-alexa-as-media-player-testers-needed/58639
"""
import datetime
import logging
from typing import List, Text # noqa pylint: disable=unused-import
from homeassistant.const import DEVICE_CLASS_TIMESTAMP, STATE_UNAVAILABLE
from homeassistant.exceptions import NoEntitySpecifiedError
from homeassistant.helpers.entity import Entity
from homeassistant.util import dt
from . import (
CONF_EMAIL,
This file has been truncated. show original
def _fix_alarm_date_time(self, value):
import pytz
if self._sensor_property != "date_time" or not value:
return value
naive_time = dt.parse_datetime(value[1][self._sensor_property])
timezone = pytz.timezone(self._client._timezone)
if timezone:
value[1][self._sensor_property] = timezone.localize(naive_time)
else:
_LOGGER.warning(
"%s does not have a timezone set. "
"Returned times may be wrong. "
"Please set the timezone in the Alexa app.",
self._client.name,
)
return value
arnaud
(arnaud)
January 9, 2020, 7:13pm
11
pnbruckner:
That might be your problem. The time zone setting in the OS, or docker, or whatever HA is running in, is set incorrectly.
Mmmm … i use docker on ubuntu.
Do you run it with ... -v /etc/localtime:/etc/localtime:ro
?
arnaud
(arnaud)
January 9, 2020, 7:14pm
13
petro:
if you’re interested…
I see … i will check my log
Seems to be a common problem. But according to @petro ’s post, looks like yet another time zone setting is coming into play that needs to be set right, too.
arnaud
(arnaud)
January 9, 2020, 7:15pm
15
I can’t check right now because i don’t have access th the host machine.
But i use the stock configuration and image of hassio on docker …
petro
(Petro)
January 9, 2020, 7:16pm
16
when you setup ubuntu it asks you to put in your timezone. It’s separate from HA.
arnaud
(arnaud)
January 9, 2020, 7:16pm
17
yes maybe but why when i display the HA time :
sensor.date_time = 2020-01-09, 13:39 sensor.time_utc = 18:40 sensor.date_time_iso = 2020-01-09T13:41:00
It’s correct …
But docker can have its own time zone setting, too, right??? (I don’t know. I never tried to use docker.)
Because HA has its own time zone setting.
There are at least these time zone settings in your scenario, and they should all be set correctly and agree:
Ubuntu
Docker
HA
Alexa App
arnaud
(arnaud)
January 9, 2020, 7:17pm
20
I know … i checked my tzinfo on my ubuntu server and it was correct yesterday