Weather & Sun Clock
Combine a configured location, weather response, local sunrise time, formatted temperature, and humidity chart. Demo mode makes the tutorial runnable without an API key; the live request path is already included.

Complete app
app.star
load("http.star", "http")
load("humanize.star", "humanize")
load("math.star", "math")
load("render.star", "render")
load("schema.star", "schema")
load("sunrise.star", "sunrise")
load("time.star", "time")
DEMO_MODE = True
DEMO_WEATHER = {
"place": "Miami",
"temp": 21.7,
"humidity": 68,
"condition": "Clear",
}
def fetch_weather(location):
response = http.get(
"https://weather.example/current?lat=%s&lng=%s" % (
location["lat"],
location["lng"],
),
ttl_seconds = 900,
)
if response.status_code != 200:
fail("Weather request failed: %d" % response.status_code)
return response.json()
def main(config):
location = config.get("location") or {
"lat": 25.7617,
"lng": -80.1918,
"locality": "Miami",
"timezone": "America/New_York",
}
weather = DEMO_WEATHER if DEMO_MODE else fetch_weather(location)
moment = time.parse_time("2026-09-23T12:00:00Z")
sunrise_at = sunrise.sunrise(
location["lat"],
location["lng"],
moment,
).in_location(location["timezone"])
temperature = "%s°" % humanize.ftoa(weather["temp"], 0)
humidity = math.floor(weather["humidity"])
return render.Root(
child = render.Box(
width = 64,
height = 32,
color = "#164e63",
child = render.Padding(
pad = (3, 2, 3, 2),
child = render.Row(
expanded = True,
main_align = "space_between",
cross_align = "center",
children = [
render.Column(
children = [
render.Text(
temperature,
font = "6x13",
color = "#fef3c7",
),
render.Box(width = 1, height = 1),
render.Text(
weather["place"],
font = "CG-pixel-4x5-mono",
color = "#cffafe",
),
render.Box(width = 1, height = 1),
render.Text(
"Sun %s" % sunrise_at.format("3:04"),
font = "CG-pixel-3x5-mono",
color = "#fde68a",
),
],
),
render.PieChart(
colors = ["#22d3ee", "#0e7490"],
weights = [humidity, 100 - humidity],
diameter = 22,
),
],
),
),
),
)
def get_schema():
return schema.Schema(
version = "1",
fields = [
schema.Location(
id = "location",
name = "Location",
desc = "Location used for weather and sunrise.",
icon = "location-dot",
),
],
)
How it works
schema.Locationsupplies latitude, longitude, locality, and time zone.sunrise.sunrise()calculates the solar event, thenin_location()converts it to the selected time zone.humanize.ftoa()formats the temperature, whilemath.floor()normalizes humidity to a whole-number chart weight.PieChartvisualizes humidity against the remaining percentage.
Connect live weather
Replace weather.example with your provider's endpoint, map its JSON to the
four DEMO_WEATHER keys, and set DEMO_MODE to False. Keep the request TTL
to avoid fetching identical weather on every render.