Bosch eBike Flow App Integration (BES3)

I used to use ioBroker, which has an adapter for integrating the Bosch Flow+ app. ioBroker is therefore still running on my system and sends the Flow+ data to HA via MQTT. For me, it is important to have the latest battery charge level and the number of kilometers per trip. Incidentally, 100% battery charge is not really 100%, but slightly less. This means you can always charge the battery to 100% without worrying about damaging it, as is the case with electric cars. However, I switch off the power supply when the socket reports that no power is being consumed. This is because the charger keeps trying to charge the battery further or maintain the charge level. You can see this from the small power spikes that occur regularly.

Doesn’t the battery level only work with their Connect module and an active Flow+ subscription?

Upvoting. There is a massive feature update just released, now it’s possible to share 1 bike with multiple phones, or vice-versa, as well their API Docu got a fresh update. This shall be possible from now on, to integrate the API - or use BLE for the connection.
Industry solutions
Now the important question: where do we beginn? :slight_smile:

3 Likes

I reverse engineered the iobroker adapter to see if I could convert it to a home assistant integration.

Unfortunately the current flow api only provides ride statistics - nothing about the bike itself

It seems the flow API offers a lot less functionality than the old connect API

This new update seems very positive, it would allow retrieval of battery percentage (within 5 minute accuracy) and location if you have the connect module installed

However the contact us link on the page doesn’t work, the only reference I can find to the mobile SDK is Bosch eBike Systems - eBike SDK Ā· GitHub which is fully private

If I can get in touch with them somehow and get SDK or API documentation I’m more than happy to build and maintain a home assistant integration

7 Likes

That’s not fully true. If you look at the ioBroker thread in their forum someone posted a ā€œlinkā€ to query the battery state (at the very end).

This is working fine for me in a patched version of the ioBroker module. Only my BikeID is hardcoded as I don’t know how to retrieve it automagically.

1 Like

Thanks! I had missed that

Done some exploratory work into it and managed to get state of charge.
It only works when the bike is on or charging, but that’s a lot more than we currently have :smiley:

I’ve currently got this -

  • Battery Level: 100% :white_check_mark:
  • Charger Connected: Yes :white_check_mark:
  • Charging Status: Not charging (fully charged) :white_check_mark:
  • Remaining Energy: 7,051 Wh (from ConnectModule) :white_check_mark:
  • Reachable Range: [39, 36, 23, 23] km per assist mode :white_check_mark:
  • Last Update: Just ~2 hours ago :white_check_mark:

I can get the bikeId from another endpoint so should be able to make this into a working HASS plugin now - authenticate with flow credentials and it will pull back data for all bikes.

It will have to poll for charge status every 5 minutes and store historical data as when the bike charger turns off the data will stop - but for people wanting to charge until 80% then turn off a wifi plug that will be fine

I can’t guarantee i’ll get it done quickly as open-source work takes a back seat to my day to day job but I’ll throw some updates in here as I progress

9 Likes

Saying that… it’s going well so far :smiley:

6 Likes

This is so awesome. Can’t wait to test it. Are you pulling the data via a connectmodule or bluetooth locally?

At the moment it’s only working for bikes with the connectmodule and flow+ subscription. Which I have

I think that’s going to be the most reliable as it doesn’t require the bike to be on and a bluetooth connection.

I can try looking into the older bosch connect API for pre-smart bikes, as I think that also exposed some stuff which might be useful - though I don’t have a gen 3 bike anymore so would need to borrow someones API details to develop that

For the smart bikes though the connect module is the best way - bosch have really restricted what the flow API can do.
There was an announcement this month that they’re opening up a much better API to allow fleet tracking and stuff which should show a lot more information but there’s no info yet on how to register for a developer account and again I think it would rely on bikes having the connect module.

thanks … the issue with the connect module is that many MTBs cannot easily be equipped with it as it requires putting it somewhere in the frame as the default placement does not work due to limited space. Let’s hope there will be an alternative way to connect with the new API.

On a side note: does this increase the polling frequency of the connect module via the cellular connection it has built in? if so, that might be a recipe for disaster as bosch will try to shut it down due to growing connectivity costs (but I think you only poll the cloud API and have no influence on the cloud ↔ connect module frequency - so this should be fine)

Nope the connectmodule just sends data to Bosch as it would - I just query their API and get whatever the last data is they got.

1 Like

Turned out to be quicker than I thought

All done and working

You can add a custom repo to HACS and install if you’d like to test - but sadly you will need a connectModule and Flow+ subscription

This may change in the future if Bosch get more open with their API’s - we’re having to hijack mobile app functionality to make this work - but for now that’s the only use case that will work.

I’m happy to reach out to Bosch as the ā€œGet in touchā€ link for the new API doesn’t work and try to do this ā€œproperlyā€ in the future likely with a lot more functionality, but need to show that there’s a user base for it!

8 Likes

Amazing! Very excited to try this myself, though I’m having issues extracting the code in the auth process. I’ve tried it a handful of times on multiple browsers (all Chromium variants on desktop) and never seem to end up with a code key in the querystring. Also tried from my phone with similar results. Example:

https://singlekey-id.com/en-us/redirection?returnUrl=/auth/connect/authorize/callback?scope=openid%20email%20profile%20offline_access&state=Bi7zebe-aLBEBWuTnzeH_O45rJ1NOJGhmabGSkbpnzU.tKZxubFArhg.F30z_5ulQyijx4RP1mOV-A.eyJydSI6Im9uZWJpa2VhcHaW9zOi8vY29tLmJvc2NViaWtlLm9uZWJpa2VhcHAvb2F1dGgycmVkaXJlY3QiLCJydCI6IvZGUiLCJzdCI63bnFzMjI4RVJPWUt6Yllhc2NnVVBzeWWJCOXFUajB2ckJZc2xjZzAifQ&response_type=code&client_id=D6A9F4-4F02-9EE4-C5CEC3EF4&redirect_uri=https%3A%2F%2Fp9.authz.bosch.com%2Fauth%2Frealms%2Fobc%2Fbroker%2Fskid%2Fendpoint&prompt=login&code_challenge=fmLODKhfdcrlLYUdJtgxo7_4ZF1BAyxpn_AYzjM&code_challenge_method=S256&nonce=ZaWfWiforCC_LA3w&suppressed_prompt=login&f=Nzmk

For this example, I removed a handful of characters from each value above in case there’s sensitive data in there. I confirmed that I’m using the exact same login info as used in my Bosch Flow app.

Where am I going awry?

It’s really awkward

When you get to the login page open developer tools - go to network tab

Put your username in
Then your password

After that you’ll see a ā€œredirecting in 5ā€¦ā€ screen - after 5 seconds you’ll see a red redirect to a url starting with onebikeapp-ios:// that failed - in that URL the last paramater is ?code=xxxx

Copy the code from there

1 Like

I finally got it working that way. Thank you very much for that nice integration. I get values for everything but the Battery Remaining Energy, will check when I use the bike the next time. Currently it is off.

1 Like

I really don’t know what you mean.
This is the login screen I get,

I don’t see developer tools.
I also created a ticket on you’re github by the way.

Thanks for helping me.

Developer tools is in the browser

If you’re in Edge or Chrome press F12
Then across the top you’ll see a tab for Network

In there you can see what network requests the page is trying to do
Because the only way to do this at the moment is to pretend to be the iOS app - you have to look for where it tries to redirect back to onebikeapp-ios://… and fails - then copy the code from it

If bosch allowed people to register to use their API I could do it all in one click - unfortunately they don’t seem particularly friendly to integrators at the minute

That worked, thank you!

Fingers crossed for better Bosch API access for integrators in the future.

2 Likes

Hi,

After a reboot the integration stopped working.
Tried to delete and recreate the device, that succeded but new entirties were created,
See error from the log:

Deze fout is ontstaan door een aangepaste integratie.

Logger: custom_components.bosch_ebike.coordinator
Bron: helpers/update_coordinator.py:392
integratie: Bosch eBike Flow (documentatie, problemen)
Eerst voorgekomen: 14:55:15 (88 gebeurtenissen)
Laatst gelogd: 16:48:50

Unexpected error fetching bosch_ebike_f1ad6d87-2cec-4f1e-a4e1-a89f0afa9a89 data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 392, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/bosch_ebike/coordinator.py", line 57, in _async_update_data
    combined_data = self._combine_bike_data(profile_data, soc_data)
  File "/config/custom_components/bosch_ebike/coordinator.py", line 111, in _combine_bike_data
    "alarm_enabled": connected_module.get("isAlarmFeatureEnabled"),
                     ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'

whaou !!! thanks, it works.