PVOuput Uploader

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

Any progress on integrating upload capability into core? It would be incredibly useful and powerful to have HA be able to upload its data (since it can come from multiple sources) to pvoutput and emoncms so that we can compare data with other users. I think this would lead to a large number of HA adoption as many in the energy monitoring community are using old antiquated techniques. Thanks!

3 Likes

I have a strange issue. I am not getting the v7 or v8 data depending on where I put it in the YAML. Using my example I get the v8 data, but not the v7. If I swap it around like this, I get the v7 and not the v8.

    payload: >-
        d={{now().strftime("%Y%m%d")}}
        &t={{now().strftime("%H:%M")}}
        &v2={{(states('sensor.lux_solar_output_live'))|round(0) }}
        &v4={{(states('sensor.lux_home_consumption_live'))|round(0) }}
        &v5={{(states('sensor.met_office_buntingford_temperature_3_hourly'))|round(0) }}
        &v8={{(states('sensor.lux_solar_output_array_2_live'))|round(0) }}
        &v7={{(states('sensor.lux_solar_output_array_1_live'))|round(0) }}

I finally have this working with some help from the LuxPowerTek GitHub group. This is the working YAML. I hope it can help other people.

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: !secret pvoutout-api
        X-Pvoutput-SystemId: !secret pvoutput-site
    payload: "d={{now().strftime('%Y%m%d')}}&t={{now().strftime('%H:%M')}}&v2={{(states('sensor.lux_solar_output_live'))|round(0)}}&v4={{(states('sensor.lux_home_consumption_live'))|round(0)}}&v5={{(states('sensor.met_office_buntingford_temperature_3_hourly'))|round(0)}}&v8={{(states('sensor.lux_solar_output_array_2_live'))|round(0)}}&v6={{(states('sensor.lux_grid_voltage_live'))|round(0)}}&v7={{(states('sensor.lux_solar_output_array_1_live'))|round(0)}}&v9={{(states('sensor.lux_battery'))|round(0)}}&v10={{(states('sensor.lux_battery_charge_live'))|round(0)}}&v11={{(states('sensor.lux_battery_discharge_live'))|round(0)}}&v12={{(states('sensor.lux_power_to_grid_live'))|round(0)}}"

I have this working but I have phantom power from my solar sensor.
How do i modify the below to say ‘if value less than 15, then set to 0’ ?
Or - do I do that on the sensor config itself somehow ?
Sorry - I am very very new to HA - and have a load of things yet to add, but getting there.

pvoutput_generation: ‘curl -d “d={{now().strftime(”%Y%m%d")}}" -d “t={{now().strftime(”%H:%M")}}" -d “v2={{states.sensor.cc_solar_generation_power.state|int}}” -H “X-Pvoutput-Apikey: keyhere” -H “X-Pvoutput-SystemId: systemidhere” https://pvoutput.org/service/r2/addstatus.jsp

just wanted to say I stumbled upon this after my old process (ginlong scaper) stopped working with the migration of Soliscloud.

Made sense to have this running at the same time as HA and its one less process to run on my NAS…All seems to work smoothly…will make sure tomorrow’s numbers tie up…but thanks to all the tips and comments here that made things pretty simple

Hi there,

interesting topic this is! I also have solar power and meteobridge coming in on HA. Now I wanted to upload these values. Long time ago I did this with domoticz but now want to use HA.
I read al these stiff here but get stuck.
It is not clear where I put all these code.
Do I need the code from Martijn Braam?
And where do I put rest commands and all others? Could anyone make a list of what code where to put in HA?
Thanks in advance.

Use this post as reference

But be sure to update the apikey, SystemId + check the v1 and v2 values for the correct sensors that you use for your inverter data. If you don’t know what to put there, the API spec: API Specification — PVOutput documentation

It’s still working great here.

1 Like

Hi! I used this sucessfully for some months.
About 4 weeks ago I started getting error (Logs) and I have no idea what I could change to resolve it?
Could somebody help me what I am doing wrong?