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!
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.
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?
I was able to implement this thanks to the posts so far above.
My automations.yaml file.
- alias: PVOutput Uploader (rest_command)
description: Uploads values to PVOutput
trigger:
- platform: time_pattern
minutes: /5
seconds: "0"
action:
- service: rest_command.pvoutput_generation
data: {}
mode: single
My configuration.yaml file.
logger:
default: info
logs:
homeassistant.components.rest_command: debug
# Power Consumption (Instantaneous), Energy Consumption (Accumulated)
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=%H:%M')}}&c1=1&v3={{states('sensor.esphome_web_a2e2e8_load_power_consumption_of_the_day')| float * 1000 }}&v4={{states('sensor.energy_consumption_5min')|float(0)}}&v1={{states('sensor.esphome_web_a2e2e8_power_generation_of_the_day')| float * 1000 }}&v2={{states('sensor.energy_generation_5min')|float(0)}}&v6={{states('sensor.esphome_web_a2e2e8_pv_voltage')|float(0)}}"
content_type: "application/x-www-form-urlencoded"
My payload response.
2024-03-26 16:20:01.744 DEBUG (MainThread) [homeassistant.components.rest_command] Success. Url: https://pvoutput.org/service/r2/addstatus.jsp. Status code: 200. Payload: b’d=20240326&t=16:20&c1=1&v3=6500.0&v4=660.5&v1=4300.0&v2=986.65&v6=74.0’
So far the result.
I was testing a couple of stuff and I used my accumulated energy sensor at one point for the payload, thus the jump in energy use. I only multiplied by 1000 for the values that come as kWh.
I have two inverters, one already in use for almost 10 years, the other brand new. I managed to have an automated upload via HA using the rest_command to a new account. I would like to upload the other one as well to a existing account. Adding another rest_command results in an error.
rest_command:
pvoutput_generation:
method: POST
url: https://pvoutput.org/service/r2/addstatus.jsp
headers:
X-Pvoutput-Apikey: key1
X-Pvoutput-SystemId: ID1
payload: 'd={{now().strftime("%Y%m%d")}}&t={{now().strftime("%H:%M")}}&v1={{states.sensor.inverter_1_yieldday|round()+states.sensor.inverter_2_yieldday|round()}}'
content_type: "application/x-www-form-urlencoded"
pvoutput_generationABB:
method: POST
url: https://pvoutput.org/service/r2/addstatus.jsp
headers:
X-Pvoutput-Apikey: key2
X-Pvoutput-SystemId: ID2
payload: 'd={{now().strftime("%Y%m%d")}}&t={{now().strftime("%H:%M")}}&v1={{states.sensor.solar_inverter_total_energyy|round()*1000}}'
content_type: "application/x-www-form-urlencoded"
What error do you get ?
Maybe the double yy at the end of energy ?
states.sensor.solar_inverter_total_energyy
Got a configuration error at check configuration.
Changed the pvoutput_generationABB to pvoutput_generationabb and removed the yy and now the config is valid. Will load the new configuration.yaml when it is all ok for other users.
Thanks
I’m also adding the PVoutput payload
it is working , but still V3 and V4 are not correct in my case
V3 Gross Energy Consumption today (Wh)
V4 Gross Power Consumption today (W)
if im correct the Gross value
so i have to calculate
V3 = energy consumption(today) from grid + generated solar energy(today) - energy return to grid(today)
but im getting a hard time calculating this
i have sensors
Electricity Meter Energy consumption (tarif 1)
Electricity Meter Energy consumption (tarif 2)
Electricity Meter Energy production (tarif 1)
Electricity Meter Energy production (tarif 2)
Solar Energy production today
With the app Utility meter i can calculate the today values (resets daily) but look like it is not always working correctly
is there a easier better way to calculate V3 and V4
This topic is a couple of years old, but still a great inspiration of how to upload data to PVOutput.
I’d like to share the way I implemented this so others can benefit from it.
To start off, I have this rest_command definition in my configuration.yaml
file.
rest_command:
upload_to_pvoutput:
url: "{{ url }}"
method: POST
headers:
X-Pvoutput-Apikey: !secret pvoutput_api_key
X-Pvoutput-SystemId: !secret pvoutput_system_id
Content-Type: application/x-www-form-urlencoded
payload: "{{ payload }}"
Using the url and payload as variables allows me to fiddle around with the automation that will eventually send the data to PVOutput without reloading Home Assistant after every change.
📝Info
Something that helped me tremendously with troubleshooting was using a mock API service such as Beeceptor. This allows you to set up an endpoint to intercept and analyze your REST API calls very easily.
Make sure to create a new rest_command definition that does not include your actual API key and system ID for better security.
Next up I use this automation to send the data to PVOutput.
alias: Upload PV data to PVoutput
description: ""
triggers:
- minutes: /5
trigger: time_pattern
conditions:
- condition: template
value_template: "{{ states('sensor.pv_power') != 'unavailable' }}"
alias: If status sensor.pv_power is not unavailable
actions:
- data:
url: https://pvoutput.org/service/r2/addstatus.jsp
payload: |-
{{ ''.join([
'd=' ~ now().strftime('%Y%m%d'),
'&t=' ~ now().strftime('%H:%M'),
'&v1=' ~ ((states('sensor.today_s_pv_generation') | float) * 1000),
'&v2=' ~ states('sensor.pv_power'),
'&v5=' ~ (state_attr('weather.forecast_thuis', 'temperature') | float)
]) }}
action: rest_command.upload_to_pvoutput
alias: >-
Data is sent to PVOutput. The `join` function ensures no extra whitespace
is added
mode: single
This automation sends data to PVOutput every 5 minutes. But only when my sensor for pv_power is available. My inverter shuts down in the evening, so it makes no sense sending data to PVOutput in that situation.
The way the payload is formatted is pretty important. I’ve seen people trying to keep their yaml readable by using a folded block scalar (>-
) and putting each parameter on a new line. But this introduced unintended whitespace which causes issues with the PVOutput API. By using join
you can mitigate this issue and keep your payload readable.
I hope this contribution will prevent people from having the issues I encountered and start using PVOutput straight away.
good afternoon everyone.
Yesterday I created my account on PVOutput, I wanted to automatically upload the values of my photovoltaic system from Home Assistant.
logically on my account I have enabled the “API”
Following various posts I created the necessary files, but there is something that does not add up.
There is some error that I can not find …
Thanks in advance to anyone who can help me …
This works for mine ABB aurora power one 10kw 3 phase inveerter
in /homeassistant/automations.yaml
alias: PVOutput Uploader (rest_command)
description: Uploads values to PVOutput
trigger:
- platform: time_pattern
minutes: /5
action:
- service: rest_command.pvoutput_upload
data: {}
mode: single
in homeassistant/configuration.yaml
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
logger:
default: info
logs:
homeassistant.components.rest_command: debug
rest_command:
pvoutput_upload:
url: https://pvoutput.org/service/r2/addstatus.jsp
method: post
content_type: "application/x-www-form-urlencoded"
headers:
X-Pvoutput-Apikey: key
X-Pvoutput-SystemId: id
payload: "d={{now().strftime('%Y%m%d')}}&t={{now().strftime('%H:%M')}}&v1={{(states('sensor.cumulated_energy_today'))|round(0)}}&v2={{(states('sensor.grid_power'))|round(0)}}"
with the esp32:
Good morning everyone.
I thought I had solved the problem (in part), but instead another very strange one has arisen.
I made several changes to the file and they all reported the same result, so I can’t find the problem…
Situation:
- if I withdraw from the Grid, HA sends the “data” to PVO
- if I am producing from the PV and I am also withdrawing from the Grid, HA sends the “data” to PVO
- if I am producing from the PV and I am putting Energy into the Grid, HA does NOT send the “data” to PVO, giving me the following ERROR " Error. Url: https://pvoutput.org/service/r2/addstatus.jsp. Status code 400. Payload: b’d=20250308 &t=09:05 &v2=2048 &v4=-1937 &v5=5 &v6=236’ "
So as soon as the PV produces in the early morning and in the late afternoon, and I also withdraw from the grid, both data are there… Instead if I produce and insert WITHOUT withdrawing ,data is not sent…
Is it possible that the value of the energy/power of the Photovoltaic must be with a negative sign??? Is there a possibility to “FORCE” the sending of data with a “negative sign” in the script string???
Thanks to all and have a good weekend
Ok, yesterday fiddling around I managed, in part, to fix the file. Now with the current configuration I can “add status” every 5 minutes.
But there is a but:
- v4 is net, set parameter n=1, So Import\Export… If I withdraw it shows me the Watts used, if I enter it shows 0 W. But this can be fine.
- v2 instead is gross, and is found in the same request as v4, unfortunately with parameter n=1 it does not show me anything So it is always 0
How can I send “add Status” with 2 different strings, So:
-v2 gross
-v4 net
How should the file be configured in Home Assistant.???
Thanks to everyone and have a good day.
Hi, new to HA and have previously uploaded solar and consumption to Pvoutput for over 12 years, I’m having the same problem with net metering as you. With my configuration.yaml for upload appended with n=1 I’m getting 0W returned on the 5 min uploads when v4 is negative. As soon as the sun goes and v4 is positive I get data showing in Pvoutput. I’ve been going round and round in circles trying all sorts of variations of code and google searches. s
Without the n=1 I’m getting "Bad request 400: Invalid power value [-*] and nothing uploads as expected, with n=1 “OK 200: Added Status” as expected.
Can anyone assist with some direction or fix to the code?
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.solar_inverter_power_output’))|float(0) }}&v4={{(states(‘sensor.shellypro3em_ac15186c68cc_total_active_power’))|round(0)|float(0) }}&v5={{(states(‘sensor.solar_inverter_temperature’))|float(0) }}&v6={{(states(‘sensor.solar_inverter_grid_voltage’))|float(0) }}&n=1”
Cheers
Adrian
*edit - admin -sorry for the deleted posts