I think I misread your question. If you have a battery attached to your SolarEdge inverter (maybe only SolarEdge batteries), then you have a battery tab in your SolarEdge Monitoring app. There you can set the battery to different behaviours.
Yes. I know I can set the batteriebehavior to “time of use” or “maximise self consumption” aso. In the app. What I thought you had managed to do was to adjust this behaviour based on the changing dynamic Tariffs from Nordpool. Or maybe this functionality has been added in the app? When I got the system now >1 year ago that was not possible. So I spent a lot of time to set up an automation to “charge on cheapest hours” and “discharge on most expensive hours”, using the modbus integration. Now trying to set up EMHASS to add some more intelligence into that behavior.
I can set different options in the SolarEdge app. With ‘Time of use’ I can use dynamic tariffs. You don’t have this?
I see that to, when now opening the app! That was new to me
How is the optimization working you think? Does it export when high prices and import on low for batter?
Yes, if you set the correct costs and your location for you. You can enter additional costs if that implies for you. Then check the ‘Preview’ if the numbers are correct.
The system will account for the weather and your usage and behave accordingly. It’s an AI of some sort, so give it some time to learn (like 1 month or 2)
Ah! Very interesting. Thankyou! Have started to set up EMHASS, and will give it a good go. Otherwise this seems like an easier way ![]()
Hi, can someone explain to me how to get the power panel to work with the SolarEdge battery? The measurements are off, and I’m definitely using the wrong sensor. However, as for the batteries, they’re the only two I can configure. What’s wrong?
i use:
Battery Energy Export
Battery Energy Import
In the top of this message I explain which sensors I use: SolarEdge Modbus Multi config for Single Inverter, Battery and Backup Module/Meter - #2 by jrebergen
Nice one. I have a similar setup and still tweak here and there, in particular to get SolCast (solar production estimation) working with Auto dampening.
What I can recommend for further use is to add unique_id to each created sensor to get it in the registry - in addition you can then add / edit the sensor via UI.
Hi,
I am a newby, and am very impressed by your work. I like it very much. Copied all your code (followed your instructions above).
BUT the output apex chart keeps displaying … loading …
What am I doing wrong?
That’s hard to tell what is going wrong. N/A means not available I think? Follow the sensor: sensor.solar_panel_to_house_w. This is the Solar > Huis sensor. Is it named the same in your configuration? If not, then probably the other ones are also named different. Do al the sensors work if you recreate this dashboard: SolarEdge Modbus Multi config for Single Inverter, Battery and Backup Module/Meter - #4 by jrebergen
Hi,
Thank you. You gave me a hint: the sensors were not in my configuration.yaml under recorder. I put them in and … it works like a charm. Thank you so much.
Another question: the code in this feed of jul 28, 11 h (starting with this:
type: sections
max_columns: 3
title: Solar
path: solar
sections:
etc.
Does not work when I copy and past it. Any suggestion for that?
Thanks in advance
And this is how we slowly become experts, seek and learn!
Great job finding the issue.
About the code, that’s the code of a tab in Home Assistant. Click on the ‘pencel’ to edit your dashboard. Then with the + create a new tab. Click on the 3 vertical dots in the upper right corner and choose ‘Edit in YAML’. Here you can paste that code. And just like that you’ve created a new tab.
Hey Guys,
I’m trying to get it running since months now
and just found this thread. May I ask you to place me the entire code for the configuration.yaml here? I have tried too use the code from the first page here, but my energy dashboard still looks weird, please see my screenshots:
and
I hope I can finally get it running with your help now ![]()
Many thanks
If you want this thread to work, you must follow the steps as described. I see all the code in de configuration.yaml file. This could work, but then I or anybody else can’t help you. I created this thread with 2 things in mind: a solution for my specific sensor naming based on using ‘SolarEdge Modbus Multi’ and ease of use if you follow the steps. In step 3 and 4 of the first post (SolarEdge Modbus Multi config for Single Inverter, Battery and Backup Module/Meter) you see that you have to create 3 files in a folder called ‘solaredge’. So maybe try again, but follow the steps exactly. It should work then. ![]()
Hello and thank you so much for this guide and your work. I have exactly this problem and am delighted to have found this solution, as I’ve already spent days trying to get usable data from my SolarEdge system into HA.
Unfortunately, I’m a complete beginner and am having trouble modifying the code to integrate two inverters and two batteries.
My Modbus configuration in HA looks like this:
Making the changes for one (the top) inverter (with the M1 meter) is no problem at all.
The question is: Should I create helpers for each sensor (and then sum the data) and then integrate these helpers into the YAML files? Or can I integrate both inverters directly into the YAML files?
Perhaps someone can help me?
I’d be happy to donate ![]()
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 i2_dc_power = states('sensor.solaredge_i2_dc_power') | float(0) %}
{% set b2_dc_power = states('sensor.solaredge_i2_b1_dc_power') | float(0) %}
{% if (is_state('sensor.solaredge_i2_dc_power', 'unknown') or is_state('sensor.solaredge_i2_b1_dc_power', 'unknown')) %}
0
{% elif (i2_dc_power + b1_dc_power <= 0) %}
0
{% else %}
{{ (i2_dc_power + b1_dc_power) }}
{% endif %}
availability: >
{{ states('sensor.solaredge_i2_dc_power') | is_number and states('sensor.solaredge_i2_ac_power') | is_number and states('sensor.solaredge_i2_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 i2_dc_power = states('sensor.solaredge_i2_dc_power') | float(0) %}
{% set i2_ac_power = states('sensor.solaredge_i2_ac_power') | float(0) %}
{% set b1_dc_power = states('sensor.solaredge_i2_b1_dc_power') | float(0) %}
{% set m1_ac_power = states('sensor.solaredge_i2_m1_ac_power') | float(0) %}
{% set inverter_effectiveness = states('sensor.solar_inverter_effectiveness') | float(0) %}
{% if (b2_dc_power >= 0 and m1_ac_power > 0) %}
{% if (i2_dc_power < 0 and i1_ac_power <= 0) %}
{{ (i2_dc_power - m1_ac_power) }}
{% else %}
{{ (i2_ac_power - m1_ac_power) }}
{% endif %}
{% elif (b1_dc_power >= 0 and m1_ac_power <= 0) %}
{% if (i2_dc_power < 0 and i2_ac_power <= 0) %}
0{#{{ (i2_dc_power) }}#}{# Added 0 #}
{% else %}
{{ (i2_ac_power) }}
{% endif %}
{% elif (b1_dc_power < 0) %}
{% if (i2_dc_power + b1_dc_power < 0) %}
0
{% else %}
{{ ((i2_dc_power + b1_dc_power) * inverter_effectiveness) }}
{% endif %}
{% else %}
0
{% endif %}
availability: >
{{ states('sensor.solaredge_i2_dc_power') | is_number and states('sensor.solaredge_i2_ac_power') | is_number and states('sensor.solaredge_i2_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 i2_dc_power = states('sensor.solaredge_i2_dc_power') | float(0) %}
{% set i2_ac_power = states('sensor.solaredge_i2_ac_power') | float(0) %}
{% set b1_dc_power = states('sensor.solaredge_i2_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 (i2_dc_power < 0 and i1_ac_power <= 0) %}
{{ (b1_dc_power+i2_dc_power) }}
{% else %}
0
{% endif %}
{% else %}
{{ b1_dc_power }}
{% endif %}
{% else %}
0
{% endif %}
availability: >
{{ states('sensor.solaredge_i2_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_i2_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_i2_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_i2_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_i2_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 i2_ac_power = states('sensor.solaredge_i2_ac_power') | float(0) %}
{% set b1_dc_power = states('sensor.solaredge_i2_b1_dc_power') | float(0) %}
{% set i2_dc_power = states('sensor.solaredge_i2_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_i2_ac_power') | is_number and states('sensor.solaredge_i2_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_i2_m1_ac_power') | float(0) %}
{% if (m1_ac_power < 0) %}
{{ (m1_ac_power * -1) }}
{% else %}
0
{% endif %}
availability: >
{{ states('sensor.solaredge_i2_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_i2_m1_ac_power') | float(0) %}
{% if (m1_ac_power > 0) %}
{{ (m1_ac_power) }}
{% else %}
0
{% endif %}
availability: >
{{ states('sensor.solaredge_i2_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_i2_ac_energy') | float(0) %}
{{ ((ac_energy_kwh / 1000) | round (2)) }}
availability: >
{{ states('sensor.solaredge_i2_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_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_i2_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_i2_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_i2_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
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_i2_dc_power') | float(0) %}
{% set i1_ac_power = states('sensor.solaredge_i2_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_i2_dc_power') | float(0) %}
{% set b1_dc_power = states('sensor.solaredge_i2_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_i2_dc_power') | is_number and states('sensor.solaredge_i2_ac_power') | is_number and states('sensor.solaredge_i2_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
Thank you very much!
Ouch, you’ve got a tricky one! I think this one goes above my head too. What I did initially was convert everything in the original files to the names I had. You have to do this again because you have I2 and B2 entities. But you also have a W2 device?
Converting everything in my files to your I2, I2 B1 and I2 M1 is doable. And looking at your screenshot, I2 is the same as w2 I3. And I2 B1 is the same as w2 I3 B1. But why these names are so different?
Could you ask the author of SolarEdge Modbus Multi if he has seen this before?
It would have made sense to me if you had a I1 with the B1 and M1 and then separate a I2 with a B1 or B2. But the W I don’t understand…
I have 2 inverters and one battery. You can see my full config here in my public GitHub repo:
Hope it helps point you in the right direction.
I was reading your question again and your question was if you should combine the 2 devices via helpers or in the yaml.
I think this is easier in a helper first. Then you can take the entities you want (you don’t need all for daily view) and make calculations. If these are correct, maybe you can make them definite in yaml?
Thanks for your answer and help!
And P6Dave: Thanks for your files.
I’m currently trying to adapt these settings so I can get it working, but unfortunately, I’m not making much progress. It’s a bit too complex for me—especially since your files are then located in different directories, and the other configuration doesn’t match the one in this thread.
Let me briefly explain the devices I’ve created for my Modbus integration:
I2: This is my primary inverter.
I2 B1: This is the primary inverter’s battery.
I2 M1: This is the main meter—it runs through the primary inverter.
W2 I3: This is my second, secondary inverter.
W2 I3 B1: This is the secondary inverter’s battery.
So, actually, it’s quite simple. ![]()
But overall, it’s probably too complex for me to adapt the files accordingly.
I’ve now adapted Dave’s files and placed them in a folder called “packages,” and I’ve added that folder to my config file.
Unfortunately, I’m still missing the second battery from my secondary inverter. I haven’t been able to add it yet.
Here are my files – perhaps someone can help me?
electrical_power
##################################################################################
# @author : Remko Van Der Veer #
# @date : 11/4/2020 #
# @package : energy.yaml #
# @description : All energy config for dashboard #
# #
# @modified by : Ryan McLean #
# @date : 05/12/2022 #
# #
# @further modified by : Dave Forrester (@Daverover66) #
# @date : 25/05/2025 #
# @description : Added dynamic battery charge rate sensor #
##################################################################################
###########################
# sensors #
###########################
template:
- sensor:
- name: "Inverter 1 Production"
unique_id: inverter_1_production
icon: mdi:solar-power
unit_of_measurement: "W"
state_class: "measurement"
device_class: "power"
state: >
{% set inverter_1_dc_output = states('sensor.solaredge_i2_dc_power') | float (0) %}
{% set battery_output = states('sensor.solaredge_i2_b1_dc_power') | float (0) %}
{% set inverter_1_production_discharging = battery_output + inverter_1_dc_output %}
{% set inverter_1_production_charging = inverter_1_dc_output + battery_output %}
{% if (battery_output >=0) %}
{{ inverter_1_production_charging }}
{% else %}
{{ inverter_1_production_discharging }}
{% endif %}
availability: >
{{ states('sensor.solaredge_i2_dc_power') | is_number and states('sensor.solaredge_b2_dc_power') | is_number }}
- name: "Total DC Power"
unique_id: total_dc_power
icon: mdi:solar-power
unit_of_measurement: "W"
state_class: "measurement"
device_class: "power"
state: >
{% set total_dc_power = (states('sensor.solaredge_i2_dc_power')|float(0) + states('sensor.solaredge_w2_i3_dc_power')|float(0)) %}
{{ total_dc_power }}
availability: >
{{ states('sensor.solaredge_i2_dc_power') | is_number and states('sensor.solaredge_w2_i3_dc_power') | is_number }}
- name: "Total AC Power"
unique_id: total_ac_power
icon: mdi:solar-power
unit_of_measurement: "W"
state_class: "measurement"
device_class: "power"
state: >
{% set total_ac_power = (states('sensor.solaredge_i2_ac_power')|float(0) + states('sensor.solaredge_w2_i3_ac_power')|float(0)) %}
{{ total_ac_power }}
availability: >
{{ states('sensor.solaredge_i2_ac_power') | is_number and states('sensor.solaredge_w2_i3_ac_power') | is_number }}
##########################################################
# energy flow from Modbus config documentation
##########################################################
- name: "Power - Battery Charging"
unique_id: power_battery_charging
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
state: "{{ max([float(states('sensor.solaredge_i2_b1_dc_power'), 0), 0]) | abs() }}"
- name: "Power - Battery Discharging"
unique_id: power_battery_discharging
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
state: "{{ min([float(states('sensor.solaredge_i2_b1_dc_power'), 0), 0]) | abs() }}"
- name: "Power - Grid Import"
unique_id: power_grid_import
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
state: "{{ min([float(states('sensor.solaredge_i2_m1_ac_power'), 0), 0]) | abs() }}"
- name: "Power - Grid Export"
unique_id: power_grid_export
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
state: "{{ max([float(states('sensor.solaredge_i2_m1_ac_power'), 0), 0]) | abs() }}"
- name: "Power - Solar Generation"
unique_id: power_solar_generation
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
# The net of DC power from inverters and battery, only if this is positive
state: "{{ max([float(states('sensor.solaredge_i2_dc_power'), 0) + float(states('sensor.solaredge_w2_i3_dc_power'), 0) + float(states('sensor.solaredge_i2_b1_dc_power'), 0), 0]) }}"
- name: "Power - Consumption"
unique_id: power_consumption
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
# The net of inverters and grid power
state: "{{ (float(states('sensor.solaredge_i2_ac_power'), 0) + float(states('sensor.solaredge_w2_i3_ac_power'), 0)) - float(states('sensor.solaredge_i2_m1_ac_power'), 0) }}"
- name: "Power - PV - Battery"
unique_id: power_pv_battery
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
# Battery power less anything coming from the grid, always positive
state: "{{ max([float(states('sensor.solaredge_i2_b1_dc_power'), 0) + min([float(states('sensor.solaredge_i2_dc_power'), 0) + float(states('sensor.solaredge_w2_i3_dc_power'), 0), 0]), 0]) }}"
- name: "Power - PV - Load"
unique_id: power_pv_load
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
# What is being generated less what is going to the battery and what is being exported, always positive.
state: "{{ max([float(states('sensor.power_solar_generation'), 0) - float(states('sensor.power_pv_battery'), 0) - float(states('sensor.power_grid_export'), 0), 0]) }}"
- name: "Power - PV - Grid"
unique_id: power_pv_grid
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
# What is being generated less what is going to the battery and what is being consumed, always positive
state: "{{ max([float(states('sensor.power_solar_generation'), 0) - float(states('sensor.power_pv_battery'), 0) - float(states('sensor.power_consumption'), 0), 0]) }}"
- name: "Power - Grid - Load"
unique_id: power_grid_load
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
# What is being imported less anything going to the battery, always positive
state: "{{ max([float(states('sensor.power_grid_import'), 0) + min([float(states('sensor.solaredge_i2_ac_power'), 0), 0]), 0]) }}"
- name: "Power - Grid - Battery"
unique_id: power_grid_battery
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
# Grid -> Battery is I1 AC + I2 AC power, when negative
# Battery -> Grid is what is being exported, if the battery is discharging
state: "{{ max([-(float(states('sensor.solaredge_i2_ac_power'), 0) + float(states('sensor.solaredge_w2_i3_ac_power'), 0)), 0]) - (float(states('sensor.power_grid_export'), 0) if float(states('sensor.solaredge_i2_b1_dc_power'), 0) < 0 else 0) }}"
- name: "Power - Battery - Load"
unique_id: power_battery_load
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
# What is being discharged minus what is being exported, if positive
state: "{{ max([float(states('sensor.power_battery_discharging'), 0) - float(states('sensor.power_grid_export'), 0), 0]) }}"
##################################################################
# Dynamic battery charge rate with sun elevation
##################################################################
- name: "Battery Charge Limit Dynamic"
unique_id: battery_charge_dynamic_limit
unit_of_measurement: 'W'
state: >
{% set sun_elevation = state_attr('sun.sun', 'elevation') | float(0) %}
{% set min_elev = 10 %}
{% set max_elev = 50 %}
{% set max_power = 2160 %}
{% if sun_elevation < min_elev %}
0
{% elif sun_elevation > max_elev %}
{{ max_power }}
{% else %}
{{ ((sun_elevation - min_elev) / (max_elev - min_elev) * max_power) | round(0) }}
{% endif %}
- name: "Solar Elevation Match Percentage"
unique_id: solar_elevation_match_percentage
unit_of_measurement: '%'
state: >
{% set sun_elevation = state_attr('sun.sun', 'elevation') | float(0) %}
{% set min_elev = 10 %}
{% set max_elev = 50 %}
{% if sun_elevation < min_elev %}
0
{% elif sun_elevation > max_elev %}
100
{% else %}
{{ ((sun_elevation - min_elev) / (max_elev - min_elev) * 100) | round(0) }}
{% endif %}





