oh okey. So i greate a new sensor with positive Values.
Hi - so how i get this running ?
utility_meter:
energy_import_daily:
source: sensor.energy_import_sum
name: Energy Import Daily
cycle: daily
energy_import_monthly:
source: sensor.energy_import_sum
name: Energy Import Monthly
cycle: monthly
energy_export_daily:
source: sensor.energy_export_sum
name: Energy Export Daily
cycle: daily
energy_export_monthly:
source: sensor.energy_export_sum
name: Energy Export Monthly
cycle: monthly
energy_consumption_daily:
source: sensor.energy_consumption_sum
name: Energy Consumption Daily
cycle: daily
energy_consumption_monthly:
source: sensor.energy_consumption_sum
name: Energy Consumption Monthly
cycle: monthly
What should i change ? I dont get it
Evrything else works⌠okay the energy dashboard works also not 100% but yeahâŚ
python is to complicated
Could u please tell me how u configure the Energy Dashboard ?
Add the templates to your configuration.yaml and configure the dashboard as per photos in post 9
Okay - this is my configuration now⌠but the acutal consumption goes in the negative valueâŚ
i tested all constellations⌠but i have no luck âŚ
Also the value doesnt match - it will be added what make no sense to meâŚ
what´s wrong with my code
it doesnt make sense that the import + solar power are summed up⌠i dont get it.
The Problem exist only if i´m importing. if i´m exporting the value is correctâŚmmhpf
#Shelly3EM
- platform: template
sensors:
# Template sensor for values of power import (active_power > 0)
power_import:
friendly_name: "Aktueller Import"
unit_of_measurement: 'W'
value_template: >-
{{ max(0,states('sensor.shelly3em_channel_a_power')|float + states('sensor.shelly3em_channel_b_power')|float + states('sensor.shelly3em_channel_c_power')|float)}}
availability_template: "{{
[ states('sensor.shelly3em_channel_a_power'),
states('sensor.shelly3em_channel_b_power'),
states('sensor.shelly3em_channel_c_power')
] | map('is_number') | min
}}"
# Template sensor for values of power export (active_power < 0)
power_export:
friendly_name: "Aktueller Export"
unit_of_measurement: 'W'
value_template: >-
{{ min(0,states('sensor.shelly3em_channel_a_power')|float + states('sensor.shelly3em_channel_b_power')|float + states('sensor.shelly3em_channel_c_power')|float)|abs}}
availability_template: "{{
[ states('sensor.shelly3em_channel_a_power'),
states('sensor.shelly3em_channel_b_power'),
states('sensor.shelly3em_channel_c_power')
] | map('is_number') | min
}}"
#Template sensor for values of power consumption
power_consumption:
friendly_name: "Aktueller Verbrauch"
unit_of_measurement: 'W'
value_template: >-
{% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.shellypv_power')|float(0) - states('sensor.power_export')|float(0)) < 0 %}
{% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.shellypv_power')|float(0) - states('sensor.power_export')|float(0)) > 0 %}
{{ (states('sensor.shellypv_power')|float(0)) - states('sensor.power_export')|float(0) }}
{% else %}
{{ states('sensor.power_import')|float(0) + states('sensor.shellypv_power')|float(0) }}
{% endif %}
Why power import and power solar are added ? this make no sense (see picture)
The entire Power consumption calculation doesnt match.
EDIT EDIT EDIT
So, i tested another change:
#Template sensor for values of power consumption
power_consumption:
friendly_name: "Aktueller Verbrauch"
unit_of_measurement: 'W'
value_template: >-
{% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.shellypv_power')|float(0) - states('sensor.power_export')|float(0)) < 0 %}
{% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.shellypv_power')|float(0) - states('sensor.power_export')|float(0)) > 0 %}
{{ (states('sensor.shellypv_power')|float(0)) - states('sensor.power_export')|float(0) }}
{% else %}
{{ max(0,states('sensor.shelly3em_channel_a_power')|float + states('sensor.shelly3em_channel_b_power')|float + states('sensor.shelly3em_channel_c_power')|float)}}
{% endif %}
This looks good in Import Modus - its now too late to test it with export⌠i give feedback tomorrowâŚ
I hope anyone can help me with this.
Consumption is total power your house is using, so if you are importing you are using all of the solar power + whatever you are importing, this looks correct to me.
Ah okay - yes if u say it so this make sense.
I assumed that it is the current consumption without solar. So the pure house consumption without calculating the yield.
Is it possible to add a template / sensor - which only shows me the pure house consumption or the self-consumption?
Iâm still practicing and canât really get any further
Consumption without the solar is the import power, which you already have.
Iâm not sure what you are wanting?
Hi James,
thanks for your script, that works for me better as my solution
just a short question:
why you are using the utility meters for the energy dashboard?
Currently I added for grid consumption âsensor.power_importâ and for Return âsensor.power_exportâ
Do i have to use the daily values or can it also yes with the import/export sensors?
Hi James, additional question to understand how the sensor power_consumption should work.
to explain my question better, lets have a look at these lines:
{% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.solar)|float(0) - states('sensor.power_export')|float(0)) < 0 %}
{% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.solar')|float(0) - states('sensor.power_export')|float(0)) > 0 %}
{{ (states('sensor.solar')|float(0)) - states('sensor.power_export')|float(0) }}
{% else %}
{{ states('sensor.power_import')|float(0) + states('sensor.solar')|float(0) }}
{% endif %}
The first If checks, if the export >0 AND Solar - Export<0. How can this check be true?
In my case that is always false, because the Solarvalues can only be positive (in my case from 0-600W).
The values from sensor.export can also only be positive, calulated via ShellyEM3.
So thererfore my Solar is part of the ShellyEM3 Monitoring it cannot be greater than the value of sensor.export.
So why is that first line implemented, I think there is something what I not note at the moment?
And second question:
if in my case the the first if always be not true (that means >0) which reaction in that loop will happen? The Solar - export value OR the Import + Solar value?
thanks for helping
Because the data for Solar Generation and Export are often provided by different sources on different update intervals(inverters and shelly), there can be times when the data is out of sync, say the clouds come over and reduce the solar quickly, this can produce large negative spikes.
The first if statement detects this and does not process this incorrect data and waits till the next update of the sensor values.
If that first if statement is not true it will process the rest and calculate depending on if you are importing or exporting at that time.
The Energy dashboard requires Energy(kWh) not power(W) as per the instructions and prompts:
âGrid consumption is the energy that flows from the energy grid to your home.
Consumed Energy (kWh)â
Sure, my mistake: I meant the Riemann sensors of export/import.
energy_import_sum for Consumption and
energy_export_sum for Return.
That is an incrementing counter that doesnât reset, it does not show in the list of acceptable sensors.
I suspect that will cause issues.
Just click the upside down triangle on the energy dashboard configuration when you try add a Gird consumption, it shows you what is acceptable.
Iâve added at the template sensors the device_class âpowerâ, so the Riemann integration sensors getting automaticly device_class âenergyâ
so itâs choosable in energy dahsboard.
Not sure why you would go out of your way to configure it incorrectly.
is it possible to extend the script in such a way that I can see what I have saved on costs per day/month jan-dez? I would then have total consumption - calculate consumption right? * my kwh price ⌠the result then in a variable January e.g
It is really outside of aim of the scripts, which is NET metering.
Itâs not so easy to come up with a âcalculate consumptionâ as the true savings are a also tied to how much solar you self-consume and export. The energy dashboard provides $ amounts for import, export and totals for daily/monthly/yearly. If you want more detailed analysis I suggest you send your data to pvoutput.org, itâs what I use for solar system payback etc.
Hi @uksa007,
Iâve watched the behaviour of the script the last couple days and it seems to be working - mostly.
but, sometimes there seems to be an error (in the script or in my mind):
legend:
violet: power_import
blue: power_export
turquoise: solar power
what fits for me is the timeframe 13:41 - 13:45:
power_import is high (>1300W), solar generates about 480W and therefor no power_export (0).
if I look at timeframe 14:08 - 14:18, power_import is also high (>2000W), solar generates about 560W and power_export is 300W.
That makes no sense to me.
what can I check regarding this behaviour? what can be wrong?
thanks for helping?
Check that you have included all of your shelly 3 phase sensors correctly in the power_import and power_export templates. (names in the templates you will need to change to your sensor names, sensor.l1.power, sensor.l2.power, sensor.l3.power)
Check the Shelly power sensors for each phase are reporting the correct values, you could have one of the current clamps installed backwards.