which returns just the name of the device that has the lowest battery level. e.g. “sensor.temperature_outside_battery”. However, I want that card Title to also list that device’s ‘battery_level’. I tried this non-working solution
{{ state_attr(‘sensor.battery’, ‘min_entity_id’) }} is at {{ state_attr('{{ state_attr(‘sensor.battery’, ‘min_entity_id’) }}, ‘battery_level’) }}%
I have run out of ideas, and am unsure if this is even possible. If not, is there some other way to get this information onto the Dashboard? If the answer is making a template, would you kindly post the actual code, as I am an eager newbie to coding. Thank you.
You are trying to display attributes of sensor.battery . Does this sensor provide the attributes you want to display?
You refer to a blueprint that sends a notification. How is this related to your sensor sensor.battery ?
and it returns the name of the device with the lowest battery level. What I am hoping is for a way that I can insert that result (lets call that code string “X”) into
I can’t follow. The blueprint is an automation and everything it does is to send a notification with a list of sensors that are below the given threshold.
@pedolsky I am not good at coding, so you may want to ask Sbyx about how his Blueprint works. All I know is that it always returns only the device that has the lowest battery level, whichever device that may be. My specific question and my need is how to embed
I know how that blueprint works. That’s what I’m trying to explain you: The sensor you are using has nothing to do with that blueprint. That,s why I asked you to post the state attributes of your sensor.
I have dozens of sensors and have no way of knowing in advance which one will be deemed by the Blueprint to have the lowest battery level, so I don’t see how I can provide the state attributes for the sensor that has yet to have the lowest battery level. What I do know is that all of my sensors have the “battery_level” attribute, which is the one that I want. Can you help me get the code corrected version of
Ok. Seems to be a min/max sensor, created via UI helper?
Copy the following into Developer Tools/Template (or into your card):
{% set entity = 'sensor.battery' %}
{{ state_attr(entity, 'min_entity_id') }} is at {{ states(entity) }}%
I assume, it’s a Mushroom Title Card? If so, you can use the variable entity:
{{ entity.attributes.min_entity_id }} is at {{ entity.state }}%
Originally, you asked also for quantity and size. Are that actually attributes of the target battery sensor (e.g. sensor.temperature_furnace_closet_battery )?
@pedolsky First off, your a coding genius and THANK YOU for sharing your time and knowledge with me. This is the title of a simple “Entity card”. I did not realize that one can define and use a variable within a card title. I would like to also get quantity and size, so that I know which batteries will be needed, and those are attributes of this sensor. Even if other sensors do not support those attributes, I want to learn from your wisdom, so I tried
{% set entity = ‘sensor.battery’ %}
{{ state_attr(entity, ‘min_entity_id’) }} is at {{ states(entity) }}% and needs {{ state_attr(entity, ‘battery_quantity’) }} of {{ state_attr(entity, ‘battery_size’) }}
but that fails (likely obvious for you). What is the error of my logic?
Understood. Then I will consider this topic resolved and closed. Thank you for sharing your time and expertise. I hope to be in a position to pay it forward soon.