I’m still trying to grasp what you are trying to accomplish.
You’ve got a calculation that will show you the price of charging per minute, you say that your charger has a fixed consumption of 11kW (which I doubt because to my knowledge most chargers will lower their consumption if the battery is almost full).
If you assume that if power consumption is above 11kW, then the car is charging at a rate of 11kW/hr. This would be my interpretation of your idea. I’ve borrowed some of the idea’s I’ve posted in Using power consumption to show information (status, elapsed time, count) of cycles on a dish washer - #2 by hebom
Let’s create a binary sensor that determines if the carcharger is in operation:
- platform: template
sensors:
carcharger_status:
friendly_name: "Carcharger status"
delay_on:
minutes: 0
delay_off:
minutes: 0
value_template: >-
{{ states('sensor.powermonitor') | float(0) > 11 }}
sensor.powermonitor is the sensor that monitors your overall power consumption.
The 11 is the 11kW that the carcharger consumes.
You can add delays if you want to, I’ve set them to 0 because of the fixed 11kW rating.
Let’s create some (regular) sensors:
Now that we know when your car is charging it’s time to determine the running time (in minutes).
- platform: template
sensors:
carcharger_runtime:
friendly_name: "Carcharger runtime"
value_template: >
{% set x = states('sensor.time') %}
{% set t = 0 if states('binary_sensor.carcharger_status') == 'off' else now().timestamp() - states.binary_sensor.carcharger_status.last_changed.timestamp() %}
{{ ( t / 60 ) | round(0) }}
We know now how long the car is charging, so we can calculate a tariff based on the duration of the charging:
- platform: template
sensors:
carcharger_spending:
friendly_name: "Carcharging spending"
value template:
{% set a = binary_sensor.carcharger_runtime %}
{% set b = ((sensor.energytariff() * 11) / 60) %}
{{ ( a * b ) | round(2) }}
You would like to know the “damage” per day, week and month:
utility_meter:
carcharger_daily_total:
source: sensor.carcharger_spending
name: Daily carcharger spending
cycle: daily
carcharger_weekly_spending:
source: sensor.carcharger_spending
name: Weekly carcharger spending
cycle: weekly
carcharger_monthly_spending:
source: sensor.carcharger_spending
name: Monthly carcharger spending
cycle: monthly
I hope this works, but it might need some tinkering.