Smart Bike Lights (Data Field) / Bike Lights Control (Widget)

I've made two open source CIQ applications to control ANT+ lights:

- Smart Bike Lights (data field): https://apps.garmin.com/en-US/apps/0d9fd828-c932-4470-9c37-fd2828881888 

      Configurator: https://maca88.github.io/SmartBikeLights/ 

- Bike Lights Control (widget): https://apps.garmin.com/en-US/apps/fa3c2332-76e3-4ba1-8528-32a0fd617ab1 

     Configurator: https://maca88.github.io/BikeLightsControl/ 

Smart Bike Lights features:
- Automatic light control (Smart mode) based on the configured filters (sunset, sunlight, speed, ...)
- Manual light control (only for Edge devices with a touch screen or devices with CIQ 3.2 and more than 32KB memory)
- Records lights modes that are displayed in Garmin Connect

Bike Lights Control features:
- Manual light control (available to all devices)

Both applications can be installed on the same device, which can be useful for low end devices (e.g. Edge 520) where "Bike Lights Control" can be used to change light modes manually and "Smart Bike Lights" for automatic light control.

Currently registered ANT+ lights:
- Bontrager Ion Pro RT
- Bontrager Ion 200 RT
- Bontrager Flare RT
- Garmin Varia RTL500
- Garmin Varia RTL510
- Garmin Varia RTL515
- Garmin Varia HL500
- Garmin Varia UT800

in case your ANT+ light is not on the list you can help by doing the following:

1. Install Bike Lights Control
2. Pair your bike light with your Garmin device
3. Open the widget:
- Edge with a touch screen: post which numbers are displayed on the buttons and what mode each button represents when pressed
- Other devices: Select the "Light modes" menu and post which numbers are displayed in the menu and what mode each menu item represents when selected

Example for Bontrager Ion Pro RT:


1 -> High steady beam
2 -> Medium steady beam
5 -> Low steady beam
63 -> Day flash
62 -> Night flash

There are some features that could be possible to add in the future, but would require Garmin to add them to the CIQ api. In case you are interested in any of the below features, consider upvoting their feature request thread:

1. Control lights based on the ambient light sensor available on some devices:
https://forums.garmin.com/developer/connect-iq/i/bug-reports/ambient-light-sensor-api-access 

Known issues:

1. Unable to use Tempe Visualizer or TyreWiz Data Field alongside Smart Bike Lights:
https://forums.garmin.com/developer/connect-iq/i/bug-reports/lightnetworklistener-onbikelightupdate-not-called-when-certain-data-fields-are-installed

  • What if we send setMode() in loop (with retry timer), until onBikeLightUpdate() status will confirm and only then switch off loop. And Button state do not change (visual) - it do not care about state, and I can press other buttons instantly or the same button instantly - it would feel much faster I guess. And this loop make sure mode will be set eventually, even it can be lost a few attempts.
    What do you think?

    I can create a test version of Smart Bike Lights which would call setMode on each second (called on compute as timers are not supported for data fields) until the timeout, which is currently 5 seconds. Can you provide me the configuration that you are using, so that I can hardcode it in the test data field, which you could sideload and test it=?

  • However, when I change the modes using the native Garmin light widget, I can switch between four states — brighter, dimmer, flashing, and off.
    In that case, the “Updates” value increases

    This is really odd. For some reason the onBikeLightUpdate callback is not called when the light mode is changed via the physical button. Unfortunately, without the onBikeLightUpdate callback working, you will not be able to find the missing light mode. I will need to create a different LightTester that does not rely on the LightNetwork api, but that will take me some time. I will ping you when it will be ready.

    What about the light modes that are visible in Smart Bike Lights, do they work if you press on the buttons with numbers (2, 4, 6, 7, 63)? If yes, does the tapped button become blue after the light mode is changed?

  • I tested it with both Smart Bike Lights and Bike Lights Control.
    Mode 2 is always highlighted in blue, and it never changes — pressing any other button doesn’t switch the light mode, and the blue highlight also doesn’t move to another button.

    The only thing that works is pressing OFF, which turns the light off, but even then, mode 2 stays highlighted in blue, and OFF doesn’t get highlighted either.
    After that, it’s also not possible to turn the light back on from the app — it stays off even if I switch between M and N again.

  • Can you provide me the configuration that you are using, so that I can hardcode it in the test data field, which you could sideload and test it

    Sure, I can test.

    Here one version (without remote):

    Page 1 (1# SmartBikeLights)

    #16384,90382865:1,2147483647:1:267911168,0#5,3!Night:2:51:60:0Es0,r0H]2!Day:2:0:60:0Er0,s0H]2!:1:0:0:0D=1#6291461,1409482753:0,889104606:1:#11,5!BreakD:3:1:5:0Er0,s0H]2A[-20!BreakN:3:5:5:0Es0,r0H]2A[-20!Day:2:8:60:0Er0,s0H]2!Night:2:63:60:0Es0,r0H]2!:1:0:0:0D=1#6,5:AT 1600:0:16777215:0!2,:-1,Off:0!1,Low  \n200lm-12h:51!1,Medium  \n 600lm-4h:52!1,High  \n1200lm-2h:53!1,:-2#6,5:Flare RT:0:16777215:0!2,:-1,Off:0!1,Night Flash  \n5lm-15h:63!1,Day Flash  \n45lm-12h:8!1,Night Steady  \n5lm-13.5h:5!1,Day Steady  \n25lm-4.5h:1#0::#0:0#123!:123!#0#0#B3843#14#1#0#0

    Page 2 (2# SmartBikeLights)

    ###0,73535488:1,1362494500:1:#7,3!CarD:3:7:5:0Er0,s0H]2I]-1]0!CarN:3:6:5:0Es0,r0H]2I]-1]0!:1:0:0:0D=1##6,5:Varia 515:0:16777215:0!2,:-1,Lights Off:0!1,Solid  \n20lm-6h:4!1,Peloton  \n8lm-8h:5!1,Day Flash  \n65lm-16h:7!1,Night Flash  \n29lm-6h:6#0::#0:0#123!:123!#0#0#B3843##3#0#0

    Thanks

  • Mode 2 is always highlighted in blue, and it never changes — pressing any other button doesn’t switch the light mode, and the blue highlight also doesn’t move to another button

    This means that also setMode api does not work for some reason.

    The last chance to make the light controllable via Smart Bike Lights would be to use Individual Light Network. Try do do the following:

    1. In the Garmin Sensors menu, find and write down the device id of the light

    2. Unpair the light from the Garmin Lights menu

    3.  Change value 99999 to the device id (from step 1) in the below configuration and set it in “Lights Configuration” app setting:

    #::1:####5,5::0:16777215:-1!1,2:2!1,4:4!1,6:6!1,7:7!1,63:63##1:99999:#0:0#123!:123!#0#0#B4062#99##0#0

    4. Start Smart Bike Lights and see if it works

  • I created a test version for Page 1 (AT1600 + Flare RT):
    https://github.com/maca88/SmartBikeLights/blob/test/retry-setmode/Build/Edge1040/SmartBikeLights.prg

    You need to put the file into /Garmin/Apps folder on Edge. The data field is named "Smart Bike Lights T" to distinguish it from the current one.

  • In “offline” mode, the light has the following modes in this order:

    • Steady 100%

    • Steady 75% (2)

    • Steady 50% (4)

    • Flashing fast with changing intensity (7)

    • Flashing (6)

    • Flashing slow

    It looks like the Individual Light Network works correctly — the button highlighting changes and the light responds by switching modes.

    However, only the following buttons are available in the app:

    • (2) – Steady 75%

    • (4) – Steady 50%

    • (6) – Flashing

    • (7) – Flashing fast with changing intensity

    • (63) – No effect

    I assume it’s not possible to also add the Steady 100% and Slow Flashing modes?

  • I assume it’s not possible to also add the Steady 100% and Slow Flashing modes?

    The configuration that I provided did include only the modes that were reported by the light. An alternative way to find the missing modes would be to put additional modes and see which will be selected when traversing through modes with the physical button. The following configuration does contain a lot more modes and are meant only to find the missing ones:

    #::1:-65536,1022####26,13::0:16777215:-1!2,Off:0,1:1!2,2:2,3:3!2,4:4,5:5!2,6:6,7:7!2,8:8,9:9!2,48:48,49:49!2,50:50,51:51!2,52:52,53:53!2,54:54,55:55!2,56:56,57:57!2,58:58,59:59!2,60:60,61:61!2,62:62,63:63##1:99999:#0:0#123!:123!#0#0#B3843#99##0#0

    You have to replace 99999 as you did with the previous configuration before using it. I would recommend to go through the modes with the physical button and check which numbers will be selected. I am assuming that for Steady 100% will be 1 and for slow flashing will hopefully be a number between 48-62.

  • I tested the new configuration.

    Cycling through the modes using the physical button works, but the highlighting on the Edge doesn’t change while doing so.

    When testing all the modes directly from the Edge, only the following ones actually work: 2, 4, 6, and 7.
    Even mode 63, which the device reports, doesn’t do anything — the light doesn’t react at all.

    Mode 1 also works in a way, but it’s not 100% brightness — it looks identical to mode 2.
    And it’s definitely not just an impression: when cycling through the modes with the button, you can clearly see the brightness drop at mode 2, so mode 1 is not functional as true full brightness.

     

  • but the highlighting on the Edge doesn’t change while doing so.

    This is an issue that Ravemen has to fix. They have to update the emitting light mode also when the mode is changed via the physical button. Without this, we won't be able to get the missing modes, even with the updated LightTester that I planned to do. Have you tried to tap on each button on the screen (48-62), so see if the missing light modes are hidden there?  

    Mode 1 also works in a way, but it’s not 100% brightness — it looks identical to mode 2.

    Mode 1 should represent 100% brightness according to the ANT+ Lights profile, so that is another bug that Ravemen has to fix.