Automatically limit my EV charging to 80 % via my charger

So far I have managed this but need to manually add the KWh manually to the automation at the above: line

alias: limit zappi
description: ""
trigger:
  - type: energy
    platform: device
    device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
    entity_id: sensor.myenergi_zappi_charge_added_session
    domain: sensor
    above: 19
condition: []
action:
  - device_id: xxxxxxxxxxxxxx
    domain: select
    entity_id: select.myenergi_zappi_charge_mode
    type: select_option
    option: Stopped
mode: restart

i would like to automate the entry at above:
I can see the battery percentage on the sensor
sensor.leaf_battery_level
the formula i need to use is 80 - leaf battery level * 0.37

With some trial and error i have this but can’t figure out how to put the 2 bits of code together!

{% set t = states('sensor.leaf_battery_level') | int %}
{{ (80 - t) * 0.37 }}