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
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
And my config.yaml
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)
My example source generates a entity named âsensor.my_battery_sensorâ. Did you include that in the UI?
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! :>)
Google âŚ
Youâre welcomeâŚ
Thank you so very much to all!!!