Is it possible to set an entity name as an var and use it in template. I got an card it already partially templated but want to move the rest over to the template side, because all the setting is the same with the exception of entity name.
############## Picture Element Main Light Entities ##############
- type: "custom:button-card"
entity: light.hall_way_walkway
template: light_element_button
style:
left: 54.5%
top: 33%
######### want to move this section into template #########
entity_picture: |
[[[
if (states['light.hall_way_walkway'].state == 'off')
return "/local/photos/lovelace_photos/general/recessed_light_off.png";
return "/local/photos/lovelace_photos/general/recessed_light_on.png";
]]]
custom_fields:
light_bri: |
[[[
var bri = states['light.hall_way_walkway'].attributes.brightness;
if (bri > 0)
return Math.floor(bri/255 * 100) + '%';
return
]]]
######### want to move this section into template #########
############## Button Card Template ##############
##### main light button
light_element_button:
hold_action:
action: more-info
show_entity_picture: true
show_name: false
styles:
grid:
- position: relative
entity_picture:
- width: 21px
custom_fields:
light_bri:
- position: absolute
- height: 21px
- width: 21px
- font-size: 8px
- line-height: 21px
- align-self: middle
- justify-self: start
- color: 'red'