PVOuput Uploader

That is a very smart solution!

In my case I simply upload the cumulative power amount, whereas you have the actual power (the difference is Wh vs W)

The following solution works in my setup, and does away with the secret problem. It uploads power and energy generation.

In configuration.yaml:


rest_command:
  pvoutput_generation:
    method: POST
    url: https://pvoutput.org/service/r2/addstatus.jsp
    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")}}&v1={{states.sensor.growatt_energytoday.state|round(1)*1000}}&v2={{states.sensor.growatt_acpower.state|round(0)}}'
    content_type: "application/x-www-form-urlencoded"

In automations:


alias: PVOutput Uploader (rest_command)
description: Uploads values to PVOutput
trigger:
  - platform: time_pattern
    minutes: /5
    seconds: '0'
condition:
  - condition: state
    entity_id: sensor.growatt_status
    state: Normal
action:
  - service: rest_command.pvoutput_generation
    data: {}
mode: single

I am using the sensors described here : ESPHome modbus Growatt ShineWiFi-S

4 Likes

With recent modernization of the PVOutputPro integration, this should be fairly easy to add to the core integration as a service.

Will put it on my list to do, could use it myself as well (not as high priority though)

14 Likes

Awesome, thanks for that example. Based on that I’ve got a functioning configuration for a Fronius inverter. The config below uploads all the standard fields, including consumption, voltage, temperature etc. So if anyone else adapts this for there fronius choose which fields you want to upload, v1 and v3 are the essential ones I believe.

Note to deal with the ‘unknown’ state from a sensor in some circumstances the powerflow is set to default to 0, if it’s unable to be rounded.

rest_command:
  pvoutput_generation:
    method: POST
    url: https://pvoutput.org/service/r2/addstatus.jsp
    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")}}&v1={{states.sensor.energy_total_fronius_inverter_1_http_192_168_xx_xx.state|round(0)}}&v2={{states.sensor.power_photovoltaics_fronius_power_flow_0_http_192_168_xx_xx.state|round(0,default=0)}}&v3={{states.sensor.energy_real_consumed_fronius_meter_0_http_192_168_xx_xx.state|round(0)}}&v4={{states.sensor.power_load_fronius_power_flow_0_http_192_168_xx_xx.state|round(0)*-1}}&v5={{states.sensor.outdoor_temperature|float}}&v6={{states.sensor.fronius_smartmeter_voltage_ac_phase_1.state|round(0)}}&c1=1'
    content_type: "application/x-www-form-urlencoded"

I think there’s a ‘}’ too many there?

Your correct, and yet strangely enough it was working perfectly fine and HA was happy with the configuration file…

^corrected.

Is this still working for people in 2022.6?

Ah turns out you need default values for all operations now, so float(0), round(0) etc…

Still works

This thread was very useful, but when I trigger this via an automation I get this error in the trace:
Stopped because an error was encountered at September 5, 2022 at 9:30:37 PM (runtime: 0.02 seconds)
’entity_id’

Any ideas on how to resolve this?
Using the rest_command

Can you post a snippet of your code? Seems you have an issue with entity_id

Edit, both rest and automation.

Thanks, I made some progress but did not get a result.

rest_command:
  pvoutputpro:
    url: https://pvoutput.org/service/r2/addoutput.jsp
    method: POST
    headers:
      X-Pvoutput-Ap:ikey: xxxxxxxxxxxxxxxxxxxxxxx"
      X-Pvoutput-SystemId: "yyyyy"
      accept: "application/json"
      user-agent: 'Mozilla/5.0 {{ useragent }}'
      payload: 'd={{now().strftime("%Y%m%d")}}&t={{now().strftime("%H:%M")}}&v1={{states.sensor.yield_energy_daily_wh.state|float(0)|round(0)}}&v2={{states.sensor.solar_power_c.state|float(0)|round(0)}}v3={{states.sensor.grid_consumption_energy_wh.state|float(0)|round(0)}}&v4={{states.sensor.load_power.state|float(0)|round(0)}}&v6={{states.sensor.solar_voltage_a|float(0)}}&c1=1'

      content_type: "application/x-www-form-urlencoded"

and the automation (which works)

- id: '1662376140100'
  alias: Pvoutput_trigger
  description: Posts data to pvoutput.org
  trigger:
  - platform: time_pattern
    minutes: /5
  condition: []
  action:
  - service: rest_command.pvoutputpro
    data: {}
  mode: single

Any help appreciated.

rest_command:
  pvoutputpro:
    url: https://pvoutput.org/service/r2/addoutput.jsp
    method: POST
    headers:
      X-Pvoutput-Ap:ikey: xxxxxxxxxxxxxxxxxxxxxxx" <<<< does this have a typo? should be  X-Pvoutput-Apikey:
      X-Pvoutput-SystemId: "yyyyy"
      accept: "application/json"
      user-agent: 'Mozilla/5.0 {{ useragent }}'     <<< I don't use this 
    payload: 'd={{now().strftime("%Y%m%d")}}&t={{now().strftime("%H:%M")}}&v1={{states.sensor.yield_energy_daily_wh.state|float(0)|round(0)}}&v2={{states.sensor.solar_power_c.state|float(0)|round(0)}}v3={{states.sensor.grid_consumption_energy_wh.state|float(0)|round(0)}}&v4={{states.sensor.load_power.state|float(0)|round(0)}}&v6={{states.sensor.solar_voltage_a|float(0)}}&c1=1'
    content_type: "application/x-www-form-urlencoded"

Your indents are out compared to mine, I edited yours above. I don’t use the accept line either(although I doubt that matters.)
You also have an extra : in the api key line.

"d={{now().strftime('%Y%m%d&t=%H:%M')}}&
I use that for the datetime

thats my whole payload line, although mine converts from kWh back to Wh

payload: "d={{now().strftime('%Y%m%d&t=%H:%M')}}&c1=3&v3={{states('sensor.powerpal_total_consumption')| float * 1000 }}&v4={{states('sensor.powerpal_live_consumption')| float * 1000 }}"
    

Might be worth checking your c1 flag too…

The following values are valid for the c1 flag.

  • 1 - Both v1 and v3 values are lifetime energy values. Consumption and generation energy is reset to 0 at the start of the day.
  • 2 - Only v1 generation is a lifetime energy value.
  • 3 - Only v3 consumption is a lifetime energy value.

pvo api spec

Thanks for the help and pointing out silly typos that must have crept in. Really appreciated.
I reworked my payload and checked the formatting on the developer tools/template page which was super helpful as I found one value with a trailing .state missing!

I had converted values to Wh in a template before the payload

This is the payload now.

    payload: 'd={{now().strftime("%Y%m%d&t=%H:%M")}}&v1={{states.sensor.yield_energy_wh.state|float(0)|round(0)}}&v2={{states.sensor.solar_power_c.state|float(0)|round(0)}}v3={{states.sensor.grid_consumption_energy_wh.state|float(0)|round(0)}}&v4={{states.sensor.load_power.state|float(0)|round(0)}}&v6={{states.sensor.solar_voltage_a.state|float(0)}}&c1=1'

I’m a bit worried pvoutput.org won’t like changing from 14 year old inverter totals to totals from a new energy meter.

Is there any way to see the returned status?
I’ll see what happens tomorrow during sunlight hours…

I can’t say I’ve figured out where to find the returned status for a rest post…

I get a returned status from SBFspot, that doesn’t really help you though.

It does take about 5 mins for PVo to update I find…

1 Like

Found it!

If you add this to configuration.yaml

logger:
  default: info
  logs:
    homeassistant.components.rest_command: debug     

It reports the reult in home-assistant.log (search for debug)

2022-09-15 22:20:01.359 DEBUG (MainThread) [homeassistant.components.rest_command] Success. Url: https://pvoutput.org/service/r2/addoutput.jsp. Status code: 200. Payload: b'd=20220915&t=22:20&v1=2021047&v2=0v3=1278895&v4=1181&v6=238.7&c1=1'

So the 200 Sucess status confirms the data is gettig to pvoutput.org :rofl:

1 Like

And do you also see live data on your pvoutput page ?

I can’t seem to get it to work:
I am getting a 200 succes status:

(MainThread) [homeassistant.components.rest_command] Success. Url: https://pvoutput.org/service/r2/addoutput.jsp. Status code: 200. Payload: b’d=20220926&t=12:25&v1=635&v2=293&v3=293&v4=0&v6=239.47&v7=214.0&v8=164.0&c1=1’

pvoutputpro:

url: 'https://pvoutput.org/service/r2/addoutput.jsp'

method: POST

headers:

  X-Pvoutput-Apikey: '123'

  X-Pvoutput-SystemId: '72310'

  accept: "application/json"

payload: 'd={{now().strftime("%Y%m%d&t=%H:%M")}}&v1={{states.sensor.sb3_0_1av_41_224_daily_yield.state|float(0)|round(0)}}&v2={{states.sensor.sb3_0_1av_41_224_grid_power.state|float(0)|round(0)}}&v3={{states.sensor.sb3_0_1av_41_224_grid_power.state|float(0)|round(0)}}&v4={{states.sensor.electricity_meter_power_consumption.state|float(0)|round(0)}}&v6={{states.sensor.sb3_0_1av_41_224_voltage_l1.state|float(0)}}&v7={{states.sensor.sb3_0_1av_41_224_pv_power_a.state|float(0)}}&v8={{states.sensor.sb3_0_1av_41_224_pv_power_b.state|float(0)}}&c1=1'

content_type: "application/x-www-form-urlencoded"

Any thoughts?

V7 and v8 require a donations account. Not sure what happens if you send those without having donated (although you might have a donations account).

looks reasonable otherwise except for v2 and v3 value seem to be the same. I get 5min live data.

Payload: b’d=20220926&t=12:25&v1=635&v2=293&v3=293&v4=0&v6=239.47&v7=214.0&v8=164.0&c1=1’
v2=293&v3=293

v2= grid_power.state power gen ?
v3= grid_power.state energy consumption?

Use addstatus.jsp in the url.
I got it wrong too and was pointed in the right direction

ref: Home Assistant data not received on status 200 - #2 by hassma - API - PVOutput Community

I also found it very useful to paste the payload string into the template tab to check the formatting was correct while debugging.

1 Like

I tried to configure this but I don’t see any data appear on PVOutput.
I also can’t find the logs in HA folks in this thread describe.
I only have the log of the automation:

Upload PV output
Step DetailsTrace TimelineRelated logbook entriesAutomation Config
Triggered by the time pattern at January 16, 2023 at 11:00:00
Shell Command:
Finished at January 16, 2023 at 11:00:00 (runtime: 0.02 seconds)

Where can I find the detailed logs about the shell command?
Sorry for my novice questions.

I am running this code that looks very similar to the code above. PVOutput is saying I am on line, but it seems to have no data. What am I missing?

rest_command:
  update_pvoutput:
    url: https://pvoutput.org/service/r2/addstatus.jsp
    method: post
    content_type: "application/x-www-form-urlencoded"
    headers:
        X-Pvoutput-Apikey:
        X-Pvoutput-SystemId: 
    payload: >-
        d={{now().strftime("%Y%m%d")}}
        &t={{now().strftime("%H:%M")}}
        &c1=2
        &v1={{(states('sensor.lux_solar_output_live'))|round(0) }}
        &v3={{(states('sensor.lux_home_consumption_live'))|round(0) }}
        &v7={{(states('sensor.lux_solar_output_array_1_live'))|round(0) }}
        &v8={{(states('sensor.lux_solar_output_array_2_live'))|round(0) }}

This is the output from the template editor

rest_command:
  update_pvoutput:
    url: https://pvoutput.org/service/r2/addstatus.jsp
    method: post
    content_type: "application/x-www-form-urlencoded"
    headers:
        X-Pvoutput-Apikey: xxxxx
        X-Pvoutput-SystemId: yyyyy
    payload: >-
        d=20230320
        &t=09:16
        &c1=2
        &v1=351
        &v3=444
        &v7=143
        &v8=208