Skip to content

Instantly share code, notes, and snippets.

@Ashpork
Last active February 3, 2024 19:40
Show Gist options
  • Save Ashpork/f80fb0d3cb22356a12ed24734065061c to your computer and use it in GitHub Desktop.
Save Ashpork/f80fb0d3cb22356a12ed24734065061c to your computer and use it in GitHub Desktop.
A snippet of the basic additional sensors configuration needed to track Panel production, on a SolarEdge single inverter, single battery system, along with the configuration used on the Power Flow Plus card.
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_b1_dc_power') | float(0) %}
{% if (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_b1_dc_power') | is_number }}
- name: "Solar House Consumption W"
unique_id: solar_house_consumption_w
unit_of_measurement: "W"
icon: mdi:home
state: >
{% set i1_ac_power = states('sensor.solaredge_i1_ac_power') | float(0) %}
{% set m1_ac_power = states('sensor.solaredge_m1_ac_power') | float(0) %}
{% if (i1_ac_power - m1_ac_power <= 0) %}
0
{% else %}
{{ (i1_ac_power - m1_ac_power) }}
{% endif %}
availability: >
{{ states('sensor.solaredge_i1_ac_power') | is_number and states('sensor.solaredge_m1_ac_power') | is_number }}
- name: Solar Inverter Consumption w
unique_id: solar_inverter_consumption_w
unit_of_measurement: "W"
icon: mdi:mdi:home-lightning-bolt-outline
state: >
{% set i1_ac_power = states('sensor.solaredge_i1_ac_power') | float(0) %}
{% set i1_dc_power = states('sensor.solaredge_i1_dc_power') | float(0) %}
{% if (i1_ac_power > i1_dc_power < 0) %}
{{ (i1_ac_power - i1_dc_power)| round(2) }}
{% else %}
{{ ( i1_dc_power - i1_ac_power)| round(2)}}
{% endif %}
availability: >
{{ states('sensor.solaredge_i1_ac_power') | is_number and states('sensor.solaredge_i1_dc_power') | is_number }}
- 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_m1_ac_power') | is_number }}
sensor:
- platform: integration
source: sensor.solar_panel_production_w
method: left
unit_prefix: k
name: solar_panel_production_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
utility_meter:
solar_panel_production_daily:
source: sensor.solar_panel_production_kwh
name: Solar Panel Production 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_exported_power_daily:
source: sensor.solar_exported_power_kwh
name: Solar Exported Power Daily
cycle: daily
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_exported_power_weekly:
source: sensor.solar_exported_power_kwh
name: Solar Exported Power Weekly
cycle: weekly
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_exported_power_monthly:
source: sensor.solar_exported_power_kwh
name: Solar Exported Power Monthly
cycle: monthly
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_exported_power_yearly:
source: sensor.solar_exported_power_kwh
name: Solar Exported Power Yearly
cycle: yearly
type: custom:power-flow-card-plus
title: Power Flow
entities:
home:
entity: sensor.solar_house_consumption_w
color_icon: solar
color_value: true
fossil_fuel_percentage:
entity: sensor.grid_fossil_fuel_percentage
icon: mdi:pine-tree
color_icon: true
display_zero: false
name: Green Import
state_type: power
color_value: true
grid:
name: Grid
entity: sensor.solaredge_m1_ac_power
display_state: one_way
color_circle: true
invert_state: true
solar:
icon: mdi:solar-panel-large
entity: sensor.solar_panel_production_w
color_value: true
color_icon: true
battery:
name: Battery
entity: sensor.solaredge_b1_dc_power
display_state: one_way
color_icon: true
color_circle: true
invert_state: true
state_of_charge: sensor.solaredge_b1_state_of_energy
color_state_of_charge_value: true
clickable_entities: true
display_zero_lines:
mode: hide
transparency: 50
grey_color:
- 189
- 189
- 189
use_new_flow_rate_model: true
w_decimals: 0
kw_decimals: 1
min_flow_rate: 0.75
max_flow_rate: 6
max_expected_power: 6000
min_expected_power: 0.01
watt_threshold: 750
dashboard_link: /energy
dashboard_link_label: Energy Summary
@nickt444
Copy link

Thanks for sharing the details of this solution.
How often do you have the integration polling, and what is the size of your database?
I am currently using the SolarEdge cloud integration (which polls every 15 mins) for energy, and the Modbus_multi integration (polling every 30 sec) for power.
I am debating ditching the cloud integration and switching to Modbus_multi (polling every 3-5 sec) for energy as well as power. Even with liberal use of recorder excludes, I can see the db growing substantially, and I am wondering what I actually gain from this other than just decoupling from the cloud API and more frequent updates. (15 min update intervals from the cloud API is not ideal, but quite acceptable).
Keen to hear your thoughts on this.

@Ashpork
Copy link
Author

Ashpork commented Nov 13, 2023

How often do you have the integration polling....
Modbus_multi (polling every 3-5 sec)

I prefer a near real time view as to what's going on, like when you use the SE app so I'm polling every 8 seconds. Depending on how many devices you have connected to your SE inverter the response time from it varies. In my environment I found it typically responds within 2-4 seconds so lifting it to 8 seconds to add some buffer.

For me, I'm polling more frequently as our house only uses elec, apart from the gas boiler, so the increased frequency of polling lets me spot a load above what the inverter can supply and then delay that consumption to reduce import. For example washing machine, kettle, dishwasher, cooker etc. can often pause 1-2 minutes ready for it's turn. Some of that delay is manual, some is automatic. The API sync to SE at 15minutes just didn't let me achieve that.

I am debating ditching the cloud integration and switching to Modbus_multi (polling every 3-5 sec) for energy as well as power.
I can see the db growing substantially

I used to keep 60 days of data with some filtering filtered and my DB was about 5-6GB (I know!). I have 30 zigbee devices so they were also polluting it a little by storing all the devices related entity data in attributes ("Home Assistant legacy entity attributes" in Z2MQTT), so I've been able to turn that off now which will also help.

I've recently gone down to storing just 14 days and make more use of HA statistics data. Currently DB is about 1.5GB. I'm using MariaDB.

Today doing my ROI calculations, I actually still go back to the data captured using the SolarEdge app/website and export CSVs to look at generation/import/export, and then use HA identify our house load.

@nickt444
Copy link

I've settled on using the SolarEdge cloud integration for energy, as i can handle the 15 min delay (for billing and historical use) and they can do the heavy lifting of sampling and calculating energy flows.
I am using the Modbus integration for power, sampling at 5 sec, and use recorder exclusions to prevent storing these. Like you, I am using this in automations to decide when to turn things on (hot water and ventilation fans) and to increase/decrease charging rate to my EV based on current solar output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment