Skip to content

Instantly share code, notes, and snippets.

@mathieucarbou
Last active January 19, 2026 09:03
Show Gist options
  • Select an option

  • Save mathieucarbou/d9794c3544cd12485c73121a89702f96 to your computer and use it in GitHub Desktop.

Select an option

Save mathieucarbou/d9794c3544cd12485c73121a89702f96 to your computer and use it in GitHub Desktop.
PVOutput Integration for Home Assistant

PVOutput Integration for Home Assistant

My PVOutput: https://pvoutput.org/list.jsp?userid=131277

You first need some sensors:

  • sensor.inverters_energy => energy produced

Optionnally you can add:

  • sensor.solar_production_power => produced power
  • sensor.home_consumed_energy_meter_daily => energy consumed by home (includes consumed solar energy + imported grid energy)
  • sensor.max_inverter_voltage => maximum inverter voltage value (help catch inverters going down upon high voltage)
  • sensor.grid_voltage => grid voltage
  • sensor.inverters_producing_count => number of inverters currently producing (this can be removed)

Remove from the URL call what you do not use

#
# Energy Generation + Import = Energy Used + Export
#

# https://www.home-assistant.io/integrations/rest_command
rest_command:
  # https://pvoutput.org/help/api_specification.html#add-status-service
  pv_output_live:
    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
    # dt, tm = date & time
    # pe, pp, pv = production energy, power and voltage
    # gv = grid voltage
    # he = Energy consumed by home
    # temp = Outdoor temperature
    # m = message with the number of inverters producing
    payload: >-
      {% set dt = now().strftime("%Y%m%d") %}
      {% set tm = now().strftime("%H:%M") %}
      {% set pe = (states("sensor.inverters_energy")|float(0) * 1000)|int(0) %}
      {% set pp = states("sensor.solar_production_power")|int(0) %}
      {% set pv = states("sensor.max_inverter_voltage")|float(0) %}
      {% set gv = states("sensor.grid_voltage")|float(0) %}
      {% set he = (states("sensor.home_consumed_energy_meter_daily")|float(0) * 1000)|int(0) %}
      {% set temp = states("sensor.ws3800a_outdoor_temperature")|float(-1000) %}
      {% set m = ("Inverters:" + states("sensor.inverters_producing_count") + "/8")|urlencode %}
      {% if temp == -1000 %}
        d={{dt}}&t={{tm}}&v1={{pe}}&v2={{pp}}&v3={{he}}&v6={{pv if pv > 0 else gv}}&c1=1&m1={{m}}
      {% else %}
        d={{dt}}&t={{tm}}&v1={{pe}}&v2={{pp}}&v3={{he}}&v5={{temp}}&v6={{pv if pv > 0 else gv}}&c1=1&m1={{m}}
      {% endif %}
    content_type: "application/x-www-form-urlencoded"

# https://www.home-assistant.io/docs/automation/
automation:
  # Upload PV data to https://pvoutput.org/
  - id: "0000000000060"
    alias: "PVOutput Upload"
    triggers:
      - trigger: time_pattern
        minutes: "*"
    conditions: []
    actions:
      - action: rest_command.pv_output_live
        data: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment