Create a New Sensor with New entity in Home Assistant

Hello,

I have recently started with Home assistant and got stuck with a use case.

The flow I am imagining is: when any bluetooth device is connected to my phone (smart band, headphone,etc.) if any of them has low battery a notification will be added to my home assistant.

The way I thought I would accomplish this is:

  1. Use automate in phone to get bluetooth battery %of connected device - done
  2. Send this via a http request to Home assistant - not done
  3. Update a sensor to store the device name and battery % - not done
  4. Show some notification - not done

Now I am stuck at creating a sensor, I followed some example and created one:

  - platform: template
    sensors:
      random_number:
        friendly_name: "Bluetooth Battery"
        value_template: >-
          {% if is_state('sun.sun', 'above_horizon') %}
            Charge
          {% else %}
            Don't Charge
          {% endif %}

But I am not getting how to use a new entity and store the bluetooth device name and battery %. sun.sun is a preexisting entity.

I know this is basic and I am missing something pretty obvious, but any guidance is appreciated.

can you post this automation?

There is a flow from the community called BlueBatt, I am using that one. Just note not all device broadcast their battery status. It won’t work for those. The last HTTP part is mine.

Ok, so what does the last step do? That’s the info i’m looking for. Post the http request please.