Can you share some more details about how you want to use the sunrise and sunset?
Custom Tile
I put together a quick Custom Tile that loads the sunrise and sunset from Open Meteo. You can import the Custom Tile using this link:
Import Sunset/Sunrise Custom Tile
After importing the tile, scroll down and press save, then add it to your dashboard from the Other → Custom Tile section. You’ll need to edit the tile on your dashboard and configure it with your latitude and longitude (which you can find on something like LatLong.net)
Rule Expression
You could create a rule that runs every morning and calls the new sunset()
and sunrise()
expression methods that I just put together for this.
The benefit of this approach is you can use the sunrise and/or sunset time on your dashboard and in your rules.
Here’s a few different snippets showing how you might use this
Today’s Sunrise
formatDate(sunrise(), "LT")
Today’s Sunset
formatDate(sunset(), "LT")
Tomorrow’s Sunrise
tomorrow = addDays(now(), 1)
formatDate(sunrise(tomorrow), "LT")
The Next Sunrise
tomorrow = addDays(now(), 1)
time = now() > sunrise() ?
sunrise(tomorrow) :
sunrise()
formatDate(time, "LT")
The last one reads as: "if it’s currently after today’s sunrise, then use tomorrow’s sunrise, otherwise use today’s.
Home Assistant
Since you mentioned that you’re using Home Assistant, you could use the native Sun integration which is enabled on most installations by default. To use it, you would need to make sure the relevant attributes that you are interested in are authorized in the SharpTools Home Assistant Add-on:
I would note that these values are UTC time formatted by default, so you would probably end up wanting to format them with an expression to get them into the format you want for display, so using the expressions above might be just as easy.