"Internal" time wrong

Do you see a WARNING in home-assistant.log that starts “Incomplete core configuration. Auto detected”? And, if so, was time zone one of the things that was auto detected, and if so, is it correct?

Sorry - was out to dinner… Ya, the hass.yalm is included in the config. I actually remove time_zone setting while testing attempting to see what was going on, here is the WARNING you are looking for…
2019-02-02 21:28:26 WARNING (MainThread) [homeassistant.config] Incomplete core configuration. Auto detected time_zone: America/Chicago
It autodetected it correctly, I am in the mid-west (unfortunately).

I added time_zone back and the warning disappears.

I also tried adding sensor:

  • platform: time_date
    display_options:
    • ‘time’
    • ‘date’
    • ‘date_time’
    • ‘time_date’
    • ‘time_utc’
    • ‘beat’

to verify against UTC (and that I wasn’t crazy). I actually rationalized and assumed that the forecast was busted until I found this thread. Now I’m beating my head against something that seems so easy.

Just for grins, try entering the following into the Template Editor:

{{ now() }}
{{ now().astimezone() }}
{{ utcnow().astimezone() }}
{{ now().now() }}
{{ now().today() }}
{{ now().utcnow() }}
{{ utcnow() }}
{{ now().tzinfo }}
{{ now().astimezone().tzinfo }}
{{ utcnow().tzinfo }}

I also happen to be in the Midwest and I get the following:

2019-02-02 21:52:43.591028-06:00
2019-02-02 21:52:43.591370-06:00
2019-02-02 21:52:43.592234-06:00
2019-02-02 21:52:43.593221
2019-02-02 21:52:43.593807
2019-02-03 03:52:43.594381
2019-02-03 03:52:43.594514+00:00
America/Chicago
CST
UTC

I’m not sure this will help, but might be interesting.

Same as you, but 10 minutes later. I like the the thought though.

2019-02-02 22:02:10.214452-06:00
2019-02-02 22:02:10.214861-06:00
2019-02-02 22:02:10.247371-06:00
2019-02-02 22:02:10.248347
2019-02-02 22:02:10.248888
2019-02-03 04:02:10.249490
2019-02-03 04:02:10.249609+00:00
America/Chicago
CST
UTC

Well, that seems to indicate the clock is set correctly on your system, and the time zone in both HA and the environment in which HA runs are set correctly as well. And you say your time based automations run at the right time. So it seems like all that is correct.

So you say your “forecast card” is 6 hours too early. Can you post the config items that affect that? And maybe a screen capture of what doesn’t look right?

Here is the Lovelace snippet:
- type: weather-forecast
entity: weather.forecast

Here is the weather snippet:

  • platform: darksky
    api_key: xxxxx
    name: Forecast
    units: auto

image

Basically I get to see the last 6 hours of weather, not exactly the definition of a forecast.

Hmm, my Dark Sky starts with the current (local) hour for me:

image

Weird!

FWIW, here is my Dark Sky weather config:

weather:
  - platform: darksky
    api_key: !secret ds_api_key

Dang, That’s exactly what I want…

I thing I’m going to change my TZ and see what happens.

Wait, before you do that, I just looked at the darksky.py code for the weather component. It passes latitude and longitude to the package that obtains the forecast. I wonder … are your GPS coordinates entered correctly in your HA configuration?

Also, looking at how the code gets the times for the hourly forecasts, it gets a Unix Epoch timestamp from the server, then uses datetime.fromtimestamp() to convert it to local time. So, try this in the Template Editor:

{{ now() }}
{{ as_timestamp(now()) }}
{{ as_timestamp(utcnow()) }}
{{ now().fromtimestamp(as_timestamp(now())) }}
{{ now().fromtimestamp(as_timestamp(now())).isoformat() }}

I get this:

2019-02-02 22:57:43.349875-06:00
1549169863.35018
1549169863.350598
2019-02-02 22:57:43.351429
2019-02-02T22:57:43.352427

Too late - I set it to LA and it still shows my current time -6 hours.

I did double check my lat & long and they are correct. My home zone shows correctly on the map as well.

I will revert the TZ change and pass the lat & long to dark sky directly. (and then when that fails offset it)

lol!

I’m starting to wonder if your problem is in the “frontend”.

Try this in the Template Editor (which shows the data the “backend” is generating.)

{{ states.weather.dark_sky.attributes.forecast[0] }}

I see this:

{'datetime': '2019-02-02T23:00:00', 'condition': 'fog', 'precipitation': None, 'temperature': 37}

Note the time is “naive” (meaning it has no utc offset suffix) and is in the local time.

EDIT: You may need to change .dark_sky. to .forecast..

Sorry - I missed this on my last post…

2019-02-02 23:03:26.890948-06:00
1549170206.891364
1549170206.891964
2019-02-02 23:03:26.893089
2019-02-02T23:03:26.894482

Small mod:

{{ states.weather.forecast.attributes.forecast[0] }}

here is what I get:

{‘condition’: ‘clear-night’, ‘temperature’: 52, ‘datetime’: ‘2019-02-02T23:00:00’, ‘precipitation’: None}

Bingo!!

It’s the frontend (or your web browser.) What time and time zone is your PC you’re running the browser on set to?

image

Using Safari & MacOS 10.14.2

Hmm, then not sure. You can clearly see the first hour of the forecast is for 11 PM, but when shown in the frontend it’s showing as 4 PM.