I have a P1 energy meter from Homewizard. It gives me total Energy usage consumed from the net (energy tariff 1 and 2). My sonar panels are producing energy. So in the energy dashboard i see what the total consumtion is for a day what is consumed from the net.
What i would like is the total energy consumed (without produced with solarpanels) so the total consumtion.
I have made a helper which shows me consumtion of the day taken from the net but not the bruto consumtion which the house consumed.
Is this possible to create in a helper?
It would be nice to have total consumtion added with produced and consumed from solarpanels because that is the total consumtion?
What i have available:
p1 meter import tarif 1 and 2
p1 meter export
solar panels production (but this is not kWh)
Your question is a bit confusing…
If you’re looking for you actual household energy consumption, it would, on a daily basis, your solar production - your P1 export + P1 import, both expressed in kwh.
It would be easier (also for you, I guess) if you provide numerical examples of what you have, and what you want to achieve.
what i have:
sensor.p1_meter_energie_export - 1.000
sensor.p1_meter_energie_import_tarief1 - 3.000
sensor.p1_meter_energie_import_tarief2 - 1.000
Envoy_production_today: 5.000 kWh
Envoy_production_lifetime: 100.000 kWh
Sensor for Energy Export is what i have totally exported to the net (generated with solarpanels and not consumed)
P1 meter import tariff 1 and 2 is what i have totally consumed
Envoy is what i generate with Solar.
So lets assume above is for today and i have consumed 9.000 kWh total:
In the numbers above you can see that i have consumed 4 kWh from the net and have exported to the net 1 kWh. That means directly consumed from solar panels: 4kWh but the problem is i cannot see:
Total consumtion 9 kWh (only what is consumed from the net)
Directly consumed from solar panels.
If it could be possible to create a helper that displays:
P1 imported t1+t2 + directly consumed from solarpanels
When these 2 are added to each other then i can display that helper in a graph and see the day consumtion off 9 kWh.
House = import t1 + import t2 + PV energy today - export
= 3 + 1 + 5 -1 = 8kWh, not 9kWh.
template:
- sensor:
- name: House Consumption
device_class: energy
state_class: total # there's a chance that this total could go backwards momentarily due to asynchronous sensor updates so do not use total_increasing
unit_of_measurement: kWh
state: >
{{ states('sensor.p1_meter_energie_import_tarief1')|float +
states('sensor.p1_meter_energie_import_tarief2')|float +
states('sensor.envoy_production_today')|float -
states('sensor.p1_meter_energie_export ')|float }}
availability: >
{{ has_value('sensor.p1_meter_energie_import_tarief1') and
has_value('sensor.p1_meter_energie_import_tarief2') and
has_value('sensor.envoy_production_today')|float and
has_value('sensor.p1_meter_energie_export ') }}
thx, i will try this
i have tried the template in developer mode but it gives an error:
value error: template error: float got invalid input unknown when rendering template…followed with the sensors and availability …but no default specified
Did you change the envoy sensor entity id I made up to your actual sensor?
You did not tell us what that one was.
- name: Energie_huis_verbruik
device_class: energy
state_class: total # there's a chance that this total could go backwards
momentarily due to asynchronous sensor updates so do not use
total_increasing
unit_of_measurement: kWh
state: >
{{ states('sensor.p1_meter_energie_import_tarief_1')|float +
states('sensor.p1_meter_energie_import_tarief_2')|float +
states('sensor.envoy_energy_production_today')|float -
states('sensor.p1_meter_energie_export ')|float }}
availability: >
{{ has_value('sensor.p1_meter_energie_import_tarief_1') and
has_value('sensor.p1_meter_energie_import_tarief_2') and
has_value('sensor.envoy_energy_production_today')|float and
has_value('sensor.p1_meter_energie_export ') }}
above is what i tested in developer mode: i have changed the name of sensors which is for my configuration correct
Remove the |float
from that copy and paste mistake I made.Should be:
has_value('sensor.envoy_energy_production_today') and
- name: Energie_huis_verbruik
device_class: energy
state_class: total # there's a chance that this total could go backwards momentarily due to asynchronous sensor updates so do not use total_increasing
unit_of_measurement: kWh
state: >
{{ states('sensor.p1_meter_energie_import_tarief_1')|float +
states('sensor.p1_meter_energie_import_tarief_2')|float +
states('sensor.envoy_energy_production_today')|float -
states('sensor.p1_meter_energie_export ')|float }}
availability: >
{{ has_value('sensor.p1_meter_energie_import_tarief_1') and
has_value('sensor.p1_meter_energie_import_tarief_2') and
has_value('sensor.envoy_energy_production_today') and
has_value('sensor.p1_meter_energie_export ') }}
gives the same error
What error exactly?
It is the last line: but no default was specified
Error message:
value error: template error: float got invalid input unknown when rendering template…followed with the sensors and availability …but no default specified
Do this for each sensor individually until you find the one that is not correct:
{{ states('sensor.p1_meter_energie_import_tarief_1')|float }}
All the sensors gives a result
Try removing the space inside these single quotes:
states('sensor.p1_meter_energie_export ')
For both the state and availability templates.
thats it!
now i paste it in the yaml configuration
i am waiting for a status, in developer mode the sensor has no status: unknown. Restarted HA but this can take a while i guess.
When above works then i can also create a template sensor to create a sensor for kWh used directly from solar panels like this i guess?:
- name: Energie_eigen_ZP_verbruik
device_class: energy
state_class: total # there's a chance that this total could go backwards momentarily due to asynchronous sensor updates so do not use total_increasing
unit_of_measurement: kWh
state: >
{{ states('sensor.Energie_huis_verbruik')|float -
states('sensor.p1_meter_energie_import_tarief_2')|float +
states('sensor.p1_meter_energie_import_tarief_1')|float }}
It should update as soon as one of the sensors changes and all sensors have a valid numeric state.
Sure but don’t forget the availability template. It is important that the sensor only calculates the value when all sensors are reporting a valid value. And you can simplify it to:
state: >
{{ states('sensor.envoy_energy_production_today')|float -
states('sensor.p1_meter_energie_export')|float }}
availability: >
{{ has_value('sensor.envoy_energy_production_today') and
has_value('sensor.p1_meter_energie_export') }}
Your solar produced minus the energy exported is how much solar energy you used. Things only become more complicated if you have a battery.