Hi there,
I’m using Riemann sum integral to calculate the amount of energy used while charging my car based on the current charge rate given in W.
Unfortunately, I get negative values while not charging, resulting in a false decrease of calculated energy.
So, I’m trying to use a condition template to get a sensor with the current charge rate or “0” if the rate appears negative.
So far, I’ve tried the following which doesn’t work:
template:
- sensor:
- name: auto_ladeleistung
unit_of_measurement: "W"
state: "{{ '{{ (states('sensor.charging_power')|int * 1000) | round(1) }}' if is_state('sensor.charging_power', '> 0') else '0' }}"
state_class: measurement
device_class: power
Any ideas? Thanks in advance!