home-assistant-configuration
home-assistant-configuration copied to clipboard
Integrate Electric Unicycle Battery Charging
In order to preserve the battery on my unicycles, I'd like to not keep them fully charged until I'm going out to ride them. The available apps don't let me set a max charge level, but they do expose the current charge over BLE for the apps to consume.
Idea:
- [ ] Put the unicycle charger on a smart switch, ideally with current monitoring for additional calculations later.
- [ ] Build a custom ESP device (hopefully as a custom sensor in ESPHome) that can connect to the wheel and extract battery level.
- Reference: https://github.com/Pickelhaupt/EUC-Dash-ESP32/blob/master/src/hardware/Kingsong.cpp
- [ ] Monitor charge level and turn off the charger accordingly.
Alright, well I played with this for a while, but I'll need to write more custom code than I feel like for tonight. Dropping a bunch of references:
- https://github.com/esphome/esphome/blob/dev/esphome/components/ble_client/sensor/ble_sensor.cpp
- I could implement my own BLE sensor type, similar to the text or standard BLE sensor. This would probably be the best option moving forward.
- Good code references for which service/characteristic I need, and how to parse them:
- ESP32 code:
- https://github.com/Pickelhaupt/EUC-Dash-ESP32/blob/master/src/hardware/Kingsong.cpp
- https://github.com/Pickelhaupt/EUC-Dash-ESP32/blob/2650400ce4a9156fc71b01028981d66c447dede1/src/hardware/blectl.h#L65
- Java for WheelLog:
- https://github.com/Wheellog/Wheellog.Android/blob/master/app/src/main/java/com/cooper/wheellog/utils/KingsongAdapter.java#L21
- https://github.com/Wheellog/Wheellog.Android/blob/291b473e4e56f504eb917985b3a6ffbdf2000da9/app/src/main/java/com/cooper/wheellog/utils/Constants.java#L30
- ESP32 code:
- There's also a custom component that helped a bit in my testing:
- https://github.com/myhomeiot/esphome-components#ble-client
- Example: https://github.com/myhomeiot/esphome-components/blob/main/examples/myhomeiot_ble_client/mi_band.yaml
- Forum about reverse engineering the protocol: https://forum.electricunicycle.org/topic/870-gotwaykingsong-protocol-reverse-engineering/
Branch with ESPHome config: https://github.com/corbanmailloux/home-assistant-configuration/compare/unicycle-monitor
Hi, did you finally succeed? I would also like to be able to stop the load on my wheel at say 90% so I am interested in your work...