Smart EVSE software EV-meter

Smart solar EV charging is fun and good for the energy transition, the hardware and software just work out of the ‘box’.

The integration in HA is a piece of cake with a a nice HACS integration.

One issue only: The charged energy is managed and measured, but not available for HA. The solution proposed by the SmartEVSE team is to install a separate EV meter. The data from this additional piece of hardware can be fed into the SmartEVSE system. This separate meter can be a formal requirement if you need accurate data for tax purposes or to bill your employer.

My solution is a free alternative for the EV meter, good enough if you just want to see and follow the data in and around your house.

All of this is achieved by creating 3 sensors:

First create a one or zero sensor indicating if your car is being charged:

- platform: template
    sensors:
      smartevse_charging_10:
        friendly_name: "Charging Yes or No"
        value_template: "{{ iif(is_state('sensor.smartevse_state_id', '2'), '1', '0') }}"
        unique_id: s10
        icon_template: mdi:battery-arrow-up-outline

This is needed because the charge current is available in the API/MQTT but retains it’s last value. So the power consumption is calculated as follows:

- platform: template
    sensors:
      smartevse_charge_power:
        friendly_name: "Charge power"
        unit_of_measurement: W
        value_template: "{{ ((states('sensor.smartevse_charge_current')|float) * (states('sensor.dsmr_reading_phase_voltage_l1')|float )  * (states('sensor.smartevse_charging_10')|float ) ) | round(0) }}"
        icon_template: mdi:ev-plug-type2
        unique_id: scp

Now the last sensor to convert the power to energy with the Riemann integration:

- platform: integration
    source: sensor.smartevse_charge_power
    name: smartevse_charge_energy
    unit_prefix: k
    unit_time: h
    round: 3
    method: left
    unique_id: sce

Just add the EV charged energy to your energy dashboard.

Screenshot 2024-08-06 at 10.44.47

Have fun

A bit of a starter question: when I copy this to configuration.yaml I get an error. So I guess this is supposed to be added somewhere else.
Where should I put this?
Thx

This should be part of your configuration.yaml or better create a subdirectory for all your (template) sensors. ref: Splitting up the configuration - Home Assistant