# Home Assistant: sending Zonneplan One stats to PVOutput

**Date:** 2024-09-16  
**Author:** Kees C. Bakker  
**Categories:** Automation  
**Original:** https://keestalkstech.com/home-assistant-sending-zonneplan-one-stats-to-pvoutput/

![Home Assistant: sending Zonneplan One stats to PVOutput](https://keestalkstech.com/wp-content/uploads/2024/09/evgeniy-alyoshin-2ASQyjafflo-unsplash.jpg)

---

Last year, I got some Zonneplan solar panels. My colleagues and I got hooked on comparing stats, so we decided to upload our solar panel stats to PVOutput and build a Telegram bot to keep score:

![Screenshot of our private Telegram channel. Our bot posts automatic messages to inform us about the score.](https://keestalkstech.com/wp-content/uploads/2024/09/WhatsApp-Image-2024-09-16-at-20.19.27-1.jpeg)
*Screenshot of our private Telegram channel. Our bot posts automatic messages to inform us about the score.*

As a .NET developer, I built a .NET application that connected to the Zonneplan API and posted the data to PVOutput every 5 minutes. It worked, but I couldn’t achieve a stable performance. Whenever there was a hiccup, I would lose the key and have to reconnect. Therefore, I decided to migrate my setup to Home Assistant.

Apparently the automation definition has changed in Home Assistant. The code is now compatible with Home Assistant version `2024.10.3`.

## What's the idea?

We'll do this:

1. Add the Zonneplan integration.
2. Add Visual Studio Code add-on.
3. Use `secrets.yaml` to store the PVOutput API Key and SystemId.
4. Use `configurations.yaml` to add a [RESTful command](https://www.home-assistant.io/integrations/rest_command/) that sends the Zonneplan sensor data to PVOutput.
5. Use `automations.yaml` to trigger the command.
6. Restart & enjoy.

The beauty of this way is that you don't need Bash or Python, it is just YAML.

## Home Assistant + Zonneplan

The first step is to install the Zonneplan integration in your Home Assistant. Make sure [HACS](https://www.hacs.xyz/docs/use/configuration/basic/) is installed and add the repository [](https://my.home-assistant.io/redirect/hacs_repository/?owner=fsaris&repository=home-assistant-zonneplan-one)[https://github.com/fsaris/home-assistant-zonneplan-one](https://github.com/fsaris/home-assistant-zonneplan-one), by hitting this button:

[![Direct link to Zonneplan in HACS](https://keestalkstech.com/wp-content/uploads/2026/03/hacs-button.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=fsaris&repository=home-assistant-zonneplan-one)

After restarting your Home Assistant, you can set up the integration, by hitting this button:

[![Open your Home Assistant instance and start setting up Energy sensors.](https://keestalkstech.com/wp-content/uploads/2026/03/hacs-button.svg)](https://my.home-assistant.io/redirect/config_energy/)

After completing the setup, you'll see data flowing in. [More information can be found here](https://github.com/fsaris/home-assistant-zonneplan-one).

## Preparation: install VS Code in Home Assistant

We're going to edit some Home Assistant YAML files, so it is nice to have a good editor. Let's install Visual Studio Code into your Home Assistant by hitting this button:

[![Open this add-on in your Home Assistant instance.](https://keestalkstech.com/wp-content/uploads/2026/03/hacs-button.svg)](https://my.home-assistant.io/redirect/supervisor_addon/?addon=a0d7b954_vscode&repository_url=https%3A%2F%2Fgithub.com%2Fhassio-addons%2Frepository)

## Secrets

First, we need to add some secrets, so let's click on the Studio Code Server tab to and open the `secrets.yaml`. Here we'll add the secrets for our PVOutput call:

```yaml
pvoutput_api_key: 003044-your-pvoutput-api-key-92aa93
pvoutput_system_id: 1244-your-system-id-234
```

## Command

Next, you'll need to add the command to `configuration.yaml` and add the command. We're going to fire an `addstatus.jsp` request. [The docs specify the following parameters](https://pvoutput.org/help/api_specification.html#add-status-service):

- v1 = energy generation in watt hours
- v2 = power generation in watts

Notice how Zonneplan will return `zonneplan_yield_today` in `kWh`, so we need to multiply with `1000` to convert the value to watts.

Paste the following to your `configuration.yaml`:

```yaml
rest_command:
  post_pvoutput_data:
    url: "https://pvoutput.org/service/r2/addstatus.jsp"
    method: POST
    headers:
      X-Pvoutput-Apikey: !secret pvoutput_api_key
      X-Pvoutput-SystemId: !secret pvoutput_system_id
    payload: >
      {{
        "d=" ~ now().strftime('%Y%m%d') ~
        "&t=" ~ now().strftime('%H:%M') | urlencode ~
        "&v1=" ~ states('sensor.zonneplan_yield_today') | float * 1000 | int ~
        "&v2=" ~ states('sensor.zonneplan_one_omvormer_last_measured_value') | int
      }}
    content_type: "application/x-www-form-urlencoded"
```

## Trigger

Last but not least, we'll need to create something that *triggers* the command. Let's trigger *before* and *after* sunset. PVOutput allows us to upload something every 5 minutes, so let's stick to that. Let's offset the time with 20 seconds to make sure we have received the update from Zonneplan.

These stats lead to the following automation:

```yaml
- id: post_to_pvoutput
  alias: "Post to Zonneplan every 5 minutes during the day."
  trigger:
    - trigger: time_pattern
      minutes: "/5"
      seconds: 20
  condition:
    - condition: sun
      before: sunset
      before_offset: "00:30:00"
    - condition: sun
      after: sunrise
      after_offset: "-00:30:00"
  actions:
    - action: rest_command.post_pvoutput_data
```

*Note: adding an `id` makes the automation editable in the Home Assistant UI.*

All you now need to do is restart your Home Assistant and you'll be done.

## Debugging

Debugging a rest command is a pain in the ***. We have some options in Home Assistant to see what's going on.

- *Logs*: **Settings** > **System** > **Logs**.
- *Automation traces*: trace every run with a nice UI, go to **Settings** > **Automations & Scenes** > **Post Zonneplan data to PVOutput when the data changes** > **Traces** (top right corner):

![Debug the automation run from the Home Assistant traces UI.](https://keestalkstech.com/wp-content/uploads/2024/09/image.png)
*Debug the automation run from the Home Assistant traces UI.*

- *Command*: If you want to trigger the *command*, you can execute it from the UI as well. Navigate to **Developer Tools** > **Actions** > **RESTful Command: post_pvoutput_data** and hit the **Perform Action** button.

![Debug the command itself through the Home Assistant UI.](https://keestalkstech.com/wp-content/uploads/2024/09/image-1.png)
*Debug the command itself through the Home Assistant UI.*

## Changelog

- 2024-10-22: This code works with the new automation definition of Home Assistant version `2024.10.3`.
- 2024-10-02: Changed the trigger to a cron to make an easier setup.
- 2024-09-17: Changed the command into a multi-line command using `~` templating.
- 2024-09-17: Added debug sections.
- 2024-09-16: Initial article.
