SolarEdge Modbus Multi config for Single Inverter, Battery and Backup Module/Meter

This is a fork of the great work already done by Remko with his post: Solaredge Modbus Configuration for Single Inverter and Battery. For the HACS integration:

For who is this fork?
Remko’s original post was from Sep '22. Things have changed in the mean time. I used his code, but I had to change a lot because my entity names were not the same. My 3 devices were named:

- Solaredge I1
- Solaredge I1 M1
- Solaredge I1 B1

Also I wanted the bare essentials and no tariffs etc.

Backstory
From 2023 up till April 2025 I had a SolarEdge SE3K inverter. I wanted a SolarEdge Battery and this was not possible with this inverter. SolarEdge had a trade-in program (new inverter for the old), so I got the new SE5K-RWB48 (SE5K-HUB) with the SolarEdge Home Backup Interface (BI-EU3P) and 2 SolarEdge 48V Home Battery’s.

Up until the new system I ran the official SolarEdge integration in Home Assistant and that worked great. I got the same numbers as the Monitoring app from SolarEdge. This al changed with the new system. The numbers SolarEdge’s API gave me weren’t correct. Also within the app of my energy provider, where I also made a link to SolarEdge was providing very strange numbers.
I created a case with SolarEdge, and after some convincing that their numbers where wrong, they admitted that there was a problem:

Our monitoring system displays data based on numerous calculations and algorithms, and lately, we’ve noticed that this isn’t always calculated correctly on our end.

This is a long-standing bug in our monitoring portal.

A completely new monitoring system will be rolled out in the near future that will resolve these types of issues.

So left with nothing to see what my system was doing, I searched for a solution. The HA original integration “SolarEdge Local” didn’t work for me. So HACS to the rescue. There I found “SolarEdge Modbus”. But this didn’t worked also. And so I came to “SolarEdge Modbus Multi” and this one worked! I asked my installer to enable the Modbus TCP in my inverter and got to work.

This integration gave me a bunch of numbers, but I soon noticed that it didn’t gave me all the numbers I was looking for. Especially what my solar panels were doing, and where the power went. So more searching and reading. And that’s how I ended up with Remko’s post.

But… Like so many times getting it all to work wasn’t straightforward. The naming of my entity’s didn’t correspond with Remko’s. The recorder part shutdown all other recordings. Some naming was different. Dashboard was in the old style and many more things. Also I missed some key information in the main post, so I had to read a lot to get everything working.

So in this post I will try to give a complete manual of everything I did. If you see anything wrong, let me know!

I’ll assume that you already have Modbus TCP acces to you’re inverter and you have HACS installed in you’re Home Assistant.

  1. With HACS install the “SolarEdge Modbus Multi”. Then in “Integrations” add the “SolarEdge Modbus Multi”. I use 10 sec for ‘call frequency’ (haven’t had any problems with this high frequency), but you can change that if you want. I checked the boxes for “Automatic meter detection” and “Automatic battery detection” and left the others unchecked or standard.

Now this is key!! The naming of my devices is “Solaredge I1”, “Solaredge I1 M1” and “Solaredge I1 B1”. So an entity within my meter looks like this: sensor.solaredge_i1_m1_ac_power. This is key, because that’s where my files are based on.

  1. From the GitHub Remko’s created I only used 3 files: “energy_utilities.yaml”, “energy_stats.yaml” and "“electricity.yaml”. I changed the naming of the entities to mine, and also deleted some code that I didn’t find necessary like weekly numbers. Here are the 3 files: (check different entity names in the code below if they correspond to your entities!!)

electricity.yaml

template:
  - sensor:
    - name: "Solar Panel Production W"
      unique_id: solar_panel_production_w
      unit_of_measurement: "W"
      icon: mdi:solar-power
      state: >
        {% set i1_dc_power = states('sensor.solaredge_i1_dc_power') | float(0) %}
        {% set b1_dc_power = states('sensor.solaredge_i1_b1_dc_power') | float(0) %}

        {% if (is_state('sensor.solaredge_i1_dc_power', 'unknown') or is_state('sensor.solaredge_i1_b1_dc_power', 'unknown')) %}
          0
        {% elif (i1_dc_power + b1_dc_power <= 0) %}
          0
        {% else %}
          {{ (i1_dc_power + b1_dc_power) }}
        {% endif %}
      availability: >
        {{ states('sensor.solaredge_i1_dc_power') | is_number and states('sensor.solaredge_i1_ac_power') | is_number and states('sensor.solaredge_i1_b1_dc_power') | is_number }}

    - name: "Solar Panel To House W"
      unique_id: solar_panel_to_house_w
      unit_of_measurement: "W"
      icon: mdi:solar-power
      state: >
        {% set i1_dc_power = states('sensor.solaredge_i1_dc_power') | float(0) %}
        {% set i1_ac_power = states('sensor.solaredge_i1_ac_power') | float(0) %}
        {% set b1_dc_power = states('sensor.solaredge_i1_b1_dc_power') | float(0) %}
        {% set m1_ac_power = states('sensor.solaredge_i1_m1_ac_power') | float(0) %}
        {% set inverter_effectiveness = states('sensor.solar_inverter_effectiveness') | float(0) %}

        {% if (b1_dc_power >= 0 and m1_ac_power > 0) %}
          {% if (i1_dc_power < 0 and i1_ac_power <= 0) %}
            {{ (i1_dc_power - m1_ac_power) }}
          {% else %}
            {{ (i1_ac_power - m1_ac_power) }}
          {% endif %}
        {% elif (b1_dc_power >= 0 and m1_ac_power <= 0) %}
          {% if (i1_dc_power < 0 and i1_ac_power <= 0) %}
            0{#{{ (i1_dc_power) }}#}{# Added 0 #}
          {% else %}
            {{ (i1_ac_power) }}
          {% endif %}
        {% elif (b1_dc_power < 0) %}
          {% if (i1_dc_power + b1_dc_power < 0) %}
            0
          {% else %}
            {{ ((i1_dc_power + b1_dc_power) * inverter_effectiveness) }}
          {% endif %}   
        {% else %}
          0
        {% endif %}
      availability: >
        {{ states('sensor.solaredge_i1_dc_power') | is_number and states('sensor.solaredge_i1_ac_power') | is_number and states('sensor.solaredge_i1_b1_dc_power') | is_number and states('sensor.solaredge_i1_m1_ac_power') | is_number }}

    - name: "Solar Panel To Battery W"
      unique_id: solar_panel_to_battery_w
      unit_of_measurement: "W"
      icon: mdi:solar-power
      state: >
        {% set i1_dc_power = states('sensor.solaredge_i1_dc_power') | float(0) %}
        {% set i1_ac_power = states('sensor.solaredge_i1_ac_power') | float(0) %}
        {% set b1_dc_power = states('sensor.solaredge_i1_b1_dc_power') | float(0) %}
        {% set grid_to_battery_w = states('sensor.solar_grid_to_battery_w') | float(0) %}

        {% if (b1_dc_power > 0) %}
          {% if (grid_to_battery_w > 0) %} {# Added this snippet instead of 0 #}
            {% if (i1_dc_power < 0 and i1_ac_power <= 0) %}
              {{ (b1_dc_power+i1_dc_power) }}
            {% else %}
              0
            {% endif %}
          {% else %}
            {{ b1_dc_power }}
          {% endif %} 
        {% else %}
          0
        {% endif %}
      availability: >
        {{ states('sensor.solaredge_i1_b1_dc_power') | is_number }}
        
    - name: "Solar Panel To Grid W"
      unique_id: solar_panel_to_grid_w
      unit_of_measurement: "W"
      icon: mdi:solar-power
      state: >
        {% set panel_production_w = states('sensor.solar_panel_production_w') | float(0) %}
        {% set exported_power_w = states('sensor.solar_exported_power_w') | float(0) %}

        {% if (exported_power_w > 0 and panel_production_w > 0) %}
          {% if (exported_power_w > panel_production_w) %}
            {{ panel_production_w }}
          {% else %}
            {{ exported_power_w }}
          {% endif %}
        {% 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: >
        {% set b1_dc_power = states('sensor.solaredge_i1_b1_dc_power') | float(0) %}
        {% set battery_effectiveness = states('sensor.solar_battery_effectiveness') | float(0) %}
        {% set inverter_effectiveness = states('sensor.solar_inverter_effectiveness') | float(0) %}

        {% if (b1_dc_power < 0) %}
          {{ (b1_dc_power * -1 * battery_effectiveness * inverter_effectiveness) }}
        {% else %}
          0
        {% endif %}
      availability: >
        {{ states('sensor.solaredge_i1_b1_dc_power') | is_number }}
          
    - 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: >
        {% set m1_ac_power = states('sensor.solaredge_i1_m1_ac_power') | float(0) %}
        {% set grid_to_battery_w = states('sensor.solar_grid_to_battery_w') | float(0) %}

        {% if (m1_ac_power <= 0) %}
          {{ (m1_ac_power * -1) - grid_to_battery_w }} {# Added grid_to_battery_w. #}
        {% else %}
          0
        {% endif %}
      availability: >
        {{ states('sensor.solaredge_i1_m1_ac_power') | is_number }}
          
    - name: "Solar Grid To Battery W"
      unique_id: solar_grid_to_battery_w
      unit_of_measurement: "W"
      icon: mdi:battery-positive
      state: >
        {% set i1_ac_power = states('sensor.solaredge_i1_ac_power') | float(0) %}
        {% set b1_dc_power = states('sensor.solaredge_i1_b1_dc_power') | float(0) %}
        {% set i1_dc_power = states('sensor.solaredge_i1_dc_power') | float(0) %}

        {% if (i1_ac_power <= -25 and b1_dc_power > 0) %} {#added -25 instead of 0#}
          {{ i1_dc_power|abs }} {# Changed to i1_dc_power #}
        {% else %}
          0
        {% endif %}
      availability: >
        {{ states('sensor.solaredge_i1_ac_power') | is_number and states('sensor.solaredge_i1_b1_dc_power') | is_number}}

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

        {{ (grid_to_battery_w + panel_to_battery_w) }}

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

        {{ (panel_to_house_w + battery_to_house_w + grid_to_house_w) }}

    - name: "Solar Imported Power W"
      unique_id: solar_imported_power_w
      unit_of_measurement: "W"
      icon: mdi:transmission-tower-export
      state: >
        {% set m1_ac_power = states('sensor.solaredge_i1_m1_ac_power') | float(0) %}

        {% if (m1_ac_power < 0) %}
          {{ (m1_ac_power * -1) }}
        {% else %}
          0
        {% endif %}
      availability: >
        {{ states('sensor.solaredge_i1_m1_ac_power') | is_number}}

    - name: "Solar Exported Power W"
      unique_id: solar_exported_power_w
      unit_of_measurement: "W"
      icon: mdi:transmission-tower-import
      state: >
        {% set m1_ac_power = states('sensor.solaredge_i1_m1_ac_power') | float(0) %}

        {% if (m1_ac_power > 0) %}
          {{ (m1_ac_power) }}
        {% else %}
          0
        {% endif %}
      availability: >
        {{ states('sensor.solaredge_i1_ac_power') | is_number }}
          
    - name: "Solar Lifetime Production"
      unique_id: solar_lifetime_production
      unit_of_measurement: "MWh"
      icon: mdi:solar-power
      state: >
        {% set ac_energy_kwh = states('sensor.solaredge_i1_ac_energy') | float(0) %}

        {{ ((ac_energy_kwh / 1000) | round (2)) }}
         
      availability: >
        {{ states('sensor.solaredge_i1_ac_energy') | is_number }}

sensor:
  # Panels
  - platform: integration
    source: sensor.solar_panel_production_w
    method: left
    unit_prefix: k
    name: solar_panel_production_kwh
  - platform: integration
    source: sensor.solar_panel_to_house_w
    method: left
    unit_prefix: k
    name: solar_panel_to_house_kwh
  - platform: integration
    source: sensor.solar_panel_to_battery_w
    method: left
    unit_prefix: k
    name: solar_panel_to_battery_kwh

  # Grid
  - platform: integration
    source: sensor.solar_imported_power_w
    method: left
    unit_prefix: k
    name: solar_imported_power_kwh
  - platform: integration
    source: sensor.solar_grid_to_battery_w
    method: left
    unit_prefix: k
    name: solar_grid_to_battery_kwh
  - platform: integration
    source: sensor.solar_exported_power_w
    method: left
    unit_prefix: k
    name: solar_exported_power_kwh

  # Battery
  - 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

  # House
  - platform: integration
    source: sensor.solar_house_consumption_w
    method: left
    unit_prefix: k
    name: solar_house_consumption_kwh

energy_stats.yaml

template:
  - sensor:
    - name: "Solar Selfconsumption Ratio"
      unique_id: solar_selfconsumption_ratio
      icon: mdi:percent-outline
      state: >
        {% set panel_to_house_daily = states('sensor.solar_panel_to_house_daily') | float(0) %}
        {% set battery_in_daily = states('sensor.solar_battery_in_daily') | float(0) %}
        {% set exported_power_daiy = states('sensor.solar_exported_power_daiy') | float(0) %}

        {% if (panel_to_house_daily + battery_in_daily + exported_power_daiy <= 0) %}
          0
        {% else %}
          {{ ((panel_to_house_daily + battery_in_daily) / (panel_to_house_daily + battery_in_daily + exported_power_daiy) * 100) | round (1) }}
        {% endif %}

    - name: "Solar Autarkie Ratio"
      unique_id: solar_autarkie_ratio
      icon: mdi:percent-outline
      state: >
        {% set house_consumption_daily = states('sensor.solar_house_consumption_daily') | float(0) %}
        {% set imported_power_daily = states('sensor.solar_imported_power_daily') | float(0) %}

        {% if (house_consumption_daily <= 0) %}
          0
        {% else %}
          {{ (1 - (imported_power_daily / house_consumption_daily) * 100) | round (1) }}
        {% endif %}

    - name: "Solar Inverter Effectiveness"
      unique_id: solar_inverter_effectiveness
      icon: mdi:percent-outline
      unit_of_measurement: "%"
      state: >
        {% set i1_dc_power = states('sensor.solaredge_i1_dc_power') | float(0) %}
        {% set i1_ac_power = states('sensor.solaredge_i1_ac_power') | float(0) %}
        {% set inverter_effectiveness = states('sensor.solar_inverter_effectiveness') %}

        {% if (is_state('sensor.solar_inverter_effectiveness', 'unknown')) %}
          1
        {% elif (i1_dc_power < 100 or i1_ac_power  < 100) %}
          {{ inverter_effectiveness }}
        {% else %}
          {{ (i1_ac_power ) / (i1_dc_power) }}
        {% endif %}
      availability: >
        {{ states('sensor.solaredge_i1_dc_power') | is_number and states('sensor.solaredge_i1_ac_power') | is_number }}        

    - name: "Solar Battery Effectiveness"
      unique_id: solar_battery_effectiveness
      icon: mdi:percent-outline
      unit_of_measurement: "%"
      state: >
        {% set i1_dc_power = states('sensor.solaredge_i1_dc_power') | float(0) %}
        {% set b1_dc_power = states('sensor.solaredge_i1_b1_dc_power') | float(0) %}
        {% set battery_effectiveness = states('sensor.solar_battery_effectiveness') %}
        
        {% if (is_state('sensor.solar_battery_effectiveness', 'unknown') or (solar_battery_effectiveness == 0)) or (is_state('sensor.solar_battery_effectiveness', 'unavailable'))%}
          1
        {% elif (i1_dc_power + b1_dc_power <= 0) %}
          {% if (b1_dc_power >= 0 or i1_dc_power <= 0) %}
            {{ battery_effectiveness }}
          {% else %}
            {{ (1 - ((b1_dc_power * -1 - (i1_dc_power)) / b1_dc_power * -1)) }}
          {% endif %} 
        {% else %}
          {{ battery_effectiveness }}
        {% endif %}
      availability: >
        {{ states('sensor.solaredge_i1_dc_power') | is_number and states('sensor.solaredge_i1_ac_power') | is_number and states('sensor.solaredge_i1_b1_dc_power') | is_number }}

    - name: "Solar Inverter Effectiveness Int"
      unique_id: solar_inverter_effectiveness_int
      icon: mdi:percent-outline
      unit_of_measurement: "%"
      state: >
        {{ ((states('sensor.solar_inverter_effectiveness') | float(0)) * 100) | round(2) }}

    - name: "Solar Battery Effectiveness Int"
      unique_id: solar_battery_effectiveness_int
      icon: mdi:percent-outline
      unit_of_measurement: "%"
      state: >
        {{ ((states('sensor.solar_battery_effectiveness')| float(0)) * 100) | round(2) }}

    - name: "Solar Inverter Effectiveness Average Int"
      unique_id: solar_inverter_effectiveness_average_int
      icon: mdi:percent-outline
      unit_of_measurement: "%"
      state: >
        {{ ((states('sensor.solar_inverter_effectiveness_average') | float(0)) * 100) | round(2) }}

    - name: "Solar Battery Effectiveness Average Int"
      unique_id: solar_battery_effectiveness_average_int
      icon: mdi:percent-outline
      unit_of_measurement: "%"
      state: >
        {{ ((states('sensor.solar_battery_effectiveness_average')| float(0)) * 100) | round(2) }}

sensor:
  - 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

energy_utilities.yaml

utility_meter:
### Daily
# Electricity PV Panels
  solar_panel_to_house_daily:
    source: sensor.solar_panel_to_house_kwh
    name: Solar Panel To House Daily
    cycle: daily

  solar_panel_production_daily:
    source: sensor.solar_panel_production_kwh
    name: Solar Panel Production Daily
    cycle: daily

# Electricity Grid
  solar_imported_power_daily_solaredge:
    source: sensor.solaredge_i1_m1_ac_energy_imported
    name: Solar Imported Power Daily Solar Edge
    cycle: daily

  solar_imported_power_daily:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Daily
    cycle: daily
  
# Electricity Battery
  solar_battery_from_grid_daily:
    source: sensor.solar_grid_to_battery_kwh
    name: Solar Battery Imported Daily
    cycle: daily

  solar_battery_from_panels_daily:
    source: sensor.solar_panel_to_battery_kwh
    name: Solar Battery Generated 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

# Electricity Export
  solar_exported_power_daily:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Daily
    cycle: daily

# Consumption
  solar_house_consumption_daily:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Daily
    cycle: daily


#### Monthly
# Electricity PV Panels
  solar_panel_to_house_monthly:
    source: sensor.solar_panel_to_house_kwh
    name: Solar Panel To House Monthly
    cycle: monthly

  solar_panel_production_monthly:
    source: sensor.solar_panel_production_kwh
    name: Solar Panel Production Monthly
    cycle: monthly

# Electricity Grid
  solar_imported_power_monthly_solaredge:
    source: sensor.solaredge_i1_m1_ac_energy_imported
    name: Solar Imported Power Monthly Solar Edge
    cycle: monthly

  solar_imported_power_monthly:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Monthly
    cycle: monthly

# Electricity Battery
  solar_battery_from_grid_monthly:
    source: sensor.solar_grid_to_battery_kwh
    name: Solar Battery Imported Monthly
    cycle: monthly

  solar_battery_from_panels_monthly:
    source: sensor.solar_panel_to_battery_kwh
    name: Solar Battery Generated 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

# Electricity Export
  solar_exported_power_monthly:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Monthly
    cycle: monthly

# Consumption
  solar_house_consumption_monthly:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Monthly
    cycle: monthly


####### Yearly

# Electricity PV Panels
  solar_panel_to_house_yearly:
    source: sensor.solar_panel_to_house_kwh
    name: Solar Panel To House Yearly
    cycle: yearly

  solar_panel_production_yearly:
    source: sensor.solar_panel_production_kwh
    name: Solar Panel Production Yearly
    cycle: yearly

# Electricity Grid
  solar_imported_power_yearly_solaredge:
    source: sensor.solaredge_i1_m1_ac_energy_imported
    name: Solar Imported Power Yearly Solar Edge
    cycle: yearly

  solar_imported_power_yearly:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Yearly
    cycle: yearly

  # Electricity Battery
  solar_battery_from_grid_yearly:
    source: sensor.solar_grid_to_battery_kwh
    name: Solar Battery Imported Yearly
    cycle: yearly

  solar_battery_from_panels_yearly:
    source: sensor.solar_panel_to_battery_kwh
    name: Solar Battery Generated 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

# Electricity Export
  solar_exported_power_yearly:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Yearly
    cron: "0 0 30 9 *"

# Consumption
  solar_house_consumption_yearly:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Yearly
    cycle: yearly

  1. With “File editor” (or any other similar editing program in Home Assistant) create a folder “solaredge” on top level (next to all your other HA files and folders). Within this folder create 3 files: “electricity.yaml”, “energy_stats.yaml” and “energy_utilities.yaml”. Copy the code from above.

  2. In your “configuration.yaml” add the following code:

homeassistant:
  packages: !include_dir_named solaredge
  customize:
    sensor.solar_imported_power_kwh:
      device_class: energy
    sensor.solar_exported_power_kwh:
      device_class: energy
    sensor.solar_panel_production_kwh:
      device_class: energy
    sensor.solar_panel_to_house_kwh:
      device_class: energy
    sensor.solar_panel_to_battery_kwh:
      device_class: energy
    sensor.solar_grid_to_battery_kwh:
      device_class: energy
    sensor.solar_battery_out_kwh:
      device_class: energy
    sensor.solar_battery_in_kwh:
      device_class: energy
    sensor.solar_house_consumption_kwh:
      device_class: energy

Off course after this restart your Home Assistant.

That’s it! In my next post I’ll share what to put in your Energy dashboard, Remko’s adjusted dashboard with the right entity names and other helpful tips.

Energy Dashboard

For the Solar panels I use: Solar Panel Production Daily (sensor.solar_panel_production_daily)
For Battery export I use: Solaredge I1 M1 AC Energy Exported (sensor.solaredge_i1_m1_ac_energy_exported)
For Battery import I use: Solaredge I1 M1 AC Energy Imported (sensor.solaredge_i1_m1_ac_energy_imported)

In one of the post in Remko’s post (Solaredge Modbus Configuration for Single Inverter and Battery - #45 by Remko) it said to use “sensor.solaredge_i1_ac_energy_kwh” for your solar panels, but somewhere else I found that current sensor I’m using. Try for yourself what gives you the best result.

Sample Dashboard
In Remko’s first post he gives a sample of his “Energy Dashboard”. I edited it with the right entity names:

With this code:

type: sections
max_columns: 3
title: Solar
path: solar
sections:
  - type: grid
    cards:
      - type: energy-date-selection
      - type: energy-usage-graph
        title: Energy Usage
      - type: custom:apexcharts-card
        series:
          - entity: sensor.solar_panel_to_house_daily
            name: Direct Consumption
            color: var(--energy-solar-color)
          - entity: sensor.solar_battery_out_daily
            name: Battery Usage
            color: var(--energy-battery-out-color)
          - entity: sensor.solar_imported_power_daily
            name: Imported Power
            color: var(--energy-grid-consumption-color)
        update_interval: 1min
        chart_type: donut
        apex_config:
          plotOptions:
            pie:
              expandOnClick: false
              donut:
                size: 50%
                labels:
                  show: true
                  value:
                    fontSize: 32px
                    fontWeight: 900
                  total:
                    show: true
                    showAlways: true
                    label: Autarkierate
                    formatter: |
                      EVAL:function(w) {
                        let values = w.globals.seriesTotals;
                        let total = values[0] + values[1] + values[2];
                        let self = values[0] + values[1];
                        return ((self / total) * 100).toFixed(0) + "%";
                      }
          dataLabels:
            formatter: |
              EVAL:function(value) {
                return value.toFixed(0) + "%";
              }
          chart:
            selection:
              enabled: false
          tooltip:
            enabled: false
          states:
            normal:
              filter:
                type: none
                value: 0
            hover:
              filter:
                type: none
                value: 0
            active:
              filter:
                type: none
                value: 0
          legend:
            onItemClick:
              toggleDataSeries: false
            onItemHover:
              highlightDataSeries: false
      - type: custom:apexcharts-card
        series:
          - entity: sensor.solar_panel_to_house_daily
            name: Direct Usage
            color: var(--energy-solar-color)
          - entity: sensor.solar_battery_in_daily
            name: Battery Charging
            color: var(--energy-battery-in-color)
          - entity: sensor.solar_exported_power_daily
            name: Exported Power
            color: var(--energy-grid-return-color)
        update_interval: 1min
        chart_type: donut
        apex_config:
          plotOptions:
            pie:
              expandOnClick: false
              donut:
                size: 50%
                labels:
                  show: true
                  value:
                    fontSize: 32px
                    fontWeight: 900
                  total:
                    show: true
                    showAlways: true
                    label: Self Consumption
                    formatter: |
                      EVAL:function(w) {
                        let values = w.globals.seriesTotals;
                        let total = values[0] + values[1] + values[2];
                        let self = values[0] + values[1];
                        return ((self / total) * 100).toFixed(0) + "%";
                      }
          dataLabels:
            formatter: |
              EVAL:function(value) {
                return value.toFixed(0) + "%";
              }
          chart:
            selection:
              enabled: false
          tooltip:
            enabled: false
          states:
            normal:
              filter:
                type: none
                value: 0
            hover:
              filter:
                type: none
                value: 0
            active:
              filter:
                type: none
                value: 0
          legend:
            onItemClick:
              toggleDataSeries: false
            onItemHover:
              highlightDataSeries: false
  - type: grid
    cards:
      - type: energy-solar-graph
        title: Solar Production
      - type: custom:tesla-style-solar-power-card
        name: Home Energy Flow
        change_house_bubble_color_with_flow: 1
        threshold_in_k: 1
        show_gap: true
        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_i1_b1_state_of_energy
      - type: gauge
        entity: sensor.solaredge_i1_b1_state_of_energy
        needle: true
        name: Batterij lading
        min: 0
        severity:
          green: 50
          yellow: 10
          red: 0
        max: 100
  - type: grid
    cards:
      - type: custom:power-distribution-card
        title: ""
        entities:
          - name: Grid
            preset: grid
            icon: mdi:transmission-tower
            entity: sensor.solaredge_i1_m1_ac_power
            unit_of_display: W
            decimals: 0
            invert_value: true
          - name: Solar
            preset: solar
            icon: mdi:solar-power
            entity: sensor.solar_panel_production_w
            unit_of_display: W
            decimals: 0
          - name: Home
            preset: home
            icon: mdi:home
            entity: sensor.solar_house_consumption_w
            unit_of_display: W
            decimals: 0
            invert_value: true
          - name: Battery
            preset: battery
            icon: mdi:battery-high
            entity: sensor.solaredge_i1_b1_dc_power
            unit_of_display: W
            decimals: 0
            invert_value: true
        center:
          type: bars
          content:
            - preset: custom
              name: INV
              bar_color: var(--paper-item-icon-color)
              entity: sensor.solar_inverter_effectiveness_int
            - preset: custom
              name: BAT
              bar_color: var(--paper-item-icon-color)
              entity: sensor.solar_battery_effectiveness_int
        animation: flash
      - type: entities
        entities:
          - entity: sensor.solar_panel_production_daily
            name: Produced
            icon: mdi:solar-power
          - entity: sensor.solar_house_consumption_daily
            name: Consumed
            icon: mdi:home-lightning-bolt-outline
          - entity: sensor.solar_imported_power_daily
            name: Imported
            icon: mdi:transmission-tower-export
          - entity: sensor.solar_exported_power_daily
            name: Exported
            icon: mdi:transmission-tower-import
          - entity: sensor.solar_battery_in_daily
            name: Charged
            icon: mdi:battery-positive
          - entity: sensor.solar_battery_out_daily
            name: Discharged
            icon: mdi:battery-negative
          - entity: sensor.solar_lifetime_production
        show_header_toggle: false
cards: []

You need the following HACS integrations for this dashboard:

  • apexcharts-cards
  • Power Flow Card Plus
  • template-entity-row
  • Tesla style solar power card
  • power-distribution-card

Apexcharts Cards:
In order to see what my solar panels and battery is doing, I created 3 Apexcharts cards. These reflect the SolarEdge Monitoring app. To get it exactly the same I believe you have to stack one or two entities, but I don’t how to do that. I also used the same colours as in the SolarEdge app in a previous version, but the visibility wasn’t great. So therefor the original HA colours

Edit: I discovered how to stack. When I did this I noticed that I didn’t use all the right sensors. I corrected this. Also went back to the colour scheme used in the SolarEdge Monitoring app. Also played some with ‘func: avg’, this one seems to give the best result.

SolarEdge Production:

type: custom:apexcharts-card
graph_span: 24h
update_interval: 5min
cache: false
apex_config:
  chart:
    stacked: true
    stackOnlyBar: false
  legend:
    show: false
  grid:
    show: true
    borderColor: "#666666"
all_series_config:
  stroke_width: 1
  type: area
  group_by:
    func: avg
    duration: 15m
header:
  show: true
  title: SolarEdge Productie
  show_states: true
  colorize_states: true
series:
  - entity: sensor.solar_panel_to_house_w
    color: "#009a40"
    name: Solar > Huis
  - entity: sensor.solar_panel_to_battery_w
    color: "#80ffb5"
    name: Solar > Batterij
  - entity: sensor.solar_panel_to_grid_w
    color: "#00a3b3"
    name: Solar > Net

SolarEdge Usage:

type: custom:apexcharts-card
graph_span: 24h
update_interval: 5min
cache: false
apex_config:
  chart:
    stacked: true
    stackOnlyBar: false
  legend:
    show: false
  grid:
    show: true
    borderColor: "#666666"
all_series_config:
  stroke_width: 1
  type: area
  group_by:
    func: avg
    duration: 15m
header:
  show: true
  title: SolarEdge Verbruik
  show_states: true
  colorize_states: true
series:
  - entity: sensor.solar_panel_to_house_w
    color: "#4774cc"
    name: Solar > Huis
  - entity: sensor.solar_battery_to_house_w
    color: "#a6c3ff"
    name: Batterij > Huis
  - entity: sensor.solar_grid_to_house_w
    color: "#ff8800"
    name: Net > Huis

Battery state:

type: custom:apexcharts-card
graph_span: 24h
apex_config:
  legend:
    show: false
  grid:
    show: true
    borderColor: "#666666"
all_series_config:
  stroke_width: 2
header:
  show: true
  title: Battery
  show_states: true
  colorize_states: true
series:
  - entity: sensor.solaredge_i1_b1_state_of_energy
    show:
      name_in_header: false

These 3 will give you the following cards:



This seems to correspond to the SolarEdge Monitoring app:


Update: I corrected the 2 Apexcharts Production and Usage.

Additionally if you want a Dashboard with all your solar sensors:

type: sections
max_columns: 3
title: Solar Sensors
path: solar-sensors
sections:
  - type: grid
    cards:
      - type: heading
        heading: Panels
        heading_style: title
      - type: history-graph
        entities:
          - entity: sensor.solar_panel_production_w
        logarithmic_scale: false
        hours_to_show: 24
      - type: history-graph
        entities:
          - entity: sensor.solar_panel_to_house_w
        logarithmic_scale: false
        hours_to_show: 24
      - type: history-graph
        entities:
          - entity: sensor.solar_panel_to_battery_w
        logarithmic_scale: false
        hours_to_show: 24
  - type: grid
    cards:
      - type: heading
        heading: Grid
        heading_style: title
      - type: history-graph
        entities:
          - entity: sensor.solar_imported_power_w
        logarithmic_scale: false
        hours_to_show: 24
      - type: history-graph
        entities:
          - entity: sensor.solar_grid_to_battery_w
        logarithmic_scale: false
        hours_to_show: 24
      - type: history-graph
        entities:
          - entity: sensor.solar_exported_power_w
        logarithmic_scale: false
        hours_to_show: 24
    column_span: 1
  - type: grid
    cards:
      - type: heading
        heading: Battery
        heading_style: title
      - type: history-graph
        entities:
          - entity: sensor.solar_battery_to_house_w
        logarithmic_scale: false
        hours_to_show: 24
      - type: history-graph
        entities:
          - entity: sensor.solar_battery_in_w
        logarithmic_scale: false
        hours_to_show: 24
      - type: heading
        heading: House
        heading_style: title
      - type: history-graph
        entities:
          - entity: sensor.solar_house_consumption_w
        logarithmic_scale: false
        hours_to_show: 24

This will give you this dashboard:

Very handy when looking for the right ones! :sweat_smile:

Got some strange behaviour with the Apexcharts Production and Usage. Gave it an update_interval: 5min and a cache: false. This seems to work. Also changed the all_series_config duration to 15m instead of 10m

This is great thank you! I had the same problems as you. Upgraded system, everything fell apart with the API
I will try this tonight! One question though, you say you have two batteries. My modbus shows two separate battery entities, B1 and B2
How do you make this in the yaml?

Mine just showed up as one, I never changed anything. They are linked together, so that makes sense. Do both B1 and B2 give data? Could it be that your installer did something that they appear as separate? The Modbus Multi is just reading what it is fed from the inverter, so my first thought would be a setting thing in your installation.

Yeah I’m not sure. I don’t even know how to ask them that because they aren’t familiar with HA when I asked them about settings
I spoke to solaredge today and they said it needed a firmware update which they did. But my solar production is still offset by several hours.
Your YAML files seemed to work because the naming of your devices are the same as mine with the exception of batteries 1 and 2.
They batteries are producing data that lines up with the values seen in the online SE dashboard so at least I’m reassured that those are accurate
I just cannot for the life of me understand the solar production.

The one thing I did notice was in the official SE integration is an entity called sensor.solaredge_solar_power which seemed to have had almost an identical production graph to the solaredge app. But I cannot get it to be used in the energy dashboard (it doesn’t show up!)

Just FYI this is easily adapted to any different inverter device ID numbers since where you see i1 this is actually a name generated by the inverter ID, not a “count”.

So if you happen to be using an inverter where the ID was set to 2 then you will see i2 in your entities.

I’m still learning HA and code, so I’m very dependant of guys like the great @Remko and @WillCodeForCats to do the heavy lifting. But as far as I can read the code, the ‘solar_panel_production_w’ is taken from the inverter and battery. And somewhere else in the code ‘solar_panel_production_w’ is converted to 'sensor.solar_panel_to_house_kwh". And that one is used for ‘Solar Panel To House Daily’, which you use for your energy dashboard. So if you don’t get an accurate total with ‘solar_panel_production_w’, maybe the som is only from 1 battery? Maybe you can add the extra battery to the code? But that would again be a lot of trying… :sweat_smile:

#PART OF CODE!!
  - sensor:
    - name: "Solar Panel Production W"
      unique_id: solar_panel_production_w
      unit_of_measurement: "W"
      icon: mdi:solar-power
      state: >
        {% set i1_dc_power = states('sensor.solaredge_i1_dc_power') | float(0) %}
        {% set b1_dc_power = states('sensor.solaredge_i1_b1_dc_power') | float(0) %}

Or maybe show us a screenshot of your Modbus device. Then perhaps @WillCodeForCats can help

BTW, yesterday after the code from @WillCodeForCats and my adapted files from @Remko ran for 1,5 day, for the first time I got the same solar production number as in the SolarEdge Monitoring app. So I’m happy!! I’m confident that from now on I can use HA again to get accurate production and usage numbers… :partying_face:

This is great news! Thanks for all your help, I do hope I can figure this out.
After the inverter update yesterday there’s a lot of missing values in modbus so I’m going to wait for it to all run a full 24h starting today and will report back.

I’m still testing this!! I’ll remove this line tomorrow if it works!!

I wanted to try something, I want the 2 Apexcharts “Production” and “Usage” in 1, just like in the Monitoring app. After a lot of reading I think I figured it out:

Place this code in your “electricity.yaml” (I placed it at line 227)

  #Negative Sensors
    - name: "Solar Panel To House W Negative"
      unique_id: solar_panel_to_house_w_negative
      unit_of_measurement: "W"
      icon: mdi:solar-power
      state: >
        {{ states('sensor.solar_panel_to_house_w') | float * -1 }}

    - name: "Solar Battery To House W Negative"
      unique_id: solar_battery_to_house_w_negative
      unit_of_measurement: "W"
      icon: mdi:battery-negative
      state: >
        {{ states('sensor.solar_battery_to_house_w') | float * -1 }}

    - name: "Solar Grid To House W Negative"
      unique_id: solar_grid_to_house_w_negative
      unit_of_measurement: "W"
      icon: mdi:transmission-tower-export
      state: >
        {{ states('sensor.solar_grid_to_house_w') | float * -1 }}

This will take the 3 Watt sensors, create new ones and convert them to negative

Then add a new Apexcharts card, or replace the 2 you already have, with this code:

type: custom:apexcharts-card
graph_span: 24h
update_interval: 5min
cache: false
apex_config:
  chart:
    stacked: true
    stackOnlyBar: false
  legend:
    show: false
  grid:
    show: true
    borderColor: "#666666"
all_series_config:
  stroke_width: 1
  type: area
  group_by:
    func: avg
    duration: 5m
header:
  show: true
  title: SolarEdge Productie en Verbruik
  show_states: true
  colorize_states: true
series:
  - entity: sensor.solar_panel_to_house_w
    color: "#009a40"
    name: Solar > Huis
  - entity: sensor.solar_panel_to_battery_w
    color: "#80ffb5"
    name: Solar > Batterij
  - entity: sensor.solar_panel_to_grid_w
    color: "#00a3b3"
    name: Solar > Net
  - entity: sensor.solar_panel_to_house_w_negative
    color: "#4774cc"
    name: Solar > Huis
  - entity: sensor.solar_battery_to_house_w_negative
    color: "#a6c3ff"
    name: Batterij > Huis
  - entity: sensor.solar_grid_to_house_w_negative
    color: "#ff8800"
    name: Net > Huis

Now you have the same graph as in the SolarEdge Monitoring app!

It works, but I get some ‘ghosting’ effect. The blue under the red arrow shouldn’t be there:

Anyone idea’s? I asked the same question here: ApexCharts card - A highly customizable graph card - #4576 by jrebergen

I had this before, but the cache: false solved it. Now it doesn’t anymore.

It doesn’t seem to work. I think stacking gets confused.

Hi and thanks for this nice writeup! I have modified the same original files as you, and this writeup would have spared a lot of time if this was available for me at time of original setup!

The next thing I was struggling with was to get the controlling of the Battery charge/discharge working. Have used the chepest hours nordpool integration with works OK with some homemade automations, but now trying to migrate to EMHASS. Causing me loads of trouble…

I tried you Apex cards, and they seem to work for me at this point anyway.

Great work!

Great that I could help! I’m not controlling the battery via HA, I use the SolarEdge Monitoring App ‘Time of use’. This works reasonable. SolarEdge has some work to do with the sublemental costs of dynamic tariffs, but with some workarounds it does the trick.

So you mean you can import a dynamic tariff (like nordpool) to the solaredge app and have it dynamically change a “time of use” program? How do you do that?

I do it within the SolarEdge Monitoring app. I’ve read that some people do it from Home Assistant, but I find this to tricky. You can take a look in Remko’s thread Solaredge Modbus Configuration for Single Inverter and Battery, there are more people in that thread that manage their inverter themselves.

It’s tricky to use modbus because the modbus data from the inverters is just raw data: the inverter doesn’t auto-calculate stuff for you. Normally this isn’t a big deal until you try to add batteries, then you have to deal with stuff like negative production numbers and try to account for that as battery charging.

The SolarEdge cloud platform is doing those calculations for you behind the scenes to fill in data points.