Created
February 5, 2026 21:34
-
-
Save hallettj/d5b63ede9a22c863522ae3eafb355a3f to your computer and use it in GitHub Desktop.
Charge e-bike to about 80% using Home Assistant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| alias: charge ebike to about 80% | |
| description: "" | |
| triggers: | |
| - type: turned_on | |
| device_id: 556a422a7ba455208c850f978429413d | |
| entity_id: 97d303fe6f6a9fdee99de120848bacaf | |
| domain: switch | |
| trigger: device | |
| conditions: [] | |
| actions: | |
| - delay: | |
| hours: 0 | |
| minutes: 10 | |
| seconds: 0 | |
| milliseconds: 0 | |
| - wait_for_trigger: | |
| - value_template: >- | |
| {% set power = | |
| states("sensor.mini_plug_with_power_meter_electric_consumption_w")|float | |
| %} | |
| {# Check two different power ranges to distinguish Trek FX+ 2 from | |
| Orbea Diem #} | |
| {{ (power > 97 and power < 150) or (power > 191.0) }} | |
| for: | |
| hours: 0 | |
| minutes: 2 | |
| seconds: 0 | |
| trigger: template | |
| timeout: | |
| hours: 2 | |
| minutes: 30 | |
| seconds: 0 | |
| milliseconds: 0 | |
| - type: turn_off | |
| device_id: 556a422a7ba455208c850f978429413d | |
| entity_id: 97d303fe6f6a9fdee99de120848bacaf | |
| domain: switch | |
| mode: single |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use this Home Assistant automation to stop e-bike charging at about 80% charge. I use a Zooz smart plug that has on/off control, and power monitoring via Z-Wave. I plug the bike charger into that plug. (For safety always use the original charger to charge your e-bike!)
The automation is triggered when I turn the smart plug on by pressing the button on the plug. It waits for 10 minutes to make sure power draw has stabilized. Then when power draw exceeds a specified target (in watts), the automation turns the plug off. There is a 2.5 hour timeout to stop charging after a reasonable amount of time in case I messed up the power draw logic, or some such thing.
The key is to charge the bike to 100% at least once. Then look at the graph of power draw history in Home Assistant. As battery charge increases it gets gradually harder to get more energy into it. So power draw increases steadily. What's special about the 80% number is that with typical lithium-ion batteries the last 20% is a little extra difficult to charge. So at some point toward the end of charge you should see the power draw slope increase slightly. It's subtle, so it takes some guess-work. Look at the watt value at the point where that slightly steeper slope starts, and use that as your cut-off value.
I use the same plug to charge two different bikes. Fortunately their chargers have non-overlapping power ranges, so it's easy to write cut-off logic that works for both bikes. (>97 W for a Trek FX+ 2, >191 W for an Orbea Diem). I previously used the same setup with a Tern GSD Gen 2 where I set >185 W as the cut-off.