UPDATED! SolarEdge Modbus full setup guide with Energy Dashboard integration for Installations with Battery connected

This post is obsolete, see the first post for latest instructions

3 Likes

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! :slight_smile:

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…:wink:

Cheers
Remko

Thanks for answering, @Remko. I can imagine that you put a lot of time, calculations and effort into this to reach this point.

Don’t get me wrong, I don’t care about daily deviations <= 0,5 kWh, as long as the overall meaning of the statistics and values is “correct” and reliable. That’s what I am still trying to figure out.


Especially when looking at longer time periods (like one week above), two things bother me:

  1. The daily differences add up and will get worse.
    • If you’re also suffering from deviations, you should see the same effect, right?
  2. Is it possible that I am using that little solar energy directly while at the same time buying lots of energy?
    • At least that’s how I interpret the very small share of orange bars in top left diagram
    • Is this understanding correct, do you see similar behavior or is it only on my side (9,89 kWp)?
    • As far as I have seen, my storage control mode is “maximize self consumption”.

Regarding daily deviations you mentioned rounding errors and/or calculations of the integrations platform as the root cause. What else could cause them? How about the different update intervals (15 min vs. 30 sec)? What update interval are you using by the way?

Assuming I would go back to the official web integration, then the differences should disappear because we’re looking at the same data source, right? But then again - as asked last time - you’re saying that the energy dashboard would “show incorrect values” because we never get the “actual solar produced energy on a daily basis” by the official integration. Correct understanding? Apart from that I don’t know how to add my battery to the official integration. Do you know?

Thanks again.

Hi at all,

at first i want to appreciate the awesome work Remko and the rest of you did here. I am quite new to Home Assistant and learning every day. I don´t want to disturbe the conversation about real problems but can anybody help me to get the Modbus Addon going? I don´t get any data even though modbus tcp is enabled (i can ping the ip). I am connected with one ethernet cable with my home network. do i need to configure the second rs485 to non se logger?

do you have the possibility to use a python script?

see here

i used this to test my modbus connection

Did you restart the inverter?

Thank you very much. I did get the connection going by connecting to the wifi. :slight_smile:

Hi guys,

thank you very much for the effort for providing this guide. I just installed the solaredge modbus component with HACS and wanted to try it by myself.
I added solaredge modbus to the integrations and did the setup. Nothing seems to be wrong so far.
After that I’ve got 226 new entities for the solaredge inverter, but all of them show “unknown” status in my overview dashboard. Do you have any clue what I might do wrong?
I guess the connection does work, because after setting it up, it’s not possible to connect to the inverter via modbus tcp with a modbus tcp testing tool. Therefore I assume the modbus connection is already used by HA.
Before I configured the solaredge modbus integration, the testing tool did connect without issues.

I also scanned the logs and could find repeating messages, which could be the data from the inverter.
The messages look like this:

2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x01\x19'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x07\x0c'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x02\xc5'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x06\xf3'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\xbc\x11'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00!\xb7'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x87\x8d'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00"x'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.payload] b'\x00\x00\x00\x00'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.transaction] Current transaction state - TRANSCATION_COMPLETE
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.transaction] Running transaction 18
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.transaction] SEND: 0x0 0x12 0x0 0x0 0x0 0x6 0x1 0x3 0x9d 0xac 0x0 0x67
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.client.sync] New Transaction state 'SENDING'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.transaction] Changing transaction state from 'SENDING' to 'WAITING FOR REPLY'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.transaction] Changing transaction state from 'WAITING FOR REPLY' to 'PROCESSING REPLY'
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.transaction] RECV: 0x0 0x12 0x0 0x0 0x0 0x3 0x1 0x83 0x2
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.framer.socket_framer] Processing: 0x0 0x12 0x0 0x0 0x0 0x3 0x1 0x83 0x2
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.factory] Factory Response[131]
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.transaction] Adding transaction 18
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.transaction] Getting transaction 18
2022-01-22 15:15:53 DEBUG (MainThread) [pymodbus.transaction] Changing transaction state from 'PROCESSING REPLY' to 'TRANSACTION_COMPLETE

Thank you for your Help

Jeremia

Ok, I’ve got the integration to work, but there are some open questions. I hope someone can guide me to get it right.
Good things first. The Energy flow card seems to work right :grinning:

Unfortunately the power distribution card looks a bit weird. The energy values seems to be right, but the directions are wrong.

image

Here is the config i used:

type: custom:power-distribution-card
title: Title
entities:
  - decimals: 2
    display_abs: true
    name: solar
    unit_of_display: W
    icon: mdi:solar-power
    producer: true
    entity: sensor.solar_production_w
    preset: solar
  - decimals: 2
    display_abs: true
    name: grid
    unit_of_display: W
    icon: mdi:transmission-tower
    entity: sensor.solaredge_m1_ac_power
    preset: grid
  - decimals: 2
    display_abs: true
    name: home
    unit_of_display: W
    consumer: true
    icon: mdi:home-assistant
    entity: sensor.solar_house_consumption_w
    preset: home
  - decimals: 2
    display_abs: true
    name: battery
    unit_of_display: W
    consumer: true
    icon: mdi:battery-outline
    producer: true
    entity: sensor.solaredge_battery1_power
    preset: battery
center:
  type: bars
  content:
    - preset: autarky
      name: autarky
    - preset: ratio
      name: ratio
animation: none

On the energy dashoard, I have the issue, that not all sensors are available. I can’t select “Solar Production Daily”, “Battery Power In KWh Yearly” and “Battery Power Out Yearly”.
I created all sensors from your configuration.yaml, sensors.yaml and template.yaml.
Any Idea where I messed up?

Jeremia

Hi Jeremia,

first for the Power Distribution card you can add the “invert_value = true” if you want the arrows inverted. Please see my config for this card:

type: custom:power-distribution-card
title: ''
entities:
  - decimals: 2
    display_abs: true
    name: solar
    unit_of_display: adaptive
    icon: mdi:solar-power
    producer: true
    entity: sensor.solar_production_w
    preset: solar
  - decimals: 2
    display_abs: true
    name: grid
    unit_of_display: adaptive
    icon: mdi:transmission-tower
    entity: sensor.solaredge_m1_ac_power
    preset: grid
    threshold: ''
    icon_color:
      bigger: ''
      equal: ''
      smaller: ''
    invert_value: true
  - decimals: 2
    display_abs: true
    name: home
    unit_of_display: W
    consumer: true
    icon: mdi:home-assistant
    entity: sensor.solar_house_consumption_w
    preset: home
    threshold: ''
    icon_color:
      bigger: ''
      equal: ''
      smaller: ''
    invert_value: true
  - decimals: 2
    display_abs: true
    name: battery
    unit_of_display: W
    consumer: true
    icon: mdi:battery-outline
    producer: true
    entity: sensor.solaredge_battery1_power
    preset: battery
    threshold: ''
    icon_color:
      bigger: ''
      equal: ''
      smaller: ''
    invert_value: true
center:
  type: bars
  content:
    - preset: autarky
      name: autark
      bar_color: green
      bar_bg_color: ''
      entity: sensor.solar_autarkie_ratio
    - preset: ratio
      name: selbst
      bar_color: blue
      bar_bg_color: ''
      entity: sensor.solar_selfconsumption_ratio
animation: none

The to the other issue, I have also added following to my configuration.yaml: I need these utility meters for the values to be available to the energy dashboard. Maybe you missed this bit?

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_battery_power_in_kwh_daily:
    source: sensor.battery_power_in_kwh
    name: Battery Power In kWh Daily
    cycle: daily 
  solar_battery_power_out_kwh_daily:
    source: sensor.battery_power_out_kwh
    name: Battery Power Out kWh daily
    cycle: daily
  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  
  solar_house_consumption_daily:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Daily
    cycle: daily 

Hope this helps…

Thank you very much for this ultra fast reply. We’re getting closer.

Directions of the Power distribution card are right now. The center area does display NAN now :frowning:

image

From your config I can see, that the date should be taken from “sensor.solar_autarkie_ratio”. I have this sensor, but it doesn’t have any data:

image

To the other issue:

I have all the utility_meters from your configuration.yaml aswell, but this doesn’t seem to be enough to select them in the energy dashboard. I also have your sensors.yaml and template.yaml.

I have found some invalid sensors in my dashboard:

image

image

Jeremia

Maybe I found a hint in the logs:

2022-01-26 16:28:48 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform utility_meter
ValueError: could not convert string to float: 'None'
2022-01-26 16:28:48 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform utility_meter
ValueError: could not convert string to float: 'None'
2022-01-26 16:28:48 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform utility_meter
ValueError: could not convert string to float: 'None'
2022-01-26 16:28:48 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform utility_meter
ValueError: could not convert string to float: 'None'
2022-01-26 16:28:49 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up utility_meter platform for sensor
ValueError: could not convert string to float: 'None'

That is interesting…I think the string to float is the issue…

What I try to do is in the template and sensor definition to convert the input values to float values with this statement after the entity name: “| float(0)”
This works fine for me, but what I am wondering about…an old computer issue… Even though I live in Germany and speak the language, I always have anything computer related set to english. One of the issues in Germany is always the decimal symbol. In Germany this is a “,” in Englisch a “.” So maybe, just maybe…you have your local settings in HASS set to German and it is now trying to convert a string value with a “,” in there into a float value, which would not work.
Maybe the issue is burried in there. I would start with looking at the entities in the developer tools and see what the values actually are.
Then you could use the template editor to test the different definitions you use in the template.yaml file to see if you also get the same error. Maybe that will point you in the direction of the issue because I still use exactly the same config as I have in one of the previous posts and I do not have such issues.

Again, I hope this helps or at least points you in the right direction.

That’s an intereseting theory. I checked all entities starting with “solar” in the developer tools. There is not a single one with a “,”. They all use “.” for decimal separation.

I have a little bit more detailed log now, but I can’t get more information from it

2022-01-26 17:11:59 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform utility_meter
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 613, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 747, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/usr/src/homeassistant/homeassistant/components/utility_meter/sensor.py", line 314, in async_added_to_hass
    float(state.attributes.get(ATTR_LAST_PERIOD))
ValueError: could not convert string to float: 'None'

OK…than that does not seem to be the issue…

Could you check if your “solaredge” sensors all have values in the developer tools?

Maybe there is an issue with the modbus integration, does it actually have values when you look at for example sensor.solaredge_battery1_charged or any of the solaredge “m1” sensors? Maybe you don’t get the correct values for your battery setup. That is…I am assuming you also have a battery connected to your inverter…

Most of the solaredge sensors have values. There is only one unrelated sensor, without a value. Here are the first one:

Here are some m1 guys

I have another theory:

Maybe the solaredge sensors are just not yet available during startup. Because of that the values are invalid during the execution of the template. After a while the values are ready, but the utility_meters already failed to get added during startup.

No that theory is incorrect, it does take time for the values to appear after startup, but that doesn’t impact the utility meters.

Question, do you actually have the sensor.solaredge_battery1_charged and sensor.solaredge_battery1_discharged sensors?

During setup of the modbus integration you have to select that you have a battery if I remember correct, if you did not do that you may not have those sensors, which would explain the issues you see.

Please see this note from here:

“Update the integration through HACS, remove and re-add the integration, and when you configure it tick the “read battery 1 information” checkbox. You should then get sensors for the battery.”