Skip to content

Weather

The weather set gives your app live weather data from Open-Meteo — no API key, no account, no setup. Fetch current conditions, a multi-day forecast, or hour-by-hour data for any city or set of coordinates.

There are three actions:

ActionWhat it returnsDefault range
weather-currentCurrent conditions (temperature, wind, humidity, etc.)—
weather-forecastArray of daily forecasts7 days (up to 16)
weather-hourlyArray of hourly forecasts48 hours (up to 168)

All three are functions — they must be assigned to a variable. All temperatures are in Celsius.


Current conditions — weather-current

$weather = weather-current "New York"
$weather = weather-current $city
$weather = weather-current $lat $lon

The result is an object with these fields:

FieldTypeDescription
$weather.temperaturenumberTemperature in °C
$weather.feelsLikenumberFeels-like temperature in °C
$weather.humiditynumberRelative humidity, 0–100
$weather.windSpeednumberWind speed in km/h
$weather.windDirectionnumberWind direction in degrees, 0–360
$weather.descriptiontextCondition label, e.g. "Clear sky"
$weather.icontextMDI icon name, e.g. "mdi:weather-sunny"
$weather.isDaytrue/falseWhether it is currently daytime
$weather.precipitationnumberCurrent precipitation in mm

Basic example

$weather = weather-current "Tokyo"
.text "$weather.temperature° — $weather.description"
.text "Feels like $weather.feelsLike° · Humidity $weather.humidity% · Wind $weather.windSpeed km/h"

Displaying the weather icon

The icon field contains an MDI icon name. Pass it to .icon to render it:

$weather = weather-current "London"
$ic = $weather.icon
.icon $ic
.text "$weather.description"

Using coordinates

Pass latitude and longitude as numeric variables (not strings):

$lat = 40.71
$lon = -74.01
$weather = weather-current $lat $lon
.text "$weather.temperature° in New York"

Multi-day forecast — weather-forecast

$forecast = weather-forecast "Paris"
$forecast = weather-forecast "Tokyo" 14
$forecast = weather-forecast $city
$forecast = weather-forecast $city $days
$forecast = weather-forecast $lat $lon $days

The result is an array of daily forecast objects. The default is 7 days; the maximum is 16.

Each item in the array has:

FieldTypeDescription
datetextDate in YYYY-MM-DD format
highnumberHigh temperature in °C
lownumberLow temperature in °C
feelsLikeHighnumberFeels-like high in °C
feelsLikeLownumberFeels-like low in °C
precipChancenumberPrecipitation probability, 0–100
precipAmountnumberPrecipitation in mm
windSpeednumberMax wind speed in km/h
descriptiontextCondition label
icontextMDI icon name
sunrisetextSunrise time (ISO format)
sunsettextSunset time (ISO format)

Iterating all days

$forecast = weather-forecast "London"
foreach $forecast as $day:
.text "$day.date: $day.high°C / $day.low°C — $day.description"
:end

Custom number of days

$forecast = weather-forecast "Sydney" 10
foreach $forecast as $day:
.text "$day.date — Rain chance: $day.precipChance%"
:end

Accessing specific days by index

Array entries are 1-based. To pull out specific days without a loop:

$forecast = weather-forecast "London"
.text "Today: $forecast.1.description, high $forecast.1.high°C"
.text "Tomorrow: $forecast.2.description, high $forecast.2.high°C"

Hourly forecast — weather-hourly

$hourly = weather-hourly "Miami"
$hourly = weather-hourly "Seattle" 24
$hourly = weather-hourly $city
$hourly = weather-hourly $city $hours

The result is an array of hourly entries. The default is 48 hours; the maximum is 168 (7 days).

Each entry has:

FieldTypeDescription
timetextTimestamp (ISO format)
temperaturenumberTemperature in °C
feelsLikenumberFeels-like temperature in °C
humiditynumberRelative humidity, 0–100
precipChancenumberPrecipitation probability, 0–100
precipitationnumberPrecipitation in mm
descriptiontextCondition label
icontextMDI icon name
windSpeednumberWind speed in km/h

Iterating hourly entries

$hourly = weather-hourly "New York" 24
foreach $hourly as $entry:
.text "$entry.time — $entry.temperature°C, $entry.description"
:end

Handling errors

All three actions support an extended result pattern that gives you the data, an error message, and extra location metadata as three separate variables:

$result, $error, $details = weather-current "London"
$result, $error, $details = weather-forecast "Paris" 5
$result, $error, $details = weather-hourly "Chicago" 24

$error is null on success or an error message string if the request failed. Always check before using the data:

$result, $error, $details = weather-current "Berlin"
if have $error:
.text "Could not load weather: $error" #red
:else
.text "$result.temperature° — $result.description"
:end

Practical patterns

City search app

Let the user type a city and see current conditions:

[home]
.text "Weather" -bold
.enter-text "Enter a city" $city
.button "Search"
goto [results]
[results]
$now, $err = weather-current $city
if have $err:
.text "City not found" #red
:else
.text "$city" -bold
.text "$now.temperature°C — $now.description"
.text "Humidity: $now.humidity% · Wind: $now.windSpeed km/h"
:end
.button "Back"
goto [home]

Current + forecast on one screen

Fetch both in the same block — they can share the same $city variable:

[home]
$city = "London"
$now = weather-current $city
.large.text "$now.temperature°C" -bold
.text "$now.description"
$forecast = weather-forecast $city 5
foreach $forecast as $day:
.text "$day.date: $day.high° / $day.low° — $day.description"
:end

Remembering the user’s city

Use remember to persist the chosen city between sessions:

[launch]
remember $city
[home]
if have $city:
goto [weather]
:else
.enter-text "Enter your city" $city
remember $city
.button "Save"
goto [weather]
:end
[weather]
$now = weather-current $city
.text "$city — $now.temperature°C"

Common mistakes

MistakeFix
weather-current "Tokyo" without $var =Weather actions are functions — always assign: $weather = weather-current "Tokyo"
Using $weather.temperature before checking for errorsUse the extended result pattern and if have $error: first
Passing coordinates as strings: $lat = "40.71"Coordinates must be numbers, not quoted strings
Requesting more than 16 forecast daysweather-forecast caps at 16 days; values above that are clamped
Requesting more than 168 hourly entriesweather-hourly caps at 168 hours; values above that are clamped
Treating forecast/hourly results as a single objectBoth return arrays — use foreach to iterate, or .1, .2 for specific entries