feat(signage): the weather all the way: a week, the next hours, feels like, humidity, wind, rain chance, sunrise / sunset, UV, in words; row, column, card, list of days or hourly layouts

services/weather.py asks Open-Meteo for 7 days, the next 24 hours and the details
(mph for Fahrenheit); older answers without them still read. The widget's layout,
the details it adds and the place's name; up to 7 days. Plan 6R.18, F-116.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 15:07:03 +02:00
co-authored by Claude Opus 5.5
parent 673113aff7
commit 84c2d5b2d8
10 changed files with 301 additions and 43 deletions
@@ -41,7 +41,7 @@ import MoreSettings from './MoreSettings'
import { MoreBelowFields as MoreBelow, MoreInlineFields as MoreInline } from './MoreWidgetFields'
import { MediaPick, Section } from './SignageFields'
import {
CELL_KINDS, cellWidget, fillPlace, FONT_KEYS, WIDGET_COLOURS, moved, newWidget, pickedAfterMove, presetWidget, WEATHER_CHOICES, weatherChoice, WIDGET_KINDS, WIDGET_POSITIONS,
CELL_KINDS, cellWidget, WEATHER_DETAILS, WEATHER_LAYOUTS, fillPlace, FONT_KEYS, WIDGET_COLOURS, moved, newWidget, pickedAfterMove, presetWidget, WEATHER_CHOICES, weatherChoice, WIDGET_KINDS, WIDGET_POSITIONS,
} from './signageLogic'
const ICON = { logo: ImageIcon, name: Store, date: CalendarDays, clock: Clock, message: MessageSquare, text: Type, qr: QrCode, weather: CloudSun, menu: UtensilsCrossed, hstack: Columns3, vstack: Rows3,
@@ -297,6 +297,10 @@ function InlineFields({ w, set }) {
onChange={v => { const [from, days] = v.split('-').map(Number); set({ weather_from: from, weather_days: days }) }}
options={WEATHER_CHOICES.map(([from, days]) => ({ value: `${from}-${days}`, label: t(`signage.widgets.weatherChoices.${from}-${days}`) }))} />
</Field>
<Field label={t('signage.widgets.weatherLayout')}>
<Dropdown value={w.weather_layout || 'row'} onChange={weather_layout => set({ weather_layout })} data-testid="signage-widget-weather-layout"
options={WEATHER_LAYOUTS.map(s => ({ value: s, label: t(`signage.widgets.weatherLayouts.${s}`) }))} />
</Field>
<Field label={t('signage.widgets.weatherStyle')}>
<Dropdown value={w.weather_style || 'both'} onChange={weather_style => set({ weather_style })} data-testid="signage-widget-weather-style"
options={['both', 'icon', 'text'].map(s => ({ value: s, label: t(`signage.widgets.weatherStyles.${s}`) }))} />
@@ -315,7 +319,27 @@ function BelowFields({ w, set, media, onMedia, extras, path, depth, selected, on
onChange={item => { onMedia(item); set({ media_id: item.id }) }} />
}
if (w.kind === 'message') return <MessageHint />
if (w.kind === 'weather') return <p className="text-caption text-ink-3 -mt-2">{t('signage.widgets.weatherNeedsInternet')}</p>
if (w.kind === 'weather') {
return (
<div className="grid gap-3">
<div className={ROW}>
<Field label={t('signage.widgets.weatherDetails')} className="col-span-2">
<Dropdown multiple value={w.weather_details || []} onChange={weather_details => set({ weather_details })} allLabel={t('signage.widgets.weatherNoDetails')}
data-testid="signage-widget-weather-details" options={WEATHER_DETAILS.map(d => ({ value: d, label: t(`signage.widgets.weatherDetail.${d}`) }))} />
</Field>
{w.weather_layout === 'hourly' && (
<Field label={t('signage.widgets.weatherHours')}>
<Dropdown value={w.weather_hours || 6} onChange={v => set({ weather_hours: Number(v) })} options={[3, 4, 6, 8, 10, 12].map(n => ({ value: n, label: String(n) }))} />
</Field>
)}
<Field label={t('signage.widgets.weatherPlace')}>
<Switch boxed className="h-control" checked={!!w.weather_place} onChange={weather_place => set({ weather_place })} label={t('signage.widgets.weatherPlaceLabel')} />
</Field>
</div>
<p className="text-caption text-ink-3 -mt-1">{t('signage.widgets.weatherNeedsInternet')}</p>
</div>
)
}
if (w.kind === 'qr') {
return (
<div className={ROW}>
@@ -174,7 +174,10 @@ export function cellWidget(kind) {
}
/** The weather's days, as one choice: from (0 today, 1 tomorrow, 2 the day after) and how many. */
export const WEATHER_CHOICES = [[0, 1], [0, 2], [0, 3], [1, 1], [2, 1]]
export const WEATHER_CHOICES = [[0, 1], [0, 2], [0, 3], [0, 5], [0, 7], [1, 1], [2, 1], [1, 3]]
/** The weather's layouts and details (6R.18). */
export const WEATHER_LAYOUTS = ['row', 'column', 'card', 'list', 'hourly']
export const WEATHER_DETAILS = ['words', 'feels', 'humidity', 'wind', 'rain', 'sun', 'uv']
export const weatherChoice = w => `${w.weather_from || 0}-${w.weather_days || 1}`
/** The picked widget's index after moving the one at `from` to `to` (the list reordered). */