# Visualizing My Rooftop Solar Power in Grafana Was More Fun Than I Expected

> Source: https://www.ymotongpoo.com/blog/20261202-solar-weather-grafana-pages/


{{< message >}}
- [Collector Extra](https://github.com/ymotongpoo/opentelemetry-collector-extra) 0.4.0 (my distribution of the OpenTelemetry Collector, which includes my own receivers)
- Grafana Cloud (Grafana Pages is in public preview)
- The solar power data comes from the data collection unit of Smart Heim Navi, a HEMS. The weather data comes from two sources: observations at the JMA observatory nearest to my home, and model values from Open-Meteo.
{{< /message >}}

## Introduction

I first wrote this article in Japanese for day 2 of the [Grafana Advent Calendar 2026](https://qiita.com/advent-calendar/2026/grafana). I bought my house second-hand, and it came with solar panels already on the roof. I can see the solar power on the screen of the HEMS[^hems], but its bundled dashboard is hard to read. So I decided to send the data to [Grafana Cloud](https://grafana.com/products/cloud/) and visualize it myself. At first I sent only the solar power. Later I added weather data and overlaid the two. The result was more interesting than I expected, and this article is about that.

[^hems]: A HEMS (Home Energy Management System) measures and displays the power that a home generates and consumes.

## TL;DR

I read the solar power data from the HEMS's CGI on my home network every 30 seconds. I took solar irradiance, weather, and precipitation in one-hour steps from the Japan Meteorological Agency (JMA) and Open-Meteo. Custom receivers in the [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/) collect all of this data and send it to Grafana Cloud. One [Grafana Pages](https://grafana.com/docs/grafana-cloud/platform/grafana-assistant/platform/pages/) page overlays it all. The solar power closely follows the irradiance that the JMA observatory measured. On some days, it differs from the Open-Meteo model values. When clouds pass over, the solar power swings up and down within minutes. Hourly observations and models cannot show these swings, which reflect the weather directly above my roof.

## How the data flows

The solar power data and the weather data come from different sources and update at different intervals. As Figure 1 shows, I wrote one receiver[^receiver] for each source and put all of them in one Collector[^collector] on a host at home. An exporter[^exporter] in the Collector sends the collected data out over OTLP[^otlp].

The destination is not Grafana Cloud. It is [Grafana Alloy](https://grafana.com/docs/alloy/latest/) on the same host. Alloy already ran on this host for another purpose and handled the uploads to Grafana Cloud. If I reuse that Alloy, the Collector does not need Grafana Cloud credentials. So the Collector passes the data to Alloy, and Alloy forwards it to Grafana Cloud. Another reason is that you cannot add arbitrary OpenTelemetry components to Alloy.

![The data flow from the sources to Grafana Pages](20261202-data-flow.png)
*Figure 1: The data flow from the sources to Grafana Pages. Solid lines are solar power metrics, and dashed lines are weather logs. In the Collector, three receivers collect the data, and the exporter sends it to Alloy. In Grafana Cloud, the arrows point to the data that Pages queries.*

The solar power data goes into [Grafana Mimir](https://grafana.com/oss/mimir/) as metrics. The weather data goes into [Grafana Loki](https://grafana.com/oss/loki/) as logs. I explain later why I did not store the weather data as metrics.

[^receiver]: A receiver is the Collector component that brings data into the Collector. Some receivers wait for incoming data, and others fetch data themselves. All three receivers in this article fetch data themselves.

[^collector]: The OpenTelemetry Collector is a program that receives telemetry (metrics, logs, and traces), processes it, and sends it to storage backends. You can build your own distribution that contains only the components that you need. Collector Extra is one such distribution.

[^exporter]: An exporter is the Collector component that sends data out of the Collector. There are exporters for different destinations and protocols. Here I use `otlp_http`, which sends OTLP over HTTP.

[^otlp]: OTLP (OpenTelemetry Protocol) is the protocol that OpenTelemetry uses to send and receive telemetry.

## Reading the solar power from a CGI on the home network

The data collection unit of Smart Heim Navi serves a page of measurements that you can open in a browser on the home network. However, it has no public API. The CGI that serves the page does not return JSON. It returns only HTML in Shift_JIS. To bring this data into OpenTelemetry, I needed a dedicated receiver that reads the HTML and extracts the numbers. That is why I wrote the [`smartheim` receiver](https://github.com/ymotongpoo/opentelemetry-collector-extra/tree/main/receiver/smartheimreceiver). It reads the page every 30 seconds and sends the solar power and the power consumption as metrics in watts.

## Getting the weather from two sources

I wanted to compare the solar power with these weather values: solar irradiance, sunshine duration, precipitation, temperature, cloud cover, and weather conditions. I used two sources: the [JMA historical weather data](https://www.data.jma.go.jp/stats/etrn/index.php) and [Open-Meteo](https://open-meteo.com/). Open-Meteo is a service with a free API that returns values that weather models calculate[^attribution]. I use two sources because each one lacks some values that I need.

| Source | Receiver | Kind of value | Main values | Available period |
| --- | --- | --- | --- | --- |
| JMA (nearest observatory) | [`jma`](https://github.com/ymotongpoo/opentelemetry-collector-extra/tree/main/receiver/jmareceiver) | Observed | Irradiance, sunshine duration, precipitation, cloud cover, weather conditions | Yesterday and earlier |
| Open-Meteo | [`openmeteo`](https://github.com/ymotongpoo/opentelemetry-collector-extra/tree/main/receiver/openmeteoreceiver) | Model | Irradiance, cloud cover, weather codes, sunrise and sunset | Today and forecasts |

The JMA values are real observations, but the hourly table only goes up to yesterday. Irradiance, cloud cover, and weather conditions appear only in the observatory's table. The nearby AMeDAS stations do not record them[^amedas]. Open-Meteo also returns today's values and forecasts. However, it calculates them at grid points, so they may not match the weather above my roof. For this reason, I send the JMA observations and the Open-Meteo model values as separate series. Neither source replaces values from the other.

[^attribution]: The weather data in this article comes from the JMA historical weather data and from Open-Meteo ([Open-Meteo.com](https://open-meteo.com/), CC BY 4.0).

[^amedas]: The AMeDAS hourly tables have no columns for irradiance, cloud cover, or weather conditions. Also, since March 2, 2021, the AMeDAS sunshine duration is an estimate that JMA derives from sources such as weather satellite observations. The `jma` receiver sends these estimates separately from observed values.

### Why I send the weather data as logs

JMA sometimes corrects values after it publishes them. The `jma` receiver fetches the last 7 days again every day and the last 30 days again every week. When a value changes, the receiver sends it as a new **revision**, a numbered record that separates the values before and after a correction. As a result, a correction to the irradiance for October 25 can arrive on October 28. A metrics store such as Mimir cannot overwrite a sample at the same timestamp in the same series with a different value. Data whose past values change later does not fit metrics.

So I send each weather value as one JSON log line. In addition to the value itself, each log line has these fields:

- `period_start` and `period_end`: the time period that the value covers
- `observation_key`: an identifier for the combination of source, location, variable, and time period
- `retrieved_at`: the time when the receiver fetched this revision
- `event_id`, `revision`, and `supersedes`: the identifier of the revision, and the revision that it replaces

The timestamp of each log line is the time when the receiver sent it. Suppose that you want the weather for October 25. If you query Loki only for logs from October 25, you miss the corrections that arrived later. Instead, the page queries a wide enough range of send times. For each `observation_key`, it picks the revision with the latest `retrieved_at`. Then it plots the values with `period_end` as the time axis. The Loki query itself is simple:

```logql
{service_name=~"weather-(openmeteo|jma)"} | json
```

## Overlaying all the data in Grafana Pages

Grafana Pages is a feature that builds a page from Grafana Cloud data when you ask [Grafana Assistant](https://grafana.com/docs/grafana-cloud/platform/grafana-assistant/) for one. Some layouts and processing do not fit a combination of dashboard panels. With Pages, the Assistant writes them as the code of the page. Each time someone opens a page, the page queries the data sources with that viewer's permissions. At the time of writing, Pages is in public preview and is not available in self-managed Grafana.

After Mimir and Loki had collected a fair amount of solar power data and weather logs, I gave the Assistant in Pages a rough request. I asked it to draw charts that might show how this data is related. That alone produced the page in Figure 2. The page has three tabs: "Daily generation", "Sunshine & solar", and "Tomorrow".

![The "Daily generation" tab of the "Solar Power and Weather" page in Grafana Pages](20261202-pages-overview.png)
*Figure 2: The "Daily generation" tab of the "Solar Power and Weather" page that I built with Grafana Pages. I opened it in Grafana Cloud, and it shows measured values for November 28, 2026. The top row shows the energy generated in the day, the peak output, the JMA sunshine duration, and the sunrise and sunset times. The middle chart overlays the power and the weather. The bottom row shows the sunshine duration, the cloud cover and precipitation, and the weather at each hour, in one-hour steps.*

The daily generation of 11.87 kWh is an estimate that the page calculated from the instantaneous values at 30-second intervals. The page also came with notes on how to read the charts. The lines have gaps where data is missing. Values with the JMA quality flags "quasi-normal" or "insufficient data" appear as dotted reference lines. Cloud cover is an instantaneous value on each hour, so the page does not interpolate between hours. A weather icon shows the weather at that time only, and the weather did not necessarily last the whole hour. Each note matches a field that the receivers attach to every value in the logs: unit, aggregation method, or quality. I think that the Assistant read those fields and wrote the notes from them.

## What I learned from the overlaid data

Figure 3 is an enlarged view of the center chart in Figure 2. The left axis shows the solar power and the power consumption, and the right axis shows the irradiance. A band of cloud cover runs along the top, and precipitation bars sit at the bottom.

![A chart that overlays the JMA and Open-Meteo irradiance, cloud cover, and precipitation on the solar power and power consumption](20261202-pages-day-chart.png)
*Figure 3: A chart in the "Daily generation" tab of the page in Figure 2, for November 28, 2026. The orange line is the solar power (W), and the light brown line is the power consumption (W). The cyan solid line is the JMA irradiance, an average over the previous hour in W/m². The purple dashed line is the Open-Meteo irradiance (model values). The band at the top is the Open-Meteo cloud cover, and the bars at the bottom are the Open-Meteo precipitation. The dark shading marks the hours before sunrise and after sunset.*

The first thing that stands out is how closely the solar power follows the JMA irradiance. On this day, it rained until the morning, and generation started at around 8:00. The JMA irradiance was highest in the hour from 11:00 to 12:00. In that same hour, the solar power reached its peak of 5,010 W at 11:31. In the afternoon, the solar power fell as the irradiance steps went down, and it reached 0 shortly after 16:00.

This relationship holds on other days too. The "Sunshine & solar" tab has a scatter plot of each daytime hour over the last 7 completed days (Figure 4). The horizontal axis is the JMA irradiance, and the vertical axis is the solar power in the same hour. The points fall almost on one line. The page shows a correlation coefficient of r = 1.00 (to two decimal places) as a reference value. A note on the page says that it only pairs values from the same hour. The note also says that the plot shows neither causation nor panel efficiency. The sun elevation, the panel orientation, and shade also change the solar power.

![A scatter plot of the JMA irradiance and the solar power](20261202-pages-correlation-jma.png)
*Figure 4: A scatter plot in the "Sunshine & solar" tab of the Grafana Pages page, opened in Grafana Cloud. It plots the JMA irradiance (horizontal axis, average over the previous hour in W/m²) against the solar power in the same hour (vertical axis, W). It covers 66 daytime hours from November 25 to December 1, 2026, for which both values exist, with one color for each day.*

The Open-Meteo model values, on the other hand, sometimes miss. When I switch the horizontal axis in the same tab to the Open-Meteo irradiance, the points spread out more (Figure 5). The correlation coefficient stays high at 0.98. However, in some hours the model value was 240 to 340 W/m², but the solar power stayed between about 650 and 1,050 W. In another hour, the model value was only about 265 W/m², but the solar power reached about 2,200 W.

![A scatter plot of the Open-Meteo irradiance and the solar power](20261202-pages-correlation-openmeteo.png)
*Figure 5: The scatter plot in the same tab as Figure 4, opened in Grafana Cloud. The horizontal axis is switched to the Open-Meteo irradiance (model values, W/m²). It covers 77 daytime hours in the same 7 days, for which both values exist.*

The gap also shows within a single day. On November 28, the Open-Meteo irradiance was much higher than the JMA observations from 13:00 onward. The sunshine duration in the bottom row of Figure 2 shows the same gap. The JMA observations had only three hours with 30 to 50 minutes of sunshine. The Open-Meteo model values put 60 minutes in most hours from 9:00 to 15:59. If you estimate the solar power from the Open-Meteo values alone, you can be far off on days like this one.

The most interesting part was how the solar power swung between about 10:30 and 13:00. Within a few minutes, it moved back and forth between the 1 kW range and almost 5 kW, many times. The JMA irradiance is an hourly average, so the steps in the chart smooth out these swings. I think that clouds drifted over the roof, and the sun came and went. The JMA observatory measures at one point away from my home, and Open-Meteo calculates values at grid points. Neither one shows the weather over an area as small as my roof. The solar power at 30-second intervals shows the changes in sunlight on my roof better than either source.

## Conclusion

You can also ask a local AI coding agent to draw charts like these. In that case, you keep a token for reading Grafana Cloud data on your machine, and the agent draws the data into a local file. If you share that file, everyone who receives it can see the data embedded in it. With Grafana Pages, the page runs inside Grafana Cloud, and each query runs with the permissions of the person who opens the page. So you can show the same charts with the latest data, and only to the people who are allowed to see them.

You can try Grafana Pages with a free Grafana Cloud account. On the [sign-up page](https://grafana.com/auth/sign-up/create-user), you only need an email address, and you do not need a credit card. If you have data sitting around unused, give Grafana Pages a try!

