Change reporting value from Wi-Fi strength to battery

I have a ring alarm setup properly but I want one of my sensors to default reporting a battery value NOT wifi strength. Both are available when looking at the entity.

Any ideas how to make it show battery in Lovelace?

Thanks

Template sensor using the entity’s battery attribute:

# Example configuration.yaml entry
sensor:
  - platform: template
    sensors:
      my_battery_sensor:
        value_template: "{{ state_attr('sensor.my_entity','battery_attribute_name') | float }}"
        unit_of_measurement : 'V' 
        device_class: 'battery'

Hi I added that but my sensor.side_info still reports wifi strength;
Here is my entity:
Side Info sensor.side_info MQTT

Here are the Lovelace screen shot

Screen Shot 2021-02-18 at 9.59.14 AM

And my config.yaml

Example configuration.yaml entry

sensor:

  • platform: template

    sensors:

    my_battery_sensor:

    value_template: "{{ state_attr('sensor.side_info','battery_attribute_name') | float }}"
    
    unit_of_measurement : 'V' 
    
    device_class: 'battery'![Screen Shot 2021-02-18 at 10.07.21 AM|689x314](upload://jxk21raUZ0BsFlIRTECaE58ijS6.png)![Screen Shot 2021-02-18 at 10.01.56 AM|443x500](upload://iPQ2bAdMPPOelpx8T5TCgIQaYGo.png) ![Screen Shot 2021-02-18 at 9.59.14 AM|399x440](upload://rV36EvZWC7ZVePUPqE5AMiPSJMW.png)

And this is whats in the lovelace card

My example source generates a entity named “sensor.my_battery_sensor”. Did you include that in the UI?

I did now but it reports 0

I don’t think, that the entity’s battery attribute is name battery_attribute_name, that was just an example …

It looks like from the sensor info you posted you need to change the attribute to “BatteryLevel”?

And change the unit of measurement to percent (%) not volts (V).

sensor:
  - platform: template
    sensors:
      my_battery_sensor:
        value_template: "{{ state_attr('sensor.side_info','BatteryLevel') | float }}"
        unit_of_measurement : '%' 
        device_class: 'battery'

If it doesn’t work then check the info for both entity_id and the attribute for battery level in the states page and make them both match exactly in the template.

This is the info in Developer >stats of the sensor in question.
How would I get the proper attribute name?
Thanks

batteryLevel is the attribute name

It’s … “batteryLevel”, tadaaa! And it’s not voltage, but percentage. So finity was close (except for the capital ‘B’)

sensor:
  - platform: template
    sensors:
      my_battery_sensor:
        value_template: "{{ state_attr('sensor.side_info','batteryLevel') | float }}"
        unit_of_measurement : '%' 
        device_class: 'battery'

LOL, A quick Google and I changed it.
Thanks for the help. It now works! :>)
:ok_hand:

grafik

Google …

1 Like

You’re welcome…

Thank you so very much to all!!!

1 Like