Calculating power consumption based on different sensors and states

Hello all!

I want to calculate the power usage when my car is charging. I know when the car is charging via the cars API in an on or off state (switch.car_charging) and I also have a sensor with the current charge level (sensor.car_battery_level). The problem is that when the car is charging 0-90% it’s consuming 2350 w and between 90-100% it’s only using 1200 w.
How would I set up a kwh sensor to track this in the energy dashboard? I tried to get it working with Power Calc but could not figure out how to combine the two sensors.

Thank you!

  1. Create a template power sensor, which returns either 2350, 1200, or 0 W depending on your other sensors.
  2. Riemann sum this template power sensor to get a charging energy sensor.

You can add #2 to the energy dashboard.