Hi all,
I’m using the custom graph card and in each of the cards I often have the same variable a number of times, and this is a pain to update.
I’d like to set a variable at the top of the card ‘this_sensor’, and have here the entity once, then use this_sensor elsewhere in the card so I only change the entity once - i hope that makes sense!
Here is my code (note this works, if I just put the entity int he three places, but this is what I want to avoid)
Yes I second this. I have, for example, temperature and battery card entities that change color and/or icon depending on state. Updating and modifying is very time consuming. A variable would make life so much easier.
Cheers
I have a solution. Not sure if this is exactly what you want but nonetheless here it is.
The code I show here is for the first sensor shown in the image at the bottom. The others are the same except for the entity so I don’t bother to include all the redundant code.
I use
{% set sentity = "sensor.aqara_01_battery" %}
in the style section to define the entity variable that can be used for all the formatting.