Hi Remko,
Great stuff as usual! I’ve moved over to this implementation a couple weeks back, and looking good so far.
With my Battery set up, I’m getting increased situations where my house consumption figures aren’t matching what’s being either pushed from solar, supplied by the battery or imported from the grid. Narrowing it down, it appears to be related to the battery calculation in the house consumption sensor, as a result of a bad (zero) value of the Battery Effectiveness. Sometimes get a Battery effectiveness value of “unavailable”, which then means my “battery to house w” output is zero (thanks to a multiply by zero).
The symptons are that when compared against the solarEdge monitoring website, the house consumption is just too low…
I must admit, I’m a little light on knowledge about the battery and inverter effectiveness but can I suggest a change to the battery effectiveness template set up to help handle sensors that aren’t quite ready.
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 }}
Should perhaps read
- 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) 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 %}
With this, we at least get a 1 for our battery effectiveness initially instead of “unavailable”, and onwards from there, if I’ve understood the logic of self referencing previous values, it should work.
As a note, I’ve also modified the wider configuration a little more to accept time of day tariff values, as with my battery and autumn/winter looming, I’m charging the battery during off peak time from my energy provider (managed to talk my way into an EV car tariff without an EV car), and wanted a way in HA to monitor what my spend “would have been” without PV and a battery (based purely on house consumption), vs. what my spend is now (imported elec only, topping up the solar/battery combination). I’ve done this to help me track savings as a result of buying PV & Battery earlier this year.
I’ve also had to do this as the solarEdge monitoring doesn’t present the right information after a charge, I read in the preivous post something about SolarEdge not knowing where the power came from, so go minimal on the information about what solar was generated for that day; they will show zero, until your house consumes as much electric as you charged the battery.
If anyone is interested in the setup/configuration, I’d be happy to spend a bit of time one evening pulling together the automation/config to help inspire someone else.