# Weather forecast

Current temperature and the next three days, refreshed by a cloud job from wttr.in (free, no key).

**Sizes:** small (now), medium (now on the left, three days on the right), large (plus humidity)
**Freshness:** a job every 30 minutes
**Gotcha:** the URL names the city. The job doesn't follow the user when they travel; reschedule it with the new city (read `city` from the phone context).

## Widget (a snapshot)

```json
{
  "slug": "weather",
  "title": "Riyadh",
  "symbol": "sun.max.fill",
  "accent": "#64D2FF",
  "theme": { "style": "gradient", "colors": ["#001A33", "#003D6B"] },
  "blocks": [
    { "type": "metric", "label": "Now, clear", "value": "28°" },
    { "type": "list", "title": "Next 3 days", "items": ["Wed 30° / 20°", "Thu 29° / 19°", "Fri 27° / 18° rain"] },
    { "type": "gauge", "label": "Humidity", "value": 42, "max": 100, "style": "bar" }
  ],
  "sizes": { "small": [0], "large": [0, 1, 2] },
  "lock": { "circular": 0, "inline": "28° clear" }
}
```

Medium has no `sizes`: the temperature in the left column, the three days on the right (60 pt). The highs and lows are in the item titles, because a list's `detail` shows only on large. Keep the conditions out of a metric's `change`: its colour follows the sign, so "Clear" would turn green.

## The agentic version

Weather on its own is display. The move is what it changes for the user: read their calendar (phone context) and offer the fix.

```json
{
  "slug": "weather-move",
  "title": "Weather",
  "symbol": "cloud.rain.fill",
  "accent": "#0A84FF",
  "relevance": 80,
  "blocks": [
    { "type": "metric", "label": "Rain", "value": "3pm" },
    { "type": "text", "text": "Rain at 3pm. Move your 3pm run to 6? Dry from 5." },
    { "type": "buttons", "items": [
      { "id": "move-run", "label": "Move", "symbol": "calendar.badge.clock" },
      { "id": "keep-run", "label": "Keep", "symbol": "figure.run" }
    ] },
    { "type": "list", "items": ["2pm: light rain", "4pm: heavy rain", "6pm: dry, 24°"] }
  ],
  "sizes": { "small": [1], "large": [1, 0, 3, 2] },
  "lock": { "circular": 0, "inline": "Rain 3pm. Move run?" }
}
```

A job can keep the forecast widget below current, but it can't make the offer: that takes your agent (the forecast plus the calendar). On "Move", update the event, then show "Run moved to 6pm" with [Undo].

## The job

```json
{
  "action": "schedule",
  "name": "weather-riyadh",
  "widget_slug": "weather",
  "every_minutes": 30,
  "fetch": { "url": "https://wttr.in/Riyadh?format=j1" },
  "values": {
    "temp": "current_condition.0.temp_C",
    "desc": "current_condition.0.weatherDesc.0.value",
    "humidity": "current_condition.0.humidity",
    "d0_max": "weather.0.maxtempC", "d0_min": "weather.0.mintempC",
    "d1_max": "weather.1.maxtempC", "d1_min": "weather.1.mintempC",
    "d2_max": "weather.2.maxtempC", "d2_min": "weather.2.mintempC"
  },
  "widget": {
    "title": "Riyadh",
    "subtitle": "{{now|time}}",
    "symbol": "sun.max.fill",
    "accent": "#64D2FF",
    "theme": { "style": "gradient", "colors": ["#001A33", "#003D6B"] },
    "blocks": [
      { "type": "metric", "label": "Now", "value": "{{temp}}°" },
      { "type": "list", "title": "{{desc}}", "items": ["Today {{d0_max}}° / {{d0_min}}°", "Next {{d1_max}}° / {{d1_min}}°", "Then {{d2_max}}° / {{d2_min}}°"] },
      { "type": "gauge", "label": "Humidity", "value": "{{humidity}}", "max": 100, "style": "bar" }
    ],
    "sizes": { "small": [0], "large": [0, 1, 2] },
    "lock": { "circular": 0, "inline": "{{temp}}° {{desc}}" }
  }
}
```

- For JSON, every value you use must be named in `values` (a path into the response). A `{{...}}` that isn't a named value prints `–`.
- Templates can't turn a date into a weekday or a weather code into words, hence "Today, Next, Then". Your agent can write nicer text if it updates the widget itself.
- `"value": "{{humidity}}"` becomes the string "42", which the gauge reads as a number.
