Sun tracking refuses to give usable values

Hi,

I have spent the weekend trying to get a HA system running on my Pi 3B+. I have tried Hass.io & Hassbian so far, several times. They install, and runs. But I cannot seem to figure out how to get the sun tracking to work!
Whatever I do, it gives false readings - nothing I can use in my automations…

Apart from time/date on the host (pi), and info in configuration.yaml (lat/long etc), is there anything else that needs to be configured for the sun tracking to work?

I don’t even get noon & midnight right, they look like this;

next_midnight: 2019-01-06T23:18:06+00:00
next_noon: 2019-01-07T11:17:53+00:00
friendly_name: Sun

As far as I know, they should be 00:00 & 12:00, right?

I would really, really appreciate if someone would help me out. In doing this I have googled a lot, but not found any working solutions. Please help.

Thanks

  1. solar noon does not equal noon. Solar noon can happen anytime. It’s just the time in which the sun is at the highest point in the sky. Same with midnight, accept it’s when the sun is at the lowest point.
  2. These are datetime objects. They are stored in UTC, thats what the +00:00 at the end means. You need to convert them to local. UTC is somewhere around Europe, it stands for Universal Time Coordinate. It’s the basis for all time calculations so computers can properly tell time in all parts of the world.
{{ as_timestamp(states.sun.sun.attributes.next_noon) | timestamp_custom('%H:%M:%S', True) }}

The true in that function converts the timestamp into local time. For me, my solar noon is 12:15:22.

1 Like

been wanting to ask about this. In my setup, using the True or not doesn’t make any difference at all, showing both as local time.

{{ as_timestamp(state_attr('sun.sun','next_noon')) | timestamp_custom('%H:%M:%S') }} having the same output as

{{ as_timestamp(state_attr('sun.sun','next_noon')) | timestamp_custom('%H:%M:%S', True) }}

isn’t the HA instance automatically adjusting to local time zone?

38

Thank you so much for a informative explanation!

I had no idea those were different - I simply thought that was what the time zone corrected…

Thanks!

I’m guessing that timestamp_custom() defaults to true. So when you omit the boolean, it gives you the same result.

that is it…