I’m working on a floorplan front end and wondering if there is a way to use ‘entity’ as a variable. Here is part of my code:
- type: image
entity: binary_sensor.living_room_window_1
image: /local/floorplan/images/transparent.png
tap_action:
action: more-info
style:
width: 3%
left: 77%
top: 66%
transform: rotate(0deg) scale(.3, 1.1)
card_mod:
style: |
:host {
background:
{% if states('binary_sensor.living_room_window_1') == 'on' %}
red
{% elif states('binary_sensor.living_room_window_1') == 'off' %}
green
{% else %}
yellow
{% endif %}
;
border: 1px solid black;
opacity: 0.5;
}
I’m not certain, but I think the ‘if’ statements would be considered a template. What I want to do is say if (states.entity) == … or if state. {{ entity }}…so that I can just define the entity above, once, (entity: binary_sensor.living_room_window_1). and then just pass that into the if statements. That way I can change the entity for each of these blocks of code once, instead of in 3 places. I hope that makes sense. Is that possible or is there a better way? And am I correct in calling that a template? Thanks!