I have almost the same setup as you and got both the energy dashboard as the Tesly style card working.
I think 1 thing is missing, you can also charge / discharge the battery to the grid, but I have no idea how to calculate this value. Because in that case, you have 2 variables: battery to grid and the house itself…
Any suggestions ?
I do not charge or discharge the battery to grid, because I have different rates: selling power gives me 0,09€/kWh and buying costs me 0,29€/kWh…
With the template framework it must be possible to calculate the required flows. It is a bit of a puzzle and figuring out in which state you get which value, but with similar things as I did in the template.yaml it must be possible…
I am trying to get this working - but cannot get the modbus integration working. Could anyone confirm if modbus tcp can work over Wifi? Or is it really only exposed on the ethernet port?
I use it over wifi and it works well.
Couple of test points.
Can you ping the IP address of your inverter? Checks network connectivity eth or wifi.
Can you telnet into port 1502 on your inverter?
Checks MODBUS interface is setup.
If both of those tests pass this integration should work for you.
We discussed this point last week here:
Perhaps, it can help you.
This post is obsolete, see the first post for latest instructions
Frist: Thank you @Remko!
I’m trying to adapt your latest config, but getting Errors and Warning. Am i doing something wrong? Had modified the configuration.yaml and added/importet the sensor.yaml and template.yaml… is there something missing? Do you have any Hints?
thx, sash
Logger: homeassistant.helpers.template
Source: helpers/template.py:1254
First occurred: 23:40:21 (4 occurrences)
Last logged: 23:40:21
Template warning: 'float' got invalid input 'unknown' when rendering template '{% if ((states('sensor.solaredge_m1_ac_power') | float) <= 0) %} {{(states('sensor.solaredge_m1_ac_power') | float*-1)}} {% else %} 0 {% endif %}' but no default was specified. Currently 'float' will return '0', however this template will fail to render in Home Assistant core 2022.1
Logger: homeassistant.components.template.template_entity
Source: components/template/template_entity.py:73
Integration: Template (documentation, issues)
First occurred: 23:40:21 (2 occurrences)
Last logged: 23:40:21
TemplateError('ZeroDivisionError: float division by zero') while processing template 'Template("{{(((((states('sensor.solar_house_consumption_daily') | float(0)) - (states('sensor.solar_imported_power_daily') | float(0))) / ((states('sensor.solar_production_daily') | float(0)) + (states('sensor.battery_power_out_kwh_daily') | float(0)))) * 100 ) )| round (0)}}")' for attribute '_attr_native_value' in entity 'sensor.solar_selfconsumption_ratio'
TemplateError('ZeroDivisionError: float division by zero') while processing template 'Template("{{((1 - (states('sensor.solar_imported_power_daily') | float(0) / states('sensor.solar_house_consumption_daily') | float(0))) * 100 ) | round (0)}}")' for attribute '_attr_native_value' in entity 'sensor.solar_autarkie_ratio'
Logger: homeassistant.components.utility_meter.sensor
Source: components/utility_meter/sensor.py:295
Integration: Utility Meter (documentation, issues)
First occurred: 23:40:11 (3 occurrences)
Last logged: 23:40:11
Could not restore state <unknown>. Resetting utility_meter.Solar Production Daily
Could not restore state <unknown>. Resetting utility_meter.Battery Power In kWh Yearly
Could not restore state <unknown>. Resetting utility_meter.Battery Power Out kWh Yearly
Logger: homeassistant.components.integration.sensor
Source: components/integration/sensor.py:132
Integration: integration (documentation, issues)
First occurred: 23:40:11 (3 occurrences)
Last logged: 23:40:11
Could not restore last state: [<class 'decimal.ConversionSyntax'>]
Logger: homeassistant.components.template.config
Source: components/template/config.py:89
Integration: Template (documentation, issues)
First occurred: 23:40:11 (1 occurrences)
Last logged: 23:40:11
The entity definition format under template: differs from the platform configuration format. See https://www.home-assistant.io/integrations/template#configuration-for-trigger-based-template-sensors
Sorry for the late reply. Could you please post the relevant contents of the configuration files? I guess there are some things missing…
Some of the warnings are ok, but the ones about the utility meters are not
Sure @Remko
Sorry for my late Answer. I still having these Issues, here are my configs. If you need - let me know!
configuration.yaml
utility_meter:
solar_production_daily:
source: sensor.solar_production_kwh
name: Solar Production Daily
cycle: daily
solar_battery_power_in_kwh_yearly:
source: sensor.battery_power_in_kwh
name: Battery Power In kWh Yearly
cycle: yearly
solar_battery_power_out_kwh_yearly:
source: sensor.battery_power_out_kwh
name: Battery Power Out kWh Yearly
cycle: yearly
solar_imported_power_daily:
source: sensor.solaredge_m1_imported_kwh
name: Solar Imported Power Daily
cycle: daily
solar_exported_power_daily:
source: sensor.solaredge_m1_exported_kwh
name: Solar Exported Power Daily
cycle: daily
sensor.yaml
- platform: integration
source: sensor.solar_charge_power_w
method: left
unit_prefix: k
name: battery_power_in_kwh
- platform: integration
source: sensor.solar_discharge_power_w
method: left
unit_prefix: k
name: battery_power_out_kwh
- platform: integration
source: sensor.solar_production_w
method: left
unit_prefix: k
name: solar_production_kwh
template.yaml
sensor:
- name: Solar Exported Power Total kWh
unique_id: solar_exported_power_total_kwh
state_class: total_increasing
device_class: energy
unit_of_measurement: 'kWh'
state: >
{% if ((states('sensor.solaredge_m1_exported_kwh') | float(0)) < 100) %}
{% else %}
{{(states('sensor.solaredge_m1_exported_kwh') | float(0))}}
{% endif %}
- name: Solar Imported Power Total kWh
unique_id: solar_imported_power_total_kwh
state_class: total_increasing
device_class: energy
unit_of_measurement: 'kWh'
state: >
{% if ((states('sensor.solaredge_m1_imported_kwh') | float(0)) < 100) %}
{% else %}
{{(states('sensor.solaredge_m1_imported_kwh') | float(0))}}
{% endif %}
sensors:
solar_selfconsumption_ratio:
friendly_name: Solar Selfconsumption Ratio
value_template: "{{(((((states('sensor.solar_house_consumption_daily') | float(0)) - (states('sensor.solar_imported_power_daily') | float(0))) / ((states('sensor.solar_production_daily') | float(0)) + (states('sensor.battery_power_out_kwh_daily') | float(0)))) * 100 ) )| round (0)}}"
solar_autarkie_ratio:
friendly_name: Solar Autarkie Ratio
value_template: "{{((1 - (states('sensor.solar_imported_power_daily') | float(0) / states('sensor.solar_house_consumption_daily') | float(0))) * 100 ) | round (0)}}"
solar_production_w:
friendly_name: Solar Production W
device_class: power
unit_of_measurement: 'W'
value_template: >
{% if ((states('sensor.solaredge_ac_power') | float(0)) + (states('sensor.solaredge_battery1_power') | float(0)) <= 0) %}
0
{% else %}
{{((states('sensor.solaredge_ac_power') | float(0) + states('sensor.solaredge_battery1_power') | float(0)) )}}
{% endif %}
solar_production_to_house_w:
friendly_name: Solar Production To House W
device_class: power
unit_of_measurement: 'W'
value_template: "{{((states('sensor.solar_production_w') | float(0)) - (states('sensor.solar_exported_power_w') | float(0)) - (states('sensor.solar_charge_power_w') | float(0)))}}"
solar_house_consumption_w:
friendly_name: Solar House Consumption W
device_class: power
unit_of_measurement: 'W'
value_template: "{{(((states('sensor.solar_production_w') | float(0)) - (states('sensor.solar_exported_power_w') | float(0))) + (states('sensor.solar_discharge_power_w') | float(0)) - (states('sensor.solar_charge_power_w') | float(0)) + (states('sensor.solar_imported_power_w') | float(0)))}}"
solar_imported_power_w:
friendly_name: Solar Imported Power W
device_class: power
unit_of_measurement: 'W'
value_template: >
{% if ((states('sensor.solaredge_m1_ac_power') | float) <= 0) %}
{{(states('sensor.solaredge_m1_ac_power') | float*-1)}}
{% else %}
0
{% endif %}
solar_exported_power_w:
friendly_name: Solar Exported Power W
device_class: power
unit_of_measurement: 'W'
value_template: >
{% if ((states('sensor.solaredge_m1_ac_power') | float(0)) > 0) %}
{{(states('sensor.solaredge_m1_ac_power') | float(0))}}
{% else %}
0
{% endif %}
solar_charge_power_w:
friendly_name: Solar Charge Power W
device_class: power
unit_of_measurement: 'W'
value_template: >
{% if ((states('sensor.solaredge_battery1_power') | float(0)) > 0) %}
{{(states('sensor.solaredge_battery1_power') | float(0))}}
{% else %}
0
{% endif %}
solar_discharge_power_w:
friendly_name: Solar Discharge Power W
device_class: power
unit_of_measurement: 'W'
value_template: >
{% if ((states('sensor.solaredge_battery1_power') | float(0)) < 0) %}
{{(states('sensor.solaredge_battery1_power') | float(0)*-1)}}
{% else %}
0
{% endif %}
solar_production_lifetime_mwh:
friendly_name: Solar Lifetime Production
device_class: energy
unit_of_measurement: 'MWh'
icon_template: mdi:solar-power
value_template: "{{ ((states('sensor.solaredge_ac_energy_kwh') | float(0)) / 1000) | round (2) }}"
Energy Dashboard Config
I hope, that my answer helps to find the issues
Just to add that I have the same problems as @s_ash … I’d actually set aside some time today to post my config as per @Remko 's request but then saw that @s_ash beat me to it by about sixty minutes
Please let me know if I can help with testing / debugging. Confirmed that my setup is the same as above.
I have also the same hardware setup, same configuration and the same problem
If i can be of any help for testing or debugging, i’m happy to help!
I did make some minor changes to my config, do get a few warnings and every now and then some errors when it loses connection, but that is ok. The connection automatically restores and the overall data is coming through and I get everything displayed the way it should be. I’ll go through this over the next couple of days and post the correct config.
I’ll need a few days, but will get back to this.
Thank you for all the effort, much appreciated !
I have just read through this and I have two questions.
do I need to have the SolarEdge API installed first, with will then give me the sensors links within HA.
and my second question, as I have a GivEnergy Battery then will this also work this this, as long as I have the right API for GivEnergy ?
This post is obsolete, see the first post for latest instructions
Thank you! First: most is working - i think.
First quation: Where did you define “sensor.solar_production_kwh” - you are using it in the Energy Dashboard. In your config files i couldn’t find the definition. Perhaps you could give me a Hint!
Will give an more detailed Feedback after experiencing some more.
It’s in the sensors.yaml file. The third entry there. This one:
- platform: integration
source: sensor.solar_production_w
method: left
unit_prefix: k
name: solar_production_kwh
@Remko: Thanks for all your work. I have set up the modbus integration exactly as you described in your latest post. I would have a few questions. Maybe you find some time to answer.
Above, you said:
One of the things which bugged me is that the charging of the battery does not count for production, but discharging does. This means that I would not get the actual solar produced energy on a daily basis, but the battery is factored in here, which also causes the energy dashboard to show incorrect values.
Question 1: Could you elaborate a bit on how SE monitoring works, how the energy dashboard works and how they compare respectively what exactly is/was the problem? Does this also mean that the energy dashboard never correctly works with the native SE web integration because it always has the battery factored in?
My understanding of “production” in SE Monitoring Platform is the following:
production = solar production - battery charging + battery discharging
"Produktion" = "PV-Erzeugung" - "Speicherladung" + "Speicherentladung"
Question 2: Is the above formula correct in terms of SE monitoring?
Below is a screenshot about yesterday from SE monitoring and HA energy module based on the setup you described:
Question 3: How do the values from SE and HA relate and why do they sometimes diverge?
- Import and export match → Ok
- Consumption and battery discharge diverge → Why?
- According to above formula production is 5,7 - 2,8 + 2,3 = 5,2 kWh (HA) != 4,71 kWh (SE) → Why?
Sorry for the late (and short) reply, I am having some construction work going on and not getting to this as much as I want.
As far as I have seen it, the SE Platform doe not count “battery charging” to production, but only battery discharging. This means that the daily production depends on the use of the battery on the SE platform. I have looked at the data a lot and that is the conlcusion I came to. I do not like that, under daily production I like to see what my panels produce… That is why I worked with the data to get these values.
So question 2 should be answered with that…
And to question 3…yes…I also see those differences and do not know how to explain them. I think the HA is correct, because it bases on nearly instant modbus values, but…there may be small deviations because of the converting from W to kWh by using the Integration platform. This uses a way of calculating over time and I do not know how accurate this is. So…it would actually mean monitoring the values over some time and actually sitting down and doing the math. I just havent found the time for that and just enjoy a nice looking (and I think more accurate) energy dashboard in HA and hardly look at the SE platform anymore…
So…if you have the time and want to study some of the values…I would be interested in your findings too, there still may be small mistakes in my setup. I know it took me a lot of time and fiddling with Excel to get to this point…
Cheers
Remko