Battery sensor of Laptop just like the Phone one From the App

I want to display the Battery sensor of my Laptop exactly like the one from my Phone. With the nice dynamic icon and everything.

Isn’t there a simple solution for this?
My solution works, but now I can not plot the sensor together with other sensors from the Phones.

To fix it by myself, I did the following:

  1. I created a new template sensor called inspiron_battery to display the battery level of the sensor.inspiron_battery_charge_remaining_percentage sensor as a percentage with an appropriate battery icon based on the battery level.
  2. I added an icon_template to the inspiron_battery sensor to change the icon based on the charging status of the Inspiron using the sensor.inspiron_battery_powerline_status sensor.
  3. Initially, the inspiron_battery sensor was missing the charging icon when the Inspiron was plugged in.
  4. I updated the icon_template to use different battery icons based on the battery level and charging status.
  - platform: template
    sensors:
      inspiron_battery:
        friendly_name: "Inspiron Battery"
        value_template: "{{ states('sensor.inspiron_battery_charge_remaining_percentage') }}%"
        device_class: battery
        icon_template: >-
          {% set battery_level = states('sensor.inspiron_battery_charge_remaining_percentage') | int %}
          {% set charging_status = states('sensor.inspiron_battery_powerline_status') %}
          {% if charging_status == 'Online' %}
            {% if battery_level == 100 %}
              mdi:battery-charging-100
            {% elif battery_level >= 95 %}
              mdi:battery-charging-90
            {% elif battery_level >= 85 %}
              mdi:battery-charging-80
            {% elif battery_level >= 75 %}
              mdi:battery-charging-70
            {% elif battery_level >= 65 %}
              mdi:battery-charging-60
            {% elif battery_level >= 55 %}
              mdi:battery-charging-50
            {% elif battery_level >= 45 %}
              mdi:battery-charging-40
            {% elif battery_level >= 35 %}
              mdi:battery-charging-30
            {% elif battery_level >= 25 %}
              mdi:battery-charging-20
            {% elif battery_level >= 15 %}
              mdi:battery-charging-10
            {% else %}
              mdi:battery-alert
            {% endif %}
          {% else %}
            {% if battery_level == 100 %}
              mdi:battery
            {% elif battery_level >= 95 %}
              mdi:battery-90
            {% elif battery_level >= 85 %}
              mdi:battery-80
            {% elif battery_level >= 75 %}
              mdi:battery-70
            {% elif battery_level >= 65 %}
              mdi:battery-60
            {% elif battery_level >= 55 %}
              mdi:battery-50
            {% elif battery_level >= 45 %}
              mdi:battery-40
            {% elif battery_level >= 35 %}
              mdi:battery-30
            {% elif battery_level >= 25 %}
              mdi:battery-20
            {% elif battery_level >= 15 %}
              mdi:battery-10
            {% else %}
              mdi:battery-alert
            {% endif %}
          {% endif %}

Remove the % from the end of your value_template and put it in a unit_of_measurement.

If you’re willing to remap your threshold values, you can use rounding to the nearest 10 to pick the right icon, barring an edge case or two, like for 100%.

I don’t really understand what you mean.

Also, how does the App do the battery integration? Where is the code? Can’t I just copy paste it?

Something like this:

      icon_template: >-
        {% set state = states('sensor.battery') | int(0) %}
        {% set charging = "-charging" if states('sensor.battery') == "Charging" else "" %}
        {% set suffix = (state // 10) * 10 %}
        {# empty #}
        {% if suffix == 0 %}
          mdi:battery{{ charging }}-outline
        {# full #}
        {% elif suffix == 100 %}
          {# choose the right full battery #}
          {% if charging != "" %}
            mdi:battery-charging-100
          {% else %}
            mdi:battery
          {% endif %}
        {# everything in between #}
        {% else %}
          mdi:battery{{ charging }}-{{ suffix }}
        {% endif %}