Jabra Earbud Battery percentage in Home Assistant

I spent a little while on this so wanted to share my experience and results. I have been looking for a way to report on my Earbud battery status so I can create some notifications reminding me when to charge them. I initially looked at using the Android Intent of BT_BATTERY_CHANGED but found that this is reporting as a whole the battery life of both ear buds and the case into a single percentage and wasn’t acurate.

The Jabra Earbuds use an Android app which has a persistent notification sharing the battery percentage of each ear bud and the case.

I ended up using the Companion app to enable the last_notification sensor and whitelist the Sound+ (Jabra) app.

I was then able to see the percentages within Home Assistant but was a singgle line of text with other useless information.

I tried just creating sensors using templates which worked initially but I found that when I put my earbuds back into their case the notification would change to “Saving Device Location” and would stuff up my sensor templates showing unavailable instead of the last percentage.

I found a work around by using Template sensors with Trigger templates and below is the yaml I’m using.

I have no idea if this is the most efficient or best practice and welcome any feedback.
In this example cph2145 is my phone.

template:
  - trigger:
      - platform: template
        value_template: "{% if 'Battery' in states('sensor.cph2145_last_notification') %}true{% endif %}"
    sensor:
      - name: 'Earbud Right'
        unit_of_measurement: '%'
        state: >
          {{ states.sensor.cph2145_last_notification.state | regex_findall_index('Right: (\d+)') }}
        device_class: battery
  - trigger:
      - platform: template
        value_template: "{% if 'Battery' in states('sensor.cph2145_last_notification') %}true{% endif %}"
    sensor:
      - name: 'Earbud Left'
        unit_of_measurement: '%'
        state: >
          {{ states.sensor.cph2145_last_notification.state | regex_findall_index('Left: (\d+)') }}
        device_class: battery
  - trigger:
      - platform: template
        value_template: "{% if 'Battery' in states('sensor.cph2145_last_notification') %}true{% endif %}"
    sensor:
      - name: 'Earbud Case'
        unit_of_measurement: '%'
        state: >
          {{ states.sensor.cph2145_last_notification.state | regex_findall_index('Case: (\d+)') }}
        device_class: battery
1 Like

where in the Companion app do you “whitelist” that app?

Great Job mate.

Whoa… I found it… Thx

@bluesparrow is this still working for you?

After whitelisting the Jabra app (sound+), this is what I’m getting feeding through to HA - nothing to do with battery levels.

The notification in Android does report the battery levels as expected (Left, right, case).

What have I done wrong?

Thank you