Style the weather forecast after classic cable graphics
This commit is contained in:
@@ -34,7 +34,7 @@ The current host uses the NVIDIA Compose override for Tunarr's CUDA transcode pr
|
||||
|
||||
## Weather channel
|
||||
|
||||
Tune to channel 99 in the retroLabs Roku app. This host is configured for Dunnellon, FL (34431). The screen rotates through current conditions, six hourly periods, six extended forecast periods, and sunrise/sunset. Active NWS alerts appear across the rotation. The bridge caches data and marks delayed responses.
|
||||
Tune to channel 99 in the retroLabs Roku app. This host is configured for Dunnellon, FL (34431). The screen rotates through current conditions, six hourly periods, three extended forecast cards with daily highs and lows, and sunrise/sunset. Active NWS alerts appear across the rotation. The bridge caches data and marks delayed responses.
|
||||
|
||||
To set a location on another host, set `RETROTV_WEATHER_POINT` (latitude,longitude) and `RETROTV_WEATHER_LOCATION` in `.env`, then run `docker compose up -d --no-deps bridge`. The bridge serves the feed at `/api/v1/weather`. Weather is rendered by the Roku app. Its muted live inset shows the last tuned linear channel, or the first linear channel when weather is opened directly. The inset shares the tuner's video player.
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ class NWSWeather:
|
||||
"current": observation_data,
|
||||
"almanac": {key: local_time(daylight[key]) for key in ("sunrise", "sunset")},
|
||||
"hourly": future_periods(hourly, now)[:6],
|
||||
"forecast": future_periods(forecast, now)[:6],
|
||||
"forecast": future_periods(forecast, now)[:7],
|
||||
"alerts": [
|
||||
{"event": alert["event"], "headline": alert.get("headline")}
|
||||
for alert in alerts or [] if after(alert.get("ends") or alert.get("expires"), now)
|
||||
@@ -116,7 +116,8 @@ def observation(body):
|
||||
def periods(body, limit):
|
||||
return [
|
||||
{"name": item["name"] or local_time(datetime.fromisoformat(item["startTime"])), "start": item["startTime"], "end": item["endTime"],
|
||||
"temperature": item["temperature"], "conditions": item["shortForecast"]}
|
||||
"temperature": item["temperature"], "conditions": item["shortForecast"],
|
||||
"daytime": item["isDaytime"]}
|
||||
for item in body["properties"]["periods"][:limit]
|
||||
]
|
||||
|
||||
|
||||
@@ -6,22 +6,60 @@
|
||||
<children>
|
||||
<Audio id="weatherAudio" loop="true" />
|
||||
<Group id="weather" visible="false">
|
||||
<Rectangle width="1280" height="720" color="0x122D62FF" />
|
||||
<Rectangle translation="[70,120]" width="1140" height="5" color="0x78E5EBFF" />
|
||||
<Rectangle width="1280" height="720" color="0x21114FFF" />
|
||||
<Rectangle translation="[70,120]" width="1140" height="5" color="0xFFC45CFF" />
|
||||
<Label translation="[70,55]" width="900" height="55" text="retroLabs Weather"
|
||||
font="font:LargeBoldSystemFont" color="0xF8F7EFFF" />
|
||||
font="font:LargeBoldSystemFont" color="0xFFE192FF" />
|
||||
<Label id="weatherLocation" translation="[70,135]" width="1140" height="50"
|
||||
font="font:MediumBoldSystemFont" color="0x78E5EBFF" />
|
||||
<Label id="weatherHeading" translation="[70,198]" width="1140" height="42"
|
||||
font="font:MediumBoldSystemFont" />
|
||||
<Label id="weatherBody" translation="[70,252]" width="700" height="285"
|
||||
<Rectangle translation="[66,248]" width="708" height="293" color="0xCF8B38FF" />
|
||||
<Rectangle translation="[69,251]" width="702" height="287" color="0x233A99FF" />
|
||||
<Label id="weatherBody" translation="[87,267]" width="663" height="285"
|
||||
font="font:SmallSystemFont" wrap="true" numLines="8" />
|
||||
<Group id="forecastCards" translation="[70,251]" visible="false">
|
||||
<Group translation="[0,0]">
|
||||
<Rectangle width="232" height="287" color="0xCE8B38FF" />
|
||||
<Rectangle translation="[3,3]" width="226" height="281" color="0x2943A8FF" />
|
||||
<Rectangle translation="[3,3]" width="226" height="54" color="0x342371FF" />
|
||||
<Label id="forecastDay0" translation="[8,9]" width="216" height="42"
|
||||
horizAlign="center" font="font:SmallBoldSystemFont" color="0xFFE192FF" />
|
||||
<Label id="forecastCondition0" translation="[16,83]" width="200" height="100"
|
||||
horizAlign="center" vertAlign="center" wrap="true" numLines="3" font="font:SmallSystemFont" />
|
||||
<Label id="forecastTemps0" translation="[8,213]" width="216" height="50"
|
||||
horizAlign="center" font="font:SmallBoldSystemFont" />
|
||||
</Group>
|
||||
<Group translation="[234,0]">
|
||||
<Rectangle width="232" height="287" color="0xCE8B38FF" />
|
||||
<Rectangle translation="[3,3]" width="226" height="281" color="0x2943A8FF" />
|
||||
<Rectangle translation="[3,3]" width="226" height="54" color="0x342371FF" />
|
||||
<Label id="forecastDay1" translation="[8,9]" width="216" height="42"
|
||||
horizAlign="center" font="font:SmallBoldSystemFont" color="0xFFE192FF" />
|
||||
<Label id="forecastCondition1" translation="[16,83]" width="200" height="100"
|
||||
horizAlign="center" vertAlign="center" wrap="true" numLines="3" font="font:SmallSystemFont" />
|
||||
<Label id="forecastTemps1" translation="[8,213]" width="216" height="50"
|
||||
horizAlign="center" font="font:SmallBoldSystemFont" />
|
||||
</Group>
|
||||
<Group translation="[468,0]">
|
||||
<Rectangle width="232" height="287" color="0xCE8B38FF" />
|
||||
<Rectangle translation="[3,3]" width="226" height="281" color="0x2943A8FF" />
|
||||
<Rectangle translation="[3,3]" width="226" height="54" color="0x342371FF" />
|
||||
<Label id="forecastDay2" translation="[8,9]" width="216" height="42"
|
||||
horizAlign="center" font="font:SmallBoldSystemFont" color="0xFFE192FF" />
|
||||
<Label id="forecastCondition2" translation="[16,83]" width="200" height="100"
|
||||
horizAlign="center" vertAlign="center" wrap="true" numLines="3" font="font:SmallSystemFont" />
|
||||
<Label id="forecastTemps2" translation="[8,213]" width="216" height="50"
|
||||
horizAlign="center" font="font:SmallBoldSystemFont" />
|
||||
</Group>
|
||||
</Group>
|
||||
<Rectangle id="weatherPreviewFrame" translation="[800,208]" width="416" height="238"
|
||||
color="0x78E5EBFF" visible="false" />
|
||||
<Label id="weatherPreviewLabel" translation="[802,454]" width="412" height="70"
|
||||
font="font:SmallBoldSystemFont" wrap="true" numLines="2" />
|
||||
<Label id="weatherAlerts" translation="[70,553]" width="1140" height="74"
|
||||
font="font:SmallBoldSystemFont" color="0xFFD57AFF" wrap="true" numLines="2" />
|
||||
<Rectangle translation="[0,637]" width="1280" height="83" color="0x171D54FF" />
|
||||
<Label id="weatherSource" translation="[70,646]" width="1140" height="32"
|
||||
font="font:SmallSystemFont" color="0xB7D4E9FF" />
|
||||
</Group>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
sub initWeather()
|
||||
for each id in ["weatherLocation", "weatherHeading", "weatherBody", "weatherAlerts", "weatherSource", "weatherRotation", "weatherRefresh", "weatherAudio", "weatherPreviewFrame", "weatherPreviewLabel"]
|
||||
for each id in ["weatherLocation", "weatherHeading", "weatherBody", "weatherAlerts", "weatherSource", "weatherRotation", "weatherRefresh", "weatherAudio", "weatherPreviewFrame", "weatherPreviewLabel", "forecastCards"]
|
||||
m[id] = m.top.FindNode(id)
|
||||
end for
|
||||
m.weatherRotation.ObserveField("fire", "rotateWeather")
|
||||
@@ -9,6 +9,8 @@ end sub
|
||||
sub startWeather()
|
||||
m.weatherPage = 0
|
||||
m.weatherData = invalid
|
||||
m.forecastCards.visible = false
|
||||
m.weatherBody.visible = true
|
||||
m.weatherLocation.text = ""
|
||||
m.weatherHeading.text = "Loading local weather"
|
||||
m.weatherBody.text = ""
|
||||
@@ -90,6 +92,8 @@ sub rotateWeather()
|
||||
end sub
|
||||
|
||||
sub renderWeather()
|
||||
m.forecastCards.visible = false
|
||||
m.weatherBody.visible = true
|
||||
data = m.weatherData
|
||||
m.weatherAlerts.text = ""
|
||||
m.weatherSource.text = ""
|
||||
@@ -134,8 +138,9 @@ sub renderWeather()
|
||||
periods = data.hourly
|
||||
m.weatherHeading.text = "NEXT SIX HOURS"
|
||||
if m.weatherPage = 2
|
||||
periods = data.forecast
|
||||
m.weatherHeading.text = "EXTENDED FORECAST"
|
||||
if showForecastCards(data.forecast) then return
|
||||
periods = data.forecast
|
||||
end if
|
||||
lines = []
|
||||
for each period in periods
|
||||
@@ -162,3 +167,24 @@ sub updateWeatherMusic(path as dynamic)
|
||||
m.weatherAudio.content = track
|
||||
m.weatherAudio.control = "play"
|
||||
end sub
|
||||
|
||||
function showForecastCards(periods as object) as boolean
|
||||
days = []
|
||||
for i = 0 to periods.Count() - 2
|
||||
day = periods[i]
|
||||
night = periods[i + 1]
|
||||
if day.daytime = true and night.daytime = false then days.Push({day: day, night: night})
|
||||
if days.Count() = 3 then exit for
|
||||
end for
|
||||
if days.Count() < 3 then return false
|
||||
for i = 0 to 2
|
||||
suffix = StrI(i).Trim()
|
||||
forecast = days[i]
|
||||
m.top.FindNode("forecastDay" + suffix).text = UCase(forecast.day.name)
|
||||
m.top.FindNode("forecastCondition" + suffix).text = forecast.day.conditions
|
||||
m.top.FindNode("forecastTemps" + suffix).text = "Lo " + tempLabel(forecast.night.temperature) + " Hi " + tempLabel(forecast.day.temperature)
|
||||
end for
|
||||
m.weatherBody.visible = false
|
||||
m.forecastCards.visible = true
|
||||
return true
|
||||
end function
|
||||
|
||||
Reference in New Issue
Block a user