Solaredge Modbus Configuration for Single Inverter and Battery

They could have a consumption meter, not an E+I meter.

Meter type is shown on its device page and in the attributes of the “device” sensor.

@WillCodeForCats
So do you think this means I only have a consumption meter? Does yours show E & I instead of consumption? If so what model do you have? I have no problem going out and getting a new one I just want to make sure that would be the problem. I know you can say 100% it will fix my problem but it \makes sense that mine would not support E & I since I have had all these problems and mine says consumption in the red box.

It’s not about getting a new one or a different model. The difference between a consumption meter, a production meter, and an E+I meter is a relationship of where the CTs are installed on the line, where the PV ties relative to everything else, and your utility meter and/or main load breaker are. The wattnode is a good meter and will work in all possible modes. If you really want to change it to be an E+I meter you’d need to take off all your panel covers to see if it’s possible to fit the CTs in the right location: there may not be, so your installer did it this way.

But that doesn’t mean you can’t calculate the data, just that you can’t use it at face value. You can get E+I values by taking the consumption meter values and adding them to PV production, which doesn’t require any physical electrical work just template math. This is how the solaredge portal does it. So for example if you’re generating 6000W PV and consuming 2000W, then 6000 + (-2000) = 4000W export.

My CT’s are installed in the breaker box on the two legs coming in from the utility. Where would be the correct place you are talking about?

Maybe someone else can help more, that’s about as much I can do.

You have a meter, it works fine, use the data and calculate the answer. Or call your installer and tell them you want your meter CTs relocated for E+I instead of consumption if you don’t like the calculating method of obtaining the same data.

Hi, I have three phase power, with a CT on each phase. When I add the integration, should I be ticking all three boxes?

image

You only need Meter 1 data…

1 Like

I am not quite sure about the correct location, but I think as @WillCodeForCats mentioned, you already have the required data. Just my formulas don’t work because your setup is different. And yes…my meter shows Import and Export:
image

So…probably the easiest would be to rebuild the formulas. I can have a look at it, but it may take a while. It is a bit of a puzzle to work out…

Thanks @Remko. I already contacted my installer with a lot more information about my system than I have shared here so hopefully they can make a recommendation on how to fix/update the system. I also sent in a support ticket to ctlsys.com to see if my meter does or doesn’t support E & I. If it doesn’t then I asked if they could give me a list that does. I will share that if they do. I have been looking at the energy file and it is very much a puzzle to me. I can tell that some of the items in the code are linked to other items. But I just don’t fully understand what everything means in the code. I really do appreciate all the help you and @WillCodeForCats have done for me. I know it isn’t always fun trying to figure out someone else’s problem.

CTs located between utility meter and PV tie in point will give E+I values. CTs located between PV tie in point and the load will give consumption values. For CTs located on the PV side of the PV tie in point will give production values. Same meter, three different ways to locate the CTs. You can buy new meters all you want but it won’t change anything if you don’t rewire your panels, and to be blunt if you’re asking these questions you probably don’t know enough about the physical side of things to do that so just stick with the template sensor method described below.

For calculating E+I with a consumption meter use:
sensor.solaredge_i1_ac_power + sensor.solaredge_m1_ac_power

For multiple inverters use:
(sensor.solaredge_i1_ac_power + sensor.solaredge_i2_ac_power sensor.solaredge_i3_ac_power) + sensor.solaredge_m1_ac_power

You can make a template sensor for the calculation like this:

sensor:
    - name: "solaredge_calculated_ei"
      unique_id: 'solaredge_calculated_ei_watts'
      attributes:
        friendly_name: "SolarEdge Calculated E+I"
      unit_of_measurement: 'W'
      state_class: 'total'
      state: >-
          {{((states('sensor.solaredge_i1_ac_power')|float + states('sensor.solaredge_i2_ac_power')|float + states('sensor.solaredge_i3_ac_power')|float) + (states('sensor.solaredge_m1_ac_power')|float))|round(0)}}

Then use sensor.solaredge_calculated_ei like normal.

Edit: Home Assistant 2022.12 now has a Summing entities without templates feature.

Could anyone help me figure out why my card during export shows that it is flowing from battery to house to panels? Below my energy config and Tesla card. Thanks in advance.

template:
  - sensor:
    - name: "Solar Selfconsumption Ratio"
      unique_id: solar_selfconsumption_ratio
      icon: mdi:percent-outline
      state: >
        {% if (((states('sensor.solar_panel_to_house_daily')| float(0)) + (states('sensor.solar_battery_in_daily')| float(0)) + (states('sensor.solar_exported_power_daiy')| float(0))) <= 0) %}
          0
        {% else %}
          {{((((states('sensor.solar_panel_to_house_daily')| float(0)) + (states('sensor.solar_battery_in_daily')| float(0))) / ((states('sensor.solar_panel_to_house_daily')| float(0)) + (states('sensor.solar_battery_in_daily')| float(0)) + (states('sensor.solar_exported_power_daily')| float(0)))) * 100) | round (0) }}
        {% endif %}
    - name: "Solar Autarkie Ratio"
      unique_id: solar_autarkie_ratio
      icon: mdi:percent-outline
      state: >
        {% if ((states('sensor.solar_house_consumption_daily') | float(0)) <= 0) %}
          0
        {% else %}
          {{((1 - ((states('sensor.solar_imported_power_daily') | float(0)) / (states('sensor.solar_house_consumption_daily') | float(0)))) * 100 ) | round (0)}}   
        {% endif %}  
    
    - name: "Solar Inverter Effectiveness"
      unique_id: solar_inverter_effectiveness
      icon: mdi:percent-outline
      unit_of_measurement: '%'
      state: >
        {% if ((states('sensor.solaredge_dc_power') | float(0)) < 100) or ((states('sensor.solaredge_ac_power') | float(0)) < 100)%}
          {{(states('sensor.solar_inverter_effectiveness'))}}
        {% else %}
          {% if is_state('sensor.solar_inverter_effectiveness', 'unknown') %}
            1
          {% elif ((states('sensor.solaredge_ac_power') | float(0)) <= 0) %}
            {{(states('sensor.solar_inverter_effectiveness'))}}
          {% elif ((states('sensor.solaredge_dc_power') | float(0)) <= 0) %}
            {{(states('sensor.solar_inverter_effectiveness'))}}
          {% else %}
            {{(states('sensor.solaredge_ac_power') | float(0)) / (states('sensor.solaredge_dc_power') | float(0))}}
          {% endif %}
        {% endif %}
        
    - name: "Solar Battery Effectiveness"
      unique_id: solar_battery_effectiveness
      icon: mdi:percent-outline
      unit_of_measurement: '%'
      state: >       
        {% if (((states('sensor.solaredge_dc_power') | float(0)) + (states('sensor.solaredge_battery1_power') | float(0))) <= 0 ) %}
          {% if ((states('sensor.solaredge_battery1_power')| float(0)) >= 0) %}
            {{(states('sensor.solar_battery_effectiveness'))}}
          {% elif ((states('sensor.solaredge_dc_power') | float(0)) <= 0) %}
            {{(states('sensor.solar_battery_effectiveness'))}}  
          {% else %}
            {{1 - ((((states('sensor.solaredge_battery1_power') | float(0)) * -1) - (states('sensor.solaredge_dc_power') | float(0))) /  ((states('sensor.solaredge_battery1_power') | float(0)) * -1))}}
          {% endif %} 
        {% elif is_state('sensor.solar_battery_effectiveness', 'unknown') %}
          1
        {% elif is_state('sensor.solar_battery_effectiveness', 0) %}
          1
        {% else %}
          {{(states('sensor.solar_battery_effectiveness'))}}
        {% endif %}

    - name: "Solar Panel Production W"
      unique_id: solar_panel_production_w
      unit_of_measurement: 'W'
      icon: mdi:solar-power
      state: >  
        {% if ((states('sensor.solaredge_dc_power') | float(0)) + (states('sensor.solaredge_battery1_power') | float(0)) <= 0) %}
          0
        {% elif (is_state('sensor.solaredge_dc_power', 'unknown')) or (is_state('sensor.solaredge_battery1_power', 'unknown'))%}
          0
        {% else %}
          {{((states('sensor.solaredge_dc_power') | float(0)) + (states('sensor.solaredge_battery1_power') | float(0)))}}
        {% endif %}      

    - name: "Solar Panel To House W"
      unique_id: solar_panel_to_house_w
      unit_of_measurement: 'W'
      icon: mdi:solar-power
      state: > 
        {% if ((states('sensor.solaredge_battery1_power') | float(0)) >= 0) and ((states('sensor.solaredge_m1_ac_power') | float(0)) > 0) %}
          {{(states('sensor.solaredge_ac_power') | float(0) - states('sensor.solaredge_m1_ac_power') | float(0))}}
        {% elif ((states('sensor.solaredge_battery1_power') | float(0)) >= 0) and ((states('sensor.solaredge_m1_ac_power') | float(0)) <= 0) %}
          {{states('sensor.solaredge_ac_power') | float(0)}}
        {% elif ((states('sensor.solaredge_battery1_power') | float(0)) < 0)%}
          {% if ((states('sensor.solaredge_dc_power') | float(0) + states('sensor.solaredge_battery1_power') | float(0)) < 0 ) %}
            0
          {% else %}
            {{((states('sensor.solaredge_dc_power') | float(0)) + (states('sensor.solaredge_battery1_power') | float(0))) * (states('sensor.solar_inverter_effectiveness') | float(0))}}
          {% endif %}   
        {% else %}
          0
        {% endif %}  
        
    - name: "Solar Battery To Grid W"
      unique_id: solar_battery_to_grid_w
      unit_of_measurement: "W"
      icon: mdi:solar-power
      state: >
        {% set exported_power_w = states('sensor.solar_exported_power_w') | float(0) %}
        {% set panel_to_grid_w = states('sensor.solar_panel_to_grid_w') | float(0) %}
        
        {% if (exported_power_w > panel_to_grid_w) %}
          {{ exported_power_w - panel_to_grid_w }}
        {% else %}
          0
        {% endif %}
    - name: "Solar Grid To House W"
      unique_id: solar_grid_to_house_w
      unit_of_measurement: 'W'
      icon: mdi:transmission-tower-export
      state: > 
        {% if ((states('sensor.solaredge_m1_ac_power') | float(0)) <= 0) %}
          {{((states('sensor.solaredge_m1_ac_power') | float(0)) *-1)}}
        {% else %}
          0
        {% endif %}

    - name: "Solar Panel To Grid W"
      unique_id: solar_panel_to_grid_w
      unit_of_measurement: 'W'
      icon: mdi:solar-power
      state: >  
        {% if ((states('sensor.solaredge_m1_ac_power') | float(0)) > 0) %}
          {{(states('sensor.solaredge_m1_ac_power') | float(0))}}
        {% else %}
          0
        {% endif %}   

    - name: "Solar Battery To House W"
      unique_id: solar_battery_to_house_w
      unit_of_measurement: 'W'
      icon: mdi:battery-negative
      state: >   
        {% if ((states('sensor.solaredge_battery1_power') | float(0)) < 0) %}
          {{((states('sensor.solaredge_battery1_power') | float(0)) * -1) * (states('sensor.solar_battery_effectiveness')| float(0)) * (states('sensor.solar_inverter_effectiveness')| float(0))}}
        {% else %}
          0
        {% endif %} 

    - name: "Solar Panel To Battery W"
      unique_id: solar_panel_to_battery_w
      unit_of_measurement: 'W'
      icon: mdi:solar-power
      state: >    
        {% if ((states('sensor.solaredge_battery1_power') | float(0)) > 0) %}
          {% if ((states('sensor.solar_grid_to_battery_w') | float(0)) > 0) %}
            0
          {% else %}
            {{(states('sensor.solaredge_battery1_power') | float(0))}}
          {% endif %} 
        {% else %}
          0
        {% endif %}
 
    - name: "Solar Grid To Battery W"
      unique_id: solar_grid_to_battery_w
      unit_of_measurement: 'W'
      icon: mdi:battery-positive
      state: >
        {% if ((states('sensor.solaredge_ac_power') | float) <= 0) and ((states('sensor.solaredge_battery1_power') | float(0)) > 0) %}
          {{(states('sensor.solaredge_battery1_power') | float(0))}}
        {% else %}
          0
        {% endif %} 

    - name: "Solar Battery In W"
      unique_id: solar_battery_in_w
      unit_of_measurement: 'W'
      icon: mdi:battery-positive
      state: >           
        {{(states('sensor.solar_grid_to_battery_w') | float(0)) + (states('sensor.solar_panel_to_battery_w') | float(0))}}  

    - name: "Solar House Consumption W"
      unique_id: solar_house_consumption_w
      unit_of_measurement: 'W'
      icon: mdi:home
      state: >             
        {{(states('sensor.solar_panel_to_house_w') | float(0)) + (states('sensor.solar_battery_to_house_w') | float(0)) + (states('sensor.solar_grid_to_house_w') | float(0))}}  

    - name: "Solar Imported Power W"
      unique_id: solar_imported_power_w
      unit_of_measurement: 'W'
      icon: mdi:transmission-tower-export
      state: >          
        {% if ((states('sensor.solaredge_m1_ac_power') | float(0)) <= 0) %}
          {{((states('sensor.solaredge_m1_ac_power') | float(0)) *-1)}}
        {% else %}
          0
        {% endif %}       

    - name: "Solar Exported Power W"
      unique_id: solar_exported_power_w
      unit_of_measurement: 'W'
      icon: mdi:transmission-tower-import
      state: >            
        {% if ((states('sensor.solaredge_m1_ac_power') | float(0)) > 0) %}
          {{(states('sensor.solaredge_m1_ac_power') | float(0))}}
        {% else %}
          0
        {% endif %}        

    - name: "Solar Lifetime Production"
      unique_id: solar_lifetime_production
      unit_of_measurement: 'MWh'
      icon: mdi:solar-power
      state: >    
        {{(((states('sensor.solaredge_ac_energy_kwh') | float(0)) / 1000) | round (2))}}
                 
sensor:
  - platform: integration
    source: sensor.solar_panel_production_w
    method: left
    unit_prefix: k
    name: solar_panel_production_kwh 
  - platform: integration
    source: sensor.solar_battery_to_house_w
    method: left
    unit_prefix: k
    name: solar_battery_out_kwh 
  - platform: integration
    source: sensor.solar_battery_in_w
    method: left
    unit_prefix: k
    name: solar_battery_in_kwh 
  - platform: integration
    source: sensor.solar_house_consumption_w
    method: left
    unit_prefix: k
    name: solar_house_consumption_kwh 
  - platform: integration
    source: sensor.solar_imported_power_w
    method: left
    unit_prefix: k
    name: solar_imported_power_kwh 
  - platform: integration
    source: sensor.solar_exported_power_w
    method: left
    unit_prefix: k
    name: solar_exported_power_kwh 
  - platform: integration
    source: sensor.solar_panel_to_house_w
    method: left
    unit_prefix: k
    name: solar_panel_to_house_kwh

  - platform: statistics
    name: "Solar Battery Effectiveness Average"
    unique_id: solar_battery_effectiveness_average
    state_characteristic: mean
    sampling_size: 1200
    max_age:
      hours: 24
    entity_id: sensor.solar_battery_effectiveness

  - platform: statistics
    name: "Solar Inverter Effectiveness Average"
    unique_id: solar_inverter_effectiveness_average
    state_characteristic: mean
    sampling_size: 1200
    max_age:
      hours: 24
    entity_id: sensor.solar_inverter_effectiveness

    
utility_meter:
  solar_panel_production_daily:
    source: sensor.solar_panel_production_kwh
    name: Solar Panel Production Daily
    cycle: daily
  solar_battery_in_daily:
    source: sensor.solar_battery_in_kwh
    name: Solar Battery In Daily
    cycle: daily 
  solar_battery_out_daily:
    source: sensor.solar_battery_out_kwh
    name: Solar Battery Out Daily
    cycle: daily
  solar_house_consumption_daily:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Daily
    cycle: daily 
  solar_imported_power_daily:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Daily
    cycle: daily 
  solar_imported_power_daily_solaredge:
    source: sensor.solaredge_m1_imported_kwh
    name: Solar Imported Power Daily Solar Edge
    cycle: daily 
  solar_exported_power_daily:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Daily
    cycle: daily
  solar_panel_to_house_daily:
    source: sensor.solar_panel_to_house_kwh
    name: Solar Panel To House Daily
    cycle: daily

  solar_panel_to_house_weekly:
    source: sensor.solar_panel_to_house_kwh
    name: Solar Panel To House Weekly
    cycle: weekly
  solar_imported_power_weekly:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Weekly
    cycle: weekly 
  solar_house_consumption_weekly:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Weekly
    cycle: weekly 
  solar_panel_production_weekly:
    source: sensor.solar_panel_production_kwh
    name: Solar Panel Production Weekly
    cycle: weekly
  solar_battery_in_weekly:
    source: sensor.solar_battery_in_kwh
    name: Solar Battery In Weekly
    cycle: weekly 
  solar_battery_out_weekly:
    source: sensor.solar_battery_out_kwh
    name: Solar Battery Out Weekly
    cycle: weekly
  solar_exported_power_weekly:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Weekly
    cycle: weekly
    
  solar_panel_to_house_monthly:
    source: sensor.solar_panel_to_house_kwh
    name: Solar Panel To House Monthly
    cycle: monthly
  solar_imported_power_monthly:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Monthly
    cycle: monthly 
  solar_house_consumption_monthly:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Monthly
    cycle: monthly 
  solar_panel_production_monthly:
    source: sensor.solar_panel_production_kwh
    name: Solar Panel Production Monthly
    cycle: monthly
  solar_battery_in_monthly:
    source: sensor.solar_battery_in_kwh
    name: Solar Battery In Monthly
    cycle: monthly 
  solar_battery_out_monthly:
    source: sensor.solar_battery_out_kwh
    name: Solar Battery Out Monthly
    cycle: monthly
  solar_exported_power_monthly:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Monthly
    cycle: monthly
    
  solar_panel_to_house_yearly:
    source: sensor.solar_panel_to_house_kwh
    name: Solar Panel To House Yearly
    cycle: yearly
  solar_imported_power_yearly:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Yearly
    cycle: yearly 
  solar_house_consumption_yearly:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Yearly
    cycle: yearly 
  solar_panel_production_yearly:
    source: sensor.solar_panel_production_kwh
    name: Solar Panel Production Yearly
    cycle: yearly
  solar_battery_in_yearly:
    source: sensor.solar_battery_in_kwh
    name: Solar Battery In Yearly
    cycle: yearly 
  solar_battery_out_yearly:
    source: sensor.solar_battery_out_kwh
    name: Solar Battery Out Yearly
    cycle: yearly
  solar_exported_power_yearly:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Yearly
    cycle: yearly
type: custom:tesla-style-solar-power-card
name: Home Energy Flow
grid_to_house_entity: sensor.solar_grid_to_house_w
grid_to_battery_entity: sensor.solar_grid_to_battery_w
generation_to_grid_entity: sensor.solar_panel_to_grid_w
generation_to_battery_entity: sensor.solar_panel_to_battery_w
generation_to_house_entity: sensor.solar_panel_to_house_w
battery_to_house_entity: sensor.solar_battery_to_house_w
battery_to_grid_entity: sensor.solar_battery_to_grid_w
battery_extra_entity: sensor.solaredge_battery1_state_of_charge
show_gap: true
hide_inactive_lines: 1
threshold_in_k: 1
grid_icon: mdi:transmission-tower
generation_icon: mdi:solar-power-variant-outline
house_icon: mdi:home-lightning-bolt-outline
battery_icon: mdi:battery-high

Have seen that they solved it but for Tesla battery. The battery to grid part.

@WillCodeForCats Thanks for the update on Summing entities. That should make some of these a lot easier! I also asked my installer about where my CT’s are located and he explained that because I have a backup generator, my tie in point is actually in my ATS panel and not in the electric panel where a lot of the tie ins go. So, I might get some longer cable and move them to that point in a few months. For anyone else with my issue the picture below shows three points where the CT’s can be placed. Obviously, I am talking about changing things that have electricity so don’t mess with your stuff unless you know what you’re doing. Otherwise, get a hold of an electrician so you dont hurt/kill yourself. Mine are on the red circle and I will move them to where the green circle is. When he explained this the entire install makes sense to me. Thanks for pointing that part out as I always wondered where the inverters put the electricity back into my system.

For code you posted above, is that correct? Should line 8 contain “+ sensor.solaredge_i3_ac_power” or is there a reason its not in there? Thanks again definitely appreciate the help.

I spoke with a tech at ctlsys and he said every meter they have ever made will do consumption/production, and Export & Import. I found this out before I understood where my inverter output was connected to my system (in the ATS).

Clamp placement

Oops, no, that shouldn’t be in there at all. That was just my visual reference for all the template stuff. I’ve edited it.

Copy pasting the code in energy.yaml i get the following error

expected a dictionary for dictionary value @ data[‘packages’][‘template’]

I”m using HAssOS latest version

Hi guys… I have a problem with this device.
If I try to change the “solaredge (Storage Remote Command Timeout)” parameter from 3600 to 36000 - it works, but at the end of the 36000 Sec it returns to the value 3600.
Or at each change of “solaredge (Storage Remote Command Mode)” it returns again at 3600…
Why do you think? What can I do? I need it to charge the battery at night, but with 3600 I would have to do many 1-hour charges, it would be very inconvenient…

thanks guys :wink:

Hi,

@Remko thank you very much for your template. I already used your „old version“ and now switched to the new one. @WillCodeForCats thank you for the great plug-in. The last days I had nearly the exact values as the Solar Edge App. But yesterday (first day with a lot of sun) the following happened. Do you have any ideas why the house consumption stays at value 0? Later when the battery was used the value increased. I used your energy template from the first post.







P.s Maybe you could publish your Energy.YAML configuration in a GitHub repository instead of a thread … that would simplify the change tracking a lot.

Thank you!

The “energy went backwards” warnings are a known issue. LG batteries do not provide lifetime charge/discharge data. There is no fix since it is a hardware (battery controller) issue. SolarEdge Energy Bank batteries have been reported to use lifetime counters correctly. Unfortunately this means the battery import/export data on LG batteries can’t be used for reliable reporting since they reset to zero.

Hey Guys,

Im hoping you can help me understand the solar production graph, but before i get into my issue, thanks for the great integrations and dashboards supplied here, awesome work.

I have a Solaredge single inverter and battery setup installed a few weeks ago, i’ve enabled the modbus over TCP and have been colleting data in home assistant fine. My issue is i cant for the life of me work out what entity i need to use to get accurate data in the solar production graph. Theres doesnt seem to be a direct entity for this in the modbus integration, and i’ve experimented with templates combining i1_energy and b1_export etc but cant get it right.

In your dashboard you seem to have it showing correctly, but (unless im missing something) you dont detail the config for the standard energy dashboard in the config you’ve posted?

Help with this would be very gratefully received. :slight_smile:

1 Like

I don’t have the battery but for the energy dashboard I use solaredge M1 imported/exported kwh.

I imagine there’s similar ones for the battery in and out.