I just started using Home Assistant and also have a STECAGRID inverter. My goal was to be able to get solar data in HA and also upload the data to PVOutput. For the HA integration of the solar data from the STECA inverter I used information from this thread : Cannot parse @ in value template sensor - Configuration - Home Assistant Community (home-assistant.io)
As a complete noob in HA and scripting/programming it took me a few days to get things working. For the others out there who want to get the solar data from the STECAGRID, here is the code i used in the configuration.yaml :
# Solar - Reads the measurements.xml every 10 seconds
- platform: rest
resource: http://YourSTECAInverterIP/measurements.xml
json_attributes:
- root
- Measurements
name: solar_inverter
scan_interval: 10
value_template: 'OK'
# Solar - Specifies the sensors and values
- platform: template
sensors:
solar_live_voltage:
value_template: >
{% set root = state_attr('sensor.solar_inverter', 'root') %}
{% if root.Device.Measurements.Measurement[0]["@Value"] is defined %}
{{ root.Device.Measurements.Measurement[0]["@Value"] }}
{% else %}
0
{% endif %}
device_class: Voltage
unit_of_measurement: 'V'
friendly_name: AC Voltage
solar_live_output:
value_template: >
{% set root = state_attr('sensor.solar_inverter', 'root') %}
{% if root.Device.Measurements.Measurement[2]["@Value"] is defined %}
{{ root.Device.Measurements.Measurement[2]["@Value"] | round(0)}}
{% else %}
0
{% endif %}
device_class: power
unit_of_measurement: 'Watt'
friendly_name: Live power
To upload the solar data to PVOutput i use this :
# Solar - Sensor for 5 min average generation for Pvoutput
- platform: statistics
name: solar_energy_generation_5min
entity_id: sensor.solar_live_output
state_characteristic: mean
max_age:
minutes: 5
sampling_size: 300
# Solar - Upload solar_energy_generation_5min to pvoutput
rest_command:
pvoutput_generation:
method: POST
url: https://pvoutput.org/service/r2/addstatus.jsp
headers:
X-Pvoutput-Apikey: YourAPIKeyHere
X-Pvoutput-SystemId: YourSytemIDHere
payload: 'd={{now().strftime("%Y%m%d")}}&t={{now().strftime("%H:%M")}}&v2={{states.sensor.solar_energy_generation_5min.state|round(1)}}'
content_type: "application/x-www-form-urlencoded"
And last but not least there is an automation (in the automations.yaml) that activates the upload of the data every 5 minutes :
alias: PVOutput Uploader (rest_command)
description: Uploads values to PVOutput
trigger:
- platform: time_pattern
minutes: /5
seconds: '0'
condition: []
action:
- service: rest_command.pvoutput_generation
data: {}
mode: single
I would like to have some detail about the solar production, Daily production, Monthly production and Yearly production. But I have not yet figured that out. Maybe someone can help?
Cheers