Integration with energy dashboard #16
-
Did someone try to to integrate the solix into the HA energy dashboard. For now it looks like I am missing the correct device types. |
Beta Was this translation helpful? Give feedback.
Replies: 16 comments 37 replies
-
I did, but I needed to create some sensor's by myself. |
Beta Was this translation helpful? Give feedback.
-
In general you need Energie sensors for the energy dashboard. With batteries you need separate energy for charging and discharging to display that correctly. |
Beta Was this translation helpful? Give feedback.
-
If you have power flow cards in the dashboard, they can typically configured whether using single sensor or separate for the battery power flow. The integration entity should directly be usable for the flow chart. |
Beta Was this translation helpful? Give feedback.
-
produced Energy Battery: This is a work in progress / test setup, but perhaps it will help. You need to create 4 input helper. Automation 1 Measure how much the battery changed.
and then separate for charging and discharging
Discharge:
Template SensorsBased on Thomas tipp, i converted now the charge and discharge numbers into a template sensor.
|
Beta Was this translation helpful? Give feedback.
-
Following is a subset of my templates to use the battery in power flow charts and energy dashboard. Sensor for Solar power in Power FlowchartI had to build this to calculate the Solar power properly independent of an installed solarbank. You have to consider this too, since you may want to uninstall it over winter. When uninstalled, the invert input is your Solarpower, when installed you need to use the solar power entity of the integration, or calculate solar power from DC inverter input and charge power as I did before having the integration solar entity.
Sensor for represent BKW export power without inverter standby power consumption over night
Utility meter for total Solar Energy in Energy dashboard, accumulate export energy to house and battery charge energy if availableNote: This was required before getting the direct solar power from the Anker integration. Now you could create a direct Rieman integral sensor from the solar power sensor. However, you should consider phases where this value is not available, or where you uninstalled the solarbank in winter maybe. Then you need to ensure that the source power template sensor of the kWh integral sensor considers various source sensors that reflect the actual solar power for both cases.
Battery energyFor the battery energy in the dashboard you need separate total increasing sensors for charge energy and discharge energy. I implemented that already before the integration was available via utility meter templates similar to above. They use the battery energy as source, which I estimated based on other sensors before the integration was available. utility meter for Solarbank battery total charge energy (usable as energy in Power Flowcharts and energy dashboard)
utility meter for Solarbank battery total discharge energy (usable as energy in Power Flowcharts and energy dashboard)
|
Beta Was this translation helpful? Give feedback.
-
And just for reference, here are the 2 power template sensors that you can use instead of the energy utility meter templates:
|
Beta Was this translation helpful? Give feedback.
-
Hello @thomluther I tried implementing it myself, but unfortunately, it's not turning out well. I've been working on the display in the Energy Dashboard for 3 days now, and my head is spinning -.- Could you perhaps help me out a bit? I have the following sensors through the integration:
Then I additionally have the following sensors from my inverter:
Additionally, I have a Shelly 3EM installed to display the consumption from the grid and the feed-in into the grid. I have built a Riemann helper for the "- sensor.solarbank_e1600_solarleistung". That's displaying some really strange values. (Solar output is at 375 watts but it shows 11.46 kWh). It should actually display 0.37 kWh, correct? Then I also have the issue of the battery charge in my Energy Dashboard showing 80 kWh and the discharge showing 560 kWh. Everything seems quite chaotic. See Picture: This is how my Energy Dashboard configuration looks like: And here is my configuration.yaml where I integrated your code:
Thanks for your help! |
Beta Was this translation helpful? Give feedback.
-
My solution for the Energy Dashboard Many who struggle with *.YAML, just like I did, seem to have difficulties setting up the sensors for the Energy Dashboard. After numerous tests, reconfigurations, and headaches, I've finally managed to find a working solution. (Perhaps not the most elegant programming solution, but it has been working very reliably for a week now.) The whole setup is in combination with a Shelly 3EM that measures consumption and grid feed-in. Perhaps it might help someone else. I need to apologize for my poor English! Important! After changing the configuration, please restart HomeAssistant. It may take several hours for the Energy Dashboard to display the values. It's best to let it run for a day and see. configuration.yaml
Assignment of the sensors in the Energy Dashboard. So this is how the whole thing should look. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@thomluther I tried to understand the above as I think it relates to my problem. For the energy dashboard (Solar production) I now use solar total yield, which seems to work nicely and produce a good daily solar production graph. For the battery charge/discharge in the energy dashboard I used daily discharge / charge sensors of the solarbanks, but this gives an ugly/wrong spike at midnight. Is there a solution to emulate a battery discharge/charge (all time) total that I can then simply use for the battery charge/discharge portions used in the energy dashboard? |
Beta Was this translation helpful? Give feedback.
-
Any total increasing sensor is good for the dashboard, do not used sensors that reset frequently.
|
Beta Was this translation helpful? Give feedback.
-
Hi @thomluther , i did set up charging and discharging template sensors. And did set integration sensors for summing up. I see the sum sensors in the Overview but the have "Unknown". I have 3 solarbanks in 3 systems. Charging and Discharging sensors display values.
|
Beta Was this translation helpful? Give feedback.
-
Integration of solarbank into energy dashboardHere I want to summarize some of the previous discussions and give a general guideline how energy dashboard integration can be accomplished for your solarbank. As mentioned on various places, I do NOT recommend using integration or and device entities directly in the energy dashboard for various reasons:
Following is the recommended high level approach to integrate devices such as the Solarbank into the Energy dashboard:
Each of those template helpers can be created in the UI nowadays. There is no need to use templates in the configuration.yaml, which may be complex and error prone for beginners. Battery entities for the energy dashboardBattery integration requires separate energy sensors of total_increasing class for both, battery charging energy and battery discharge energy. The Anker HA integration does only provide daily energy sensors for the solarbank, and since version 2.0.1 they are also classified correctly as total_increasing. While they should be directly usable in the energy dashboard, I recommend to create separate power template sensors for charging power and discharging power absolute values, and then create Riemann integral sensors over the power sensors to accumulate their energy over time. The reasons for this approach are described above. Battery power template sensors for solarbankWhen creating those template sensors via UI, you just need to copy the
Battery energy template sensors for solarbankFollowing is the code for the Riemann integral sensors that you need to create from your power template sensors above. I recommend to create them with the UI, using the parameters as shown in the code. The default
PV Energy entity for the energy dashboardIf you use the solarbank all over the year, you can use the existing solarbank photovoltaic power entity of the integration as source for your Riemann integral helper. I use the solarbank not over the complete year, therefore I use a template sensor to reflect the correct PV power depending on whether the solarbank is installed or not. When uninstalled, I use the inverter AC power entities to reflect generated PV power instead. When using this to accumulate energy statistics, it would be most accurate to consider only the AC power that really contributes to your house energy balance. However, with the solarbank DC PV power, only a subset might be converted to AC and go to the house at a given point in time, so it is difficult to consider it accurately in a correct energy balance. The following template simply ignores DC to AC conversion loss and uses the full DC PV power as reported by the solarbank, but in winter it uses the AC PV power as reported by the inverter since the inverter PV conversion loss does not contribute to the house energy balance tracked in the dashboard.
Energy dashboard example with included solarbankOnce you have integrated all correctly, your home energy balance may look like this for a day. The pink battery charge energy is balanced as negative energy while the cyan battery discharge energy is positive energy in the balance. The orange PV consumed energy in the balance is the difference of the orange PV produced energy, pink battery charge energy and purple grid export energy. The cyan battery discharge energy will be added to the blue grid import energy and is being considered as energy that goes into the house. |
Beta Was this translation helpful? Give feedback.
-
I have taken your last post, and modified the sensors and templates for the Solarbank 2 Pro model with the Smart Meter. It works but I'm not completely sure if what I did is the right way of doing it. I post my code in case there are any modifications that need to be done, or in case this is the right setup so that anyone can copy and benefit from it. template:
- sensor:
- name: "Solarbank charge power"
unique_id: "solarbank-charge-power"
unit_of_measurement: "W"
device_class: "power"
icon: mdi:home-lightning-bolt
state: >
{% set val = states('sensor.solarbank_2_e1600_pro_battery_power')|float(0) %}
{{ val if val > 0 else 0 }}
availability: >
{{ has_value('sensor.solarbank_2_e1600_pro_battery_power') }}
- name: "Solarbank discharge power"
unique_id: "solarbank-discharge-power"
unit_of_measurement: "W"
device_class: "power"
icon: mdi:home-lightning-bolt
state: >
{% set val = states('sensor.solarbank_2_e1600_pro_battery_power')|float(0) %}
{{ val | abs if val < 0 else 0 }}
availability: >
{{ has_value('sensor.solarbank_2_e1600_pro_battery_power') }}
- name: "Solarbank solar power"
unique_id: "solarbank-solar-power"
unit_of_measurement: "W"
device_class: "power"
icon: mdi:home-lightning-bolt
state: >
{% set val = states('sensor.solarbank_2_e1600_pro_solar_power')|float(0) %}
{{ val if val > 0 else 0 }}
availability: >
{{ has_value('sensor.solarbank_2_e1600_pro_solar_power') }}
- name: "Grid export power"
unique_id: "grid-export-power"
unit_of_measurement: "W"
device_class: "power"
icon: mdi:transmission-tower
state: >
{% set val = states('sensor.smart_meter_grid_export')|float(0) %}
{{ val if val > 0 else 0 }}
availability: >
{{ has_value('sensor.smart_meter_grid_export') }}
- name: "Grid import power"
unique_id: "grid-import-power"
unit_of_measurement: "W"
device_class: "power"
icon: mdi:transmission-tower
state: >
{% set val = states('sensor.smart_meter_grid_import')|float(0) %}
{{ val if val > 0 else 0 }}
availability: >
{{ has_value('sensor.smart_meter_grid_import') }}
sensor:
- platform: integration
source: sensor.solarbank_charge_power
name: "Solarbank charge kWh"
unique_id: solarbank_charge_kwh
unit_prefix: k
unit_time: h
round: 3
method: trapezoidal
- platform: integration
source: sensor.solarbank_discharge_power
name: "Solarbank discharge kWh"
unique_id: solarbank_discharge_kwh
unit_prefix: k
unit_time: h
round: 3
method: trapezoidal
- platform: integration
source: sensor.solarbank_solar_power
name: "Solarbank solar kWh"
unique_id: solarbank_solar_kwh
unit_prefix: k
unit_time: h
round: 3
method: trapezoidal
- platform: integration
source: sensor.grid_export_power
name: "Grid export kWh"
unique_id: grid_export_kwh
unit_prefix: k
unit_time: h
round: 3
method: trapezoidal
- platform: integration
source: sensor.grid_import_power
name: "Grid import kWh"
unique_id: grid_import_kwh
unit_prefix: k
unit_time: h
round: 3
method: trapezoidal I added the config at 9:00 am, so there are no metrics before that. |
Beta Was this translation helpful? Give feedback.
-
Is there really no way to split the Battery Wh sensor of the integration into charge and discharge? The measurements in Wh are all right there ... Anker only provies a new data point for Battery power every 5 minutes which we integrate with this workaround. This just cannot be correct IMHO |
Beta Was this translation helpful? Give feedback.
-
I had another idea. Just sharing. I am measuring the power the Anker Solix 2 puts into my home via a shelly 1PM. So there I get accurate readings every second. We know the Solar Power of the Anker Solix 2. Though they only update every 5 mintues, these values will not change that often compared to the battery Watt in Smartmeter mode. So if we subtract one from the other we basically get what gets charged into the battery or discharged from the battery as a far more accurate reading. There are just the edge cases if the battery is full and is not charging anymore and so on. |
Beta Was this translation helpful? Give feedback.
Integration of solarbank into energy dashboard
Here I want to summarize some of the previous discussions and give a general guideline how energy dashboard integration can be accomplished for your solarbank. As mentioned on various places, I do NOT recommend using integration or and device entities directly in the energy dashboard for various reasons: