Solaredge Modbus Configuration for Single Inverter and Battery

I have posted my previous configuration for the SolarEdge Modbus in the past here:

I got a lot of positive feedback and a lot of nice responses so I decided to post my updated configuration here. Why did I change? Well…the Modbus Integration was not being maintained (it is now) and I got a warning that it might not work in the future, so I started looking for alternatives and with the tip from @s_ash found the ModbusMultiInverter integration from here:

This is a fork from the original integration but better maintained and also works for Multi inverter setups. So I modified my configuration to be based on this integration and cleaned up formulas using tips from @b80k and @Ashpork …Thanks for your inputs!!

NOTE: my configuration uses one inveter and one battery. With some small modficiations, this is simply adjustable to a multi inverter setup or a setup without battery. Some in the other thread already did this, so I suggest to look at that for information.

So…how does it look now? Well this is my Energy Dashboard:

with this configuration:

  - title: Solar
    path: solar
    icon: mdi:lightning-bolt-circle
    visible:
     badges: []
    cards:
      - type: custom:mushroom-chips-card
        chips:
          - type: action
            tap_action:
              action: navigate
              navigation_path: /lovelace/home
            icon: mdi:home
      - type: energy-date-selection
      - type: energy-usage-graph
        title: Energy Usage
      - 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_b1_state_of_energy
      - type: custom:power-distribution-card
        title: ''
        entities:
          - name: Grid
            preset: grid
            icon: mdi:transmission-tower
            entity: sensor.solaredge_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_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: energy-distribution
        title: Energy Distribution
      - 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
      - type: entities
        entities:
          - entity: sensor.solar_accounting_cost_rate
            name: Importrate
          - entity: sensor.solar_accounting_compensation_rate
            name: Exportrate
          - type: custom:template-entity-row
            icon: mdi:plus
            name: Import Costs
            state: >-
              {{ ((states('sensor.solar_imported_power_daily') | float(0)) *
              (states('sensor.solar_accounting_cost_rate') | float(0))) |
              round(2) | replace('.', ',') }} €
          - type: custom:template-entity-row
            icon: mdi:minus
            name: Export Compensation
            state: >-
              {{ -((states('sensor.solar_exported_power_daily') | float(0)) *
              (states('sensor.solar_accounting_compensation_rate') | float(0)))
              | round(2) | replace('.', ',') }} €
          - entity: sensor.solar_accounting_total_daily
            icon: mdi:equal
            name: Electricity Bill
          - type: custom:template-entity-row
            icon: mdi:piggy-bank
            name: Cost Saving
            state: >-
              {{ -(((states('sensor.solar_panel_to_house_daily') | float(0)) +
              (states('sensor.solar_battery_out_daily') | float(0))) *
              (states('sensor.solar_accounting_cost_rate') | float(0))) |
              round(2) | replace('.', ',') }} €
          - entity: sensor.solar_accounting_total_weekly
            icon: mdi:equal
            name: Electricity Bill Weekly
          - entity: sensor.solar_accounting_total_monthly
            icon: mdi:equal
            name: Electricity Bill Monthly
          - entity: sensor.solar_accounting_total_yearly
            icon: mdi:equal
            name: Electricity Bill Yearly
        show_header_toggle: false
      - 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: horizontal-stack
        cards:
          - type: custom:card-templater
            card:
              type: gauge
              entity: sensor.solaredge_b1_state_of_energy
              name: Batterieladung
              min: 0
              max: 100
              needle: true
              severity:
                red: 0
                yellow: 15
                green: 50
            entities:
              - entity: sensor.sensor.solaredge_b1_state_of_energy
                state_template: '{{ states(''sensor.solaredge_b1_state_of_energy'') | round(0) }}'
          - type: custom:card-templater
            card:
              type: gauge
              entity: sensor.solar_accounting_total_daily
              name: Stromrechnung
              needle: true
              min: -10
              max: 10
              severity:
                green: -10
                yellow: 0
                red: 3
            entities:
              - entity: sensor.solar_accounting_total_daily
                state_template: >-
                  {{ '%.2f' |
                  format(states('sensor.solar_accounting_total_daily') | float)
                  }}

Using a few custom elements:

Continued in next post

3 Likes

So my overall configuration to get all the sensors etc, follow these steps:

  • Install the integration mentioned above
  • Create a folder under /config called “packages”
  • In your configuration.yaml add the following:
homeassistant:
  packages: !include_dir_named packages
  • In that folder create a file called “energy.yaml” with the following contents:
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_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)) %}
            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_b1_dc_power') | is_number }}

      - 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_b1_dc_power') | float(0) %}

          {% if (is_state('sensor.solaredge_i1_dc_power', 'unknown') or is_state('sensor.solaredge_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_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_b1_dc_power') | float(0) %}
          {% set m1_ac_power = states('sensor.solaredge_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) %}
              {{ (i1_dc_power) }}
            {% 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_b1_dc_power') | is_number and states('sensor.solaredge_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 b1_dc_power = states('sensor.solaredge_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) %}
              0
            {% else %}
              {{ b1_dc_power }}
            {% endif %} 
          {% else %}
            0
          {% endif %}
        availability: >
          {{ states('sensor.solaredge_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_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_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_m1_ac_power') | float(0) %}

          {% if (m1_ac_power <= 0) %}
            {{ (m1_ac_power * -1) }}
          {% else %}
            0
          {% endif %}
        availability: >
          {{ states('sensor.solaredge_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_b1_dc_power') | float(0) %}

          {% if (i1_ac_power <= 0 and b1_dc_power > 0) %}
            {{ b1_dc_power }}
          {% else %}
            0
          {% endif %}
        availability: >
          {{ states('sensor.solaredge_i1_ac_power') | is_number and states('sensor.solaredge_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_m1_ac_power') | float(0) %}

          {% if (m1_ac_power < 0) %}
            {{ (m1_ac_power * -1) }}
          {% else %}
            0
          {% endif %}
        availability: >
          {{ states('sensor.solaredge_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_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_kwh') | float(0) %}

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

      - name: "Solar Accounting Cost Rate"
        unique_id: solar_accounting_cost_rate
        icon: mdi:cash-plus
        unit_of_measurement: "€/kWh"
        state: >
          0.305

      - name: "Solar Accounting Compensation Rate"
        unique_id: solar_accounting_compensation_rate
        icon: mdi:cash-minus
        unit_of_measurement: "€/kWh"
        state: >
          0.0864

      - name: "Solar Accounting Total Daily"
        unique_id: solar_accounting_total_daily
        icon: mdi:currency-eur
        unit_of_measurement: "€"
        state: >
          {% set cost = (states('sensor.solar_imported_power_daily') | float(0)) * (states('sensor.solar_accounting_cost_rate') | float(0)) %}
          {% set compensation = (states('sensor.solar_exported_power_daily') | float(0)) * (states('sensor.solar_accounting_compensation_rate') | float(0)) %}
          {{ (cost - compensation) | round(2) }}

      - name: "Solar Accounting Total Weekly"
        unique_id: solar_accounting_total_weekly
        icon: mdi:currency-eur
        unit_of_measurement: "€"
        state: >
          {% set cost = (states('sensor.solar_imported_power_weekly') | float(0)) * (states('sensor.solar_accounting_cost_rate') | float(0)) %}
          {% set compensation = (states('sensor.solar_exported_power_weekly') | float(0)) * (states('sensor.solar_accounting_compensation_rate') | float(0)) %}
          {{ (cost - compensation) | round(2) }}

      - name: "Solar Accounting Total Monthly"
        unique_id: solar_accounting_total_monthly
        icon: mdi:currency-eur
        unit_of_measurement: "€"
        state: >
          {% set cost = (states('sensor.solar_imported_power_monthly') | float(0)) * (states('sensor.solar_accounting_cost_rate') | float(0)) %}
          {% set compensation = (states('sensor.solar_exported_power_monthly') | float(0)) * (states('sensor.solar_accounting_compensation_rate') | float(0)) %}
          {{ (cost - compensation) | round(2) }}

      - name: "Solar Accounting Total Yearly"
        unique_id: solar_accounting_total_yearly
        icon: mdi:currency-eur
        unit_of_measurement: "€"
        state: >
          {% set cost = (states('sensor.solar_imported_power_yearly') | float(0)) * (states('sensor.solar_accounting_cost_rate') | float(0)) %}
          {% set compensation = (states('sensor.solar_exported_power_yearly') | float(0)) * (states('sensor.solar_accounting_compensation_rate') | float(0)) %}
          {{ (cost - compensation - 40) | round(2) }}

      - 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: 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
    
recorder:
  include:
    entities:
      - sensor.solaredge_m1_exported_kwh
      - sensor.solaredge_m1_imported_kwh
      - sensor.solaredge_m1_imported_kwh_cost
      - sensor.solaredge_m1_exported_kwh_compensation
      - sensor.solaredge_b1_state_of_energy
      - sensor.solar_inverter_effectiveness
      - sensor.solar_battery_effectiveness
      - sensor.solar_battery_effectiveness_average
      - sensor.solar_inverter_effectiveness_average
      - sensor.solar_accounting_total_yearly
      
      - sensor.solar_panel_production_daily
      - sensor.solar_battery_in_daily
      - sensor.solar_battery_out_daily
      - sensor.solar_house_consumption_daily
      - sensor.solar_imported_power_daily
      - sensor.solar_exported_power_daily
      - sensor.solar_inverter_effectiveness
      - sensor.solar_battery_effectiveness
      - sensor.solar_panel_to_house_daily

      - sensor.solar_battery_in_weekly
      - sensor.solar_battery_out_weekly
      - sensor.solar_panel_to_house_weekly
      - sensor.solar_imported_power_weekly      
      - sensor.solar_exported_power_weekly
      - sensor.solar_house_consumption_weekly
      - sensor.solar_panel_production_weekly
      - sensor.solar_exported_power_weekly
      
      - sensor.solar_battery_in_monthly
      - sensor.solar_battery_out_monthly
      - sensor.solar_panel_to_house_monthly
      - sensor.solar_imported_power_monthly      
      - sensor.solar_exported_power_monthly
      - sensor.solar_house_consumption_monthly
      - sensor.solar_panel_production_monthly
      - sensor.solar_exported_power_monthly

      - sensor.solar_battery_in_yearly
      - sensor.solar_battery_out_yearly
      - sensor.solar_panel_to_house_yearly
      - sensor.solar_imported_power_yearly      
      - sensor.solar_exported_power_yearly
      - sensor.solar_house_consumption_yearly
      - sensor.solar_panel_production_yearly
      - sensor.solar_exported_power_yearly

Please Note!!

      - name: "Solar Accounting Cost Rate"
        unique_id: solar_accounting_cost_rate
        icon: mdi:cash-plus
        unit_of_measurement: "€/kWh"
        state: >
          0.305

      - name: "Solar Accounting Compensation Rate"
        unique_id: solar_accounting_compensation_rate
        icon: mdi:cash-minus
        unit_of_measurement: "€/kWh"
        state: >
          0.0864
		  
      - name: "Solar Accounting Total Yearly"
        unique_id: solar_accounting_total_yearly
        icon: mdi:currency-eur
        unit_of_measurement: "€"
        state: >
          {% set cost = (states('sensor.solar_imported_power_yearly') | float(0)) * (states('sensor.solar_accounting_cost_rate') | float(0)) %}
          {% set compensation = (states('sensor.solar_exported_power_yearly') | float(0)) * (states('sensor.solar_accounting_compensation_rate') | float(0)) %}
          {{ (cost - compensation - 40) | round(2) }}

This bit of my configuration lists my import and export costs for power, so this needs to be modified to your own prices. And int he “Solar Accounting Total Yearly” calculation I have the “-40” in the calculation, this was to get the calculation correct because my power price changed in the middle of the year. So pleas also modify to match your situation.

I will close the old thread, since i am not maintaining that configuration anymore. Any comments, questions or feedback…always welcome, I will do my best to answer it.

2 Likes

Sorry for such a silly question, but what card do you use to enter the code ?

That is the bit which gets created when you create a new page in Lovelace, maybe I better remove that bit.

1 Like

When you are editing a dashboard you can find the raw configuration in the overflow menu.
image

It’s not a card, but the code for the whole dashboard which includes the cards.

1 Like

Thank a lot

Thanks for starting a new thread…

I’m just about to pull the trigger on a Solar install (SolarEdge obviously) and seems that ModBus over TCP is the way to go. At this stage, I’m holding off on the battery, but other threads have talked about clamps etc.

Just to confirm, I can connect in via RJ45 to inverter and I’m all good? There will be two inverters, if they’re set up properly as a leader and a follower, do I just need the leader connected to the network?

Thanks.

Not the biggest expert on installation but…
Yes, I would make sure your main inverter has the wired ethernet connection to your network and guess that is enough. I am assuming that the second inverter will share it’s data with the master through RJ45 (modbus) and your master is the one you query over modbus.
When it comes to clamps etc… In my installation I have a SolarEdge meter installed in my breaker box, directly after the 3 phases enter the house. It has 3 clamps for the 3 phases and is also connected through RJ45 (modbus) with my inverter. This meter is required to get data about self consumption, import and export.

I dunno man. I have ethernet running to my router directly and modbus over TCP is working but I don’t get any data over M1, M2, or M3 channels for a reason that no one can take a guess at why or what is missing, so be careful and don’t expect this is a guarantee.

Thanks very much - looks like I’ll need to get one of these added to my install then…

@Remko: Just saw that the old thread was closed. I read the initial post in this new thread. But I am not sure, if I understood all your points correctly. Maybe you can quickly clarify the following questions:

  • Is there any difference between old and new setup apart from “WillCodeForCats” instead of “binsentsu” and some non-functional formula refactoring?
  • Why are you saying “binsentsu” was/is not maintained (anymore)? Is there any problem with this integration that I missed?
  • I am currently running your old setup with Ashporks “fix” and some own extensions on top. Do you see any benefit in moving to your new setup for my single-inverter-with-single-battery-setup?

Thanks for your answers. In any case I am happy that you are still driving and improving this topic.

@stephanschuster

  • no, there are no further differences. This integration offers support for multiple inverters (which I do not need) and I like the naming and structuring of the entities better. So overall…in my setup, just cosmetic changes. I did the formula refactoring based on some of the recommendations in the other thread and learned some new things about yaml, that is why I updated…
  • Well…binsentsu did not bring out any updates anymore. A couple of releases ago, there was a significant change in Homeassistant which would have caused it to stop working. I forked the integration and made the necessary change, which he then incorporated. WillCodeForCats is actively developing his integration, plus the cosmetic differences made me change
  • So overall…I do not see a benefit in your setup. Our setups are the same and besides the cosmetics…no benefit at all.

And yes…I keep fiddling with HomeAssistant and since I like this setup, I always keep looking at improvements.

1 Like

A few of us have issues getting any of the M1/M2/M3 sensor data. We get all the “main” data, but need the M1 data to make use of these dashboards. I have installed/uninstalled several times but no joy. Any ideas?

I don’t understand why they wouldn’t show. It is an issue of the integration though, have you opened an issue there?

Maybe a stupid question, but… What kind off setup do you have, I mean, do you actually habe an import/export meter installed? My parents have a setup without such a meter (which only issue required off you have a battery if I understand it correctly) and therefore do not get these entities of course.

  • no, there are no further differences. This integration offers support for multiple inverters (which I do not need) and I like the naming and structuring of the entities better. So overall…in my setup, just cosmetic changes. I did the formula refactoring based on some of the recommendations in the other thread and learned some new things about yaml, that is why I updated…
  • Well…binsentsu did not bring out any updates anymore. A couple of releases ago, there was a significant change in Homeassistant which would have caused it to stop working. I forked the integration and made the necessary change, which he then incorporated. WillCodeForCats is actively developing his integration, plus the cosmetic differences made me change
  • So overall…I do not see a benefit in your setup. Our setups are the same and besides the cosmetics…no benefit at all.

Thanks so much for clarification. Maybe you can give an explicit hint to all users of the old setup if you’re adding/fixing stuff which makes switching to the new setup worth it.

See the instructions for filing a bug report issue on how to enable debug logging which will show low level info when the integration asks the inverter if it has any meters configured. Specifically, there are debug log lines that say “Inverter X meter Y” and some hex numbers like this:

A valid meter (as configured in the inverter through the front panel or SetApp) should respond with C_SunSpec_DID 0x1 and C_SunSpec_Length 0x41. If it doesn’t (in the example there is no meter 3 so Inverter 1 Meter 3 is 0x0 instead) or responds with other values then it’s not a valid meter according to the specs and you would need to open a support request with your installer or SolarEdge support asking why the meter doesn’t identify itself as a meter according to the published specs.

I am the author of solaredge-modbus-multi so here’s my backstory about why my integration exists.

I started out looking for a way to get local data from my setup of two inverters and one meter. I searched a lot and it turns out very few (basically nobody) cared about setups that had more than one device, until I found someone had made a fork of an integration that did support two inverters. So I ended up using that fork of what I’ll call it the “other” integration. At the time my knowledge of development for HA and Python was nonexistent, although I have plenty of experience with C/C++, Perl, PHP, and other languages. Just never Python.

I started using the other integration and tested the PR, but it quickly became apparent that the author had no intention of actually merging the PR for multiple inverter support, but did merge requests for other stuff. I don’t know why, but it was critical to me so I started a fork that included the PR I needed and tried to backport upstream changes into my fork, but that also eventually ran into my Python knowledge limits at the time.

In the meantime I decided to try to learn how to write a complete integration from scratch for a Tekmar home automation gateway integration since literally none existed: my tekmar-482 integration and tekmar-packetserv add-on. I learned a hell of a lot about HA development and Python after tackling that task, then I took all of that knowledge and applied it to a ground-up rewrite for my solaredge-modbus-multi integration. I’ve tried to adhere to HA developer guidelines and practices, keep up on HA changes, and make sure the integration works as well as I want it to work since I’m actually using it for myself. That means I want my work to be robust and error free as possible.

The only thing my integration lacks over the other one is that solaredge-modbus-multi doesn’t have power control command support. This is because I don’t personally have any batteries, but I am slowly working through that using a modbus simulator to pretend to be a battery using data based on other user’s debug logs (since I don’t have a real battery to develop with). So it will eventually have that feature too, but obviously without real hardware on my end and most people still wanting to stick with the other integration means less demand for that feature and fewer testers for me. The beginning of that work is in PR #117 and the power-control branch.

I’m biased but I think my integration is better maintained, more robust, and higher quality. I just took a glance at all the open issues and complaints in the other integration’s “issues”, and my impression is that I think that my solaredge-modbus-multi integration fixes or addresses almost every compliant, problem, or defect present in the other one. I take pride in trying to quickly address issues that are brought up, especially if it’s a bug I missed, because I do not want to ship low quality or incomplete releases. Since I do use my own integration I see things over time that can be done better.

That’s the basic story behind why solaredge-modbus-multi exists. Even if nobody used it I would still be working on it because I use it for my system, but I’ve added a lot of features for stuff I don’t have since other people do use it instead other options. For example, I recently added SolarEdge Synergy support which is something I was aware of but didn’t originally spend time on since Synergy inverters are large three phase commercial systems up to 120kW, not something I thought HA would be connected to, but someone did so I added support for it.

Of course, if you are happy with the state of the other integration then by all means keep using it.

@Glendale, thanks for this detailed explanation. I am a software developer myself, so I fully understand your points and can totally value your work and motivation. Much appreciated. In the near future I will definitely switch to your integration. The only thing which hindered my so far was the fact that the old one is working stable and a switch would cost me quite a bit of time since I extended @Remko old setup quite a bit for my own purpose. Anyways, by the end of the year I will have switched. Keep up your work. Thanks.

Quick question: I did not understand “power control command support”. What is this for? When would I need it? I have a battery. But as far as I understood, this is supported by your integration even tough you don’t have a battery yourselves.

@Remko and @Glendale thanks for the info. I am not sure how to enable the detailed logging you are showing but that looks like my next step, then I can file a bug if the DID shows 0. Are there instructions for enabling detailed debugging?

If the DID and Length are not 0x1 and 0x41 respectively, then it’s not a bug, the inverter is saying it doesn’t have a meter configured. Those are a header that say “yes there is a meter in this config slot” if set to those values.

If you click on the bug report template under issues that template has instructions for logging configuration for your configuration.yaml file.

Edit: I should say it’s not my bug to fix. If you actually have a physical meter (assuming it was commissioned properly) and the inverter is still saying no meter then that’s a question for SolarEdge support or your installer.