WeeWX LoopData — make your skins come alive

View on GitHub Download weewx-loopdata.zip Report an issue

With LoopData, the tags in your WeeWX reports can be updated on every LOOP packet — typically every few seconds — instead of waiting for the next archive interval and page reload. This works for nearly every tag you would use in a report: current observations, trends, aggregates over hours, days, weeks, months, years and rolling windows — including almanac tags, station tags and unit labels.

This is the sample report included with the extension — a NOAA-style windrose and eleven gauges, drawn by a few hundred lines of dependency-free canvas javascript. Every needle, petal and readout on this page redraws on every loop packet, and gauges for sensors a station does not have (UV, solar radiation, air quality) hide themselves automatically:

The LoopData sample report: a live instrument panel

Requirements: Python 3.7 or later and WeeWX 4 or 5. No third-party Python packages.

The whole idea in one example

Say your report template shows a current condition, a daily aggregate and an almanac time:

Temperature: $current.outTemp
High today: $day.outTemp.max
Sunset: $almanac.sunset

List those same tags — with the $ removed — on the fields line of the [LoopData] section of weewx.conf:

[LoopData]
    [[Include]]
        fields = current.outTemp, day.outTemp.max, almanac.sunset

Now, on every loop packet, LoopData writes a json file, loop-data.txt, with those tags as its keys — and every value already unit-converted and formatted exactly as your report would render it:

{"current.outTemp": "79.2°F", "day.outTemp.max": "85.1°F", "almanac.sunset": "20:32"}

Finally, in the template, wrap each tag in an element whose id is the tag, and add a few lines of javascript to fill those elements from loop-data.txt:

Temperature: <span id="current.outTemp">$current.outTemp</span><br/>
High today: <span id="day.outTemp.max">$day.outTemp.max</span><br/>
Sunset: <span id="almanac.sunset">$almanac.sunset</span>

<script>
  async function updateLoopData() {
    const response = await fetch('loop-data.txt', {cache: 'no-store'});
    const data = await response.json();
    for (const key in data) {
      const element = document.getElementById(key);
      if (element) element.innerHTML = data[key];
    }
  }
  setInterval(updateLoopData, 2000);  // match your loop frequency
</script>

The page loads showing the values Cheetah rendered at report time, then comes alive: every wrapped tag updates as fast as your station reports. That is all there is to it.

Where to go next

  • Installation — install the extension and check that it is running.
  • Configuration — every [LoopData] option in weewx.conf.
  • Field reference — the full grammar: periods, aggregates, unit overrides, round(n) and format specs.
  • The live windrose — the windrose observation type and how to tune its speed bands for your site.
  • Almanac fields — sunrise, moon phase, planet positions and more, computed live.
  • Station fields$station tags as live fields, including a restart-correct uptime.
  • Building a live page — the recipe for using LoopData in your own skin, with production-grade javascript.
  • The sample skin — the instrument panel that ships with the extension.
  • Translations — the sample report in your language (German, French, Dutch and Spanish ship), and which report’s language governs which string.
  • Syncing to a remote server — rsync configuration and troubleshooting.
  • How LoopData works — architecture and performance.
  • Troubleshooting — symptoms and fixes.

See it in action

This extension was inspired by Gary Roderick’s weewx-realtime_gauge_data extension (its GitHub repository is no longer available).

About this manual

This manual describes loopdata 6.3 and later. The full release history is in changes.txt on GitHub.

Licensing

weewx-loopdata is licensed under the GNU Public License v3.


weewx-loopdata is Copyright © 2020–2026 John A Kline and is licensed under the GNU Public License v3.

This site uses Just the Docs, a documentation theme for Jekyll.