e-Bike/pedelec battery charging automation

The automation works with any battery charging system. It needs to input an actual battery-soc (soc before charging) and a final battery-soc (soc after charging). I use the automation to charge my pedelec. It is based on an open-loop-control as it does not work with any internal data from the battery. The automation “estimates” the charging time based on a really simple algorithm which is just the difference between final soc and actual soc multiplied by 2.5 (minutes). Example: Actual soc is 40%, final soc should be 80%, the charging time is calculated/estimated to (80-40) * 2.5 minutes = 100 minutes. The factor 2.5 ist based on the observation I made with my BOSCH 750 Wh battery. Since two years it works fine for me. The factor can easily adapted depending on battery and charging device.
The calculated charging time is displayed in the input-dialogue and when the charging has been startet a timer is active. The timer stops charging when the calculated charging time has passed regardless of the soc finally achieved. The algorithm has proven to hit the chosen final soc almost in every charging process. By setting up the inputnumber it is possible to define max and min-values for actual soc and final soc.


What is necessary to do:

  1. create two inputnumbers (helper) per pedelec you want to charge: one for actual soc and one for final soc
  2. create a timer (helper) per pedelec
  3. add a template sensor in your configuration.yaml to calculate the charging time
- sensor:
     - name: ladezeitakku1
       state: "{{ ((float(states('input_number.pedelec1_soc_final')) - float(states('input_number.pedelec1_soc_actual'))) * 2.5) | int }}"
  1. set up the dialogue as an entity-card
type: entities
entities:
  - entity: input_number.pedelec1_soc_actual
    name: Ladestand Anfang (max.80% zul.,siehe Helfer)
  - entity: input_number.pedelec1_soc_final
    name: Ladestand Ende
  - entity: sensor.ladezeitakku1
    name: kalk. Ladezeit in min.
    icon: mdi:clock
  - entity: switch.zwischenstecker_e_bike_ladegerat_1_switch_0
    name: Starte Ladevorgang
    icon: mdi:clock-start
  - entity: timer.timerladezeitakku1
    name: verbl. Ladezeit in hh:mm:ss
title: E-Bike 1
state_color: true
  1. set up the automation
alias: Laden E-Bike 1
description: Startet den Ladevorgang von E-Bike Akku1 und schaltet bei Ladeende ab
triggers:
  - entity_id:
      - switch.zwischenstecker_e_bike_ladegerat_1_switch_0
    from:
      - "off"
    to:
      - "on"
    id: start
    trigger: state
  - entity_id: timer.timerladezeitakku1
    from: active
    to: idle
    id: finish
    trigger: state
  - entity_id:
      - switch.zwischenstecker_e_bike_ladegerat_1_switch_0
    from:
      - Ein
    to:
      - "off"
    id: beendenmanuell
    trigger: state
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: start
        sequence:
          - data:
              duration: >-
                {% set minutes = states('sensor.ladezeitakku1')| int %} {{
                (minutes * 60) | int | timestamp_custom('%H:%M', false) }}
            action: timer.start
            target:
              entity_id: timer.timerladezeitakku1
      - conditions:
          - condition: trigger
            id:
              - finish
        sequence:
          - action: switch.turn_off
            target:
              device_id: device_id_of_your_remote_plug
            data: {}
      - conditions:
          - condition: trigger
            id:
              - beendenmanuell
        sequence:
          - action: timer.finish
            metadata: {}
            target:
              entity_id: timer.timerladezeitakku1
            data: {}
mode: restart
  1. set up a remote plug (e.g. shelly plug plus) to connect/disconnect the charging device from the supply-net.