esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 35 forks source link

Issues with time component(s) #1083

Closed marcelveldt closed 4 years ago

marcelveldt commented 4 years ago

Operating environment/Installation (Hass.io/Docker/pip/etc.): Hass.io/Homeassistant with esphome add-on. Homeassistant version 106.5

ESP (ESP32/ESP8266, Board/Sonoff): ESP8266 Nodemcu v3

Affected component: Time component, both sntp and homeassistant

Description of problem:

homeassistant time component does not work at all. The current time seems to be the time since boot or something.

sntp time is off by one hour. Tried with both setting the timezone and without.

Problem-relevant YAML-configuration entries:

time:
  - platform: sntp
    id: sntp_time

The issue can be seen with simply logging the time with strftime

using strftime with home_assistant time now():
[09:08:53][I][current time:274]: 01:05

using strftime with sntp time now():
[09:14:39][I][current time:279]: 08:14

I tried all different timezone formats, tried switching between stable, beta and dev version of esphome.

marcelveldt commented 4 years ago

home assistant time is stuck at January 1 1970

lolouk44 commented 4 years ago

Same issue for me. Time is 1h off (feels like UTC/GMT for me when I'm based in London and should be BST (=GMT+1) If I add timezone, it's not taken into account (tried Europe/London and Europe/Paris as test) Same issue or I'm doing something stupid?

time:
- platform: sntp
  id: sntp_time
  timezone: "Europe/London"

i2c:
  sda: D1
  scl: D2

display:
  - platform: lcd_pcf8574
    dimensions: 20x4
    address: 0x3F
    id: sainsmart
    lambda: |-
      auto date = id(sntp_time).now().strftime("%d %b %Y");
      auto time = id(sntp_time).now();
      it.printf("%s %02d:%02d:%02d %d",date.c_str(),time.hour,time.minute,time.second, time.is_dst);

In addition time.is_dst returns false when it should be true this time of the year Logs show this:

[22:06:40][C][sntp:043]: SNTP Time:
[22:06:40][C][sntp:044]:   Server 1: '0.pool.ntp.org'
[22:06:40][C][sntp:045]:   Server 2: '1.pool.ntp.org'
[22:06:40][C][sntp:046]:   Server 3: '2.pool.ntp.org'
[22:06:40][C][sntp:047]:   Timezone: 'GMT0BST-1,M3.4.0/1,M10.5.0/2'
[22:06:46][D][sntp:059]: Synchronized time: Sun Sep 13 22:06:46 2020

when it's now 23:06 in London...

randybb commented 4 years ago

This has been fixed in dev https://github.com/esphome/esphome/pull/1266

glmnet commented 4 years ago

I've missed the fix in v1.15.0 but it's coming in v1.15.1 soon

lolouk44 commented 4 years ago

Thanks both. I can confirm that the code change in the PR works for me too 👍

marcelveldt commented 4 years ago

Thanks!