Add Terrain Support for Sunrise/Sunset Calculations

Context: I live in a valley surrounded by steep hills that significantly affect the visibility of sunrise and sunset from my location. While the standard sunrise/sunset times in Home Assistant (HA) are accurate for flat terrain, the local topography alters these times due to obstructing terrain.

Request: Could you add support for considering the surrounding terrain? Specifically, it would be helpful if users could specify terrain data that adjusts the sunrise/sunset calculations based on local topography.

Potential Solution: One potential approach could be to allow users to import terrain data in a simple format, such as CSV, to account for the local horizon. For example, terrain data can be downloaded from tools like PVGIS, which provides CSV (and JSON) exports for terrain profiles.

Implementation Idea:

Enable users to paste or upload CSV (or JSON) data with elevation angles for different azimuths (terrain profile).
Use this data to adjust the calculated horizon line, affecting the displayed sunrise and sunset times.
Benefits: This feature would make the sunrise/sunset times much more accurate for people in hilly or mountainous regions, providing more realistic data for automations and displays.

Thanks for considering this request!

Have you looked at sun elevation triggers?

1 Like

have a look at this Integration…think it does what you need

and the specific “valley” issue you have I think is addressed by the Observer Elevation feature…

+1 fro @jackjourneyman solution.

At the end of the day, “sunrise” and “sunset” are defined as elevation vs the (flat) horizon. You might as well use it to define you “custom” sunrise and sunset based upon your environment.

As @Gav_in points out, my Sun2 integration can do at least part of the work. I.e., you can specify distance to, and relative height of, an obstruction, for both rising (east) and setting (west.) If those values need to be adjusted throughout the year, you can use the Rising Azimuth and/or Setting Azimuth sensor(s) to trigger an automation to update the values via the sun2.update_location service.

1 Like