WeeWX - WU Text Forecast

134 views
Skip to first unread message

Rory Gillies

unread,
Nov 21, 2024, 5:11:25 AM11/21/24
to weewx-user
Hi, I have both the forecast and RTGD extensions installed on my WeeWX 5.1 instance. The RTGD extension displays a text forecast (in my case using the WU API) in a <canvas> scroller which I have added to my main index page:

Screenshot 2024-11-21 at 09.50.54.png

The code for the above is:

<td><h6 class="h5-responsive text-dark">  | <dfn data-info='Short term hyperlocal forecast for Lerwick'>Short Term Forecast</dfn>:</h6></td>
<td><canvas id="canvas_status" width="450" height="21"></canvas></td>


I can't find any way to pull the "narrative" using the forecast extension, but as the URL is already constructed by RTGD is there a simple way to pull the text strings out of the RTGD canvas and have it in a standard <div> tag instead? The reason is I am struggling to make the <canvas> responsive so it goes off the screen on small devices / mobiles. 

I understand that I should probably contact the extension devs directly as an issue on Github, but I know Gary frequents this group and may be able to help! TIA

gjr80

unread,
Nov 22, 2024, 9:21:22 PM11/22/24
to weewx-user
Just one clarifying point; the RTGD extension generates a data file, gauge-data.txt, that contains data in JSON format for use as the data source for the SteelSeries Weather Gauges. The RTGD extension does not generate any URL as such nor does it populate any web page with data, its sole purpose is to generate gauge-data.txt. 

The RTGD extension runs as a WeeWX service that uses a separate thread to poll a source (in your case WU) at regular intervals for the forecast text. RTGD takes this forecast text and saves it to a field in a JSON data structure in the file gauge-data.txt. RTGD does not save the forecast text field in any loop packets or archive records nor is there any connection between RTGD and the forecast extension (I believe the forecast extension may obtain data from WU but as far as I am aware it does not obtain the forecast text).

The simplest way to obtain the RTGD forecast text is to read and parse the JSON data in gauge-data.txt. Any other approach will likely involve you modifying the RTGD code base or writing your own service.

Gary

Rory Gillies

unread,
Nov 26, 2024, 2:25:32 PM11/26/24
to weewx-user
Thanks Gary, I was completely overthinking it and forgetting about gauge-data.txt! I've added a small script in index.html.tmpl to pull the forecast string out of the gauge-data.txt json string, works a treat.

<td><p class="text-dark"><dfn data-info='Short term hyperlocal forecast for Lerwick'>Short Term Forecast</dfn>:</p></td>
<td><p class="text-dark" id="fcst"></p></td>

<script>
const xmlhttp = new XMLHttpRequest();
xmlhttp.onload = function() {
  const gaugeData = JSON.parse(this.responseText);
  document.getElementById("fcst").innerHTML = gaugeData.forecast;
}
xmlhttp.open("GET", "ss/gauge-data.txt");
xmlhttp.send();
</script>

Thanks again,

Rory

Reply all
Reply to author
Forward
0 new messages