Bluetooth Battery Levels (Android)

Thanks for that, yes, now it started working and also the template sensor seems to work.
image

Hi, I tried adding my headphones. Even though I think everything’s fine, I’m getting these errors in HA. Is this due to something I entered incorrectly or the device I’m trying to add?

template:
  - trigger:
    - platform: "event"
      event_type: "android.intent_received"
      event_data:
      android.bluetooth.device.extra.DEVICE: "XX:XX:XX:XX:14:41"
      #android.bluetooth.device.extra.DEVICE: "B8:7B:D4:14:14:41"
      intent: "android.bluetooth.device.action.BATTERY_LEVEL_CHANGED"
  - sensor:
    - name: "Pixel Buds Pro Battery Level"
      unique_id: "3e23961f-e6e5-4cfd-ad86-8293f7cafb84"
      device_class: "battery"
      unit_of_measurement: "%"
      state_class: "measurement"
      availability: "{{ trigger.event['data']['android.bluetooth.device.extra.BATTERY_LEVEL'] != '-1' }}"
      state: "{{ trigger.event['data']['android.bluetooth.device.extra.BATTERY_LEVEL'] }}"
    - name: Template Sidebar
      unique_id: template_sidebar
      state: template
      attributes:
        time: >

It was misplaced. This is how it worked.

template:
  - trigger:
    - platform: "event"
      event_type: "android.intent_received"
      event_data:
        android.bluetooth.device.extra.DEVICE: "XX:XX:XX:XX:14:41"
        #android.bluetooth.device.extra.DEVICE: "B8:7B:D4:14:14:41"
        intent: "android.bluetooth.device.action.BATTERY_LEVEL_CHANGED"
    sensor:
    - name: "Pixel Buds Pro Battery Level"
      unique_id: "3e23961f-e6e5-4cfd-ad86-8293f7cafb84"
      device_class: "battery"
      unit_of_measurement: "%"
      state_class: "measurement"
      availability: "{{ trigger.event['data']['android.bluetooth.device.extra.BATTERY_LEVEL'] != '-1' }}"
      state: "{{ trigger.event['data']['android.bluetooth.device.extra.BATTERY_LEVEL'] }}"
  - sensor:
    - name: Template Sidebar
      unique_id: template_sidebar
      state: template
1 Like