Sun set/rise incorrect

I am trying to get the configuration of my HA setup on a raspberryPi using The sun set/rise in not correct. When I look at the current state of sun.sun it shows the sun below the horizon when it is not. The correct sunrise is 05:13 and sunset is 19:14.

Here is the status shown for sun.sun
next_dawn: 2019-06-25T02:27:25+00:00
next_dusk: 2019-06-24T20:58:25+00:00
next_midnight: 2019-06-24T23:43:03+00:00
next_noon: 2019-06-24T11:42:43+00:00
next_rising: 2019-06-24T03:17:09+00:00
next_setting: 2019-06-24T20:08:16+00:00
elevation: -5.75
azimuth: 38.17
rising: true
friendly_name: Sun

my configuration.yaml is:


  latitude: 47.751046
  longitude: -122.626792
  elevation: 320
  unit_system: imperial
  time_zone: America/Los_Angeles
# Sensors
  # Weather prediction
  - platform: yr

# Text to speech
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

  usb_path: /dev/ttyACM0

What do you get when you paste this into the dev tools template editor:

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

And what was the local (Pacific) time when you did this?

Can’t quite explain the times you’re getting, but part of the problem may be you seem to be missing homeassistant: in your config. Specifically, it should look like this:


  latitude: 47.751046
  longitude: -122.626792
  elevation: 320
  unit_system: imperial
  time_zone: America/Los_Angeles

Of course, if that’s really what your configuration.yaml contains, it should cause HA to not even start. Hmm.

EDIT: Ah, ok, because latitude, etc is indented under default_config, it’s not causing a fatal error. But missing homeassistant: is causing it to ignore those settings.

New HA installs do not have that by default anymore mate
especially homeassistant:

But you still can have it in your configuration if you want. If you don’t, then you need to configure those parameters via the UI. Either way, @captjohn needs to check that HA is using the correct values. He should check on the Configuration -> General page.

defo it can be in there, its also required if you want to use customize as that’s located under that key.

By default its not there as its classed as advanced config

The answer to tom_l when I execute his code I get the following:
2019-06-24 22:51:47.784019+00:00
2019-06-24 14:51:47.784117-08:00
2019-06-24 22:51:47.784241+00:00
2019-06-24 22:51:47.786035+00:00
The current Pacific time is 15:52.
Note that the now() returns one hour earlier than it actually is. Seem that HA is not adjusting for daylight savings time.

I added the homeassistant: line in configuration.yaml and now it returns the correct time and the sun rise, sun set are now correct. Thanks for all the replies.