Here’s my code (as you can see, there is lot of repetition) Hope it helps
type: picture-elements
elements:
- type: state-badge
entity: sensor.0x286d97000100f3af_temperature
style:
top: 38%
left: 9%
card_mod:
style: |
:host
{
color: transparent;
--label-badge-text-color:
{%- macro interpolate(temp, start, stop) -%}
{%- set (start_temp, start_color) = start -%}
{%- set (stop_temp, stop_color) = stop -%}
{%- set (start_r, start_g, start_b) = (int(start_color[0:2], base=16), int(start_color[2:4], base=16), int(start_color[4:6], base=16)) -%}
{%- set (stop_r, stop_g, stop_b) = (int(stop_color[0:2], base=16), int(stop_color[2:4], base=16), int(stop_color[4:6], base=16)) -%}
{%- set s = ((temp - start_temp)/(stop_temp - start_temp)) -%}
{# some channels might be negative; most browsers are probably tolerant, but in case not #}
{%- set r = max(int(start_r + s*(stop_r - start_r)), 0) -%}
{%- set g = max(int(start_g + s*(stop_g - start_g)), 0) -%}
{%- set b = max(int(start_b + s*(stop_b - start_b)), 0) -%}
rgb({{ r }}, {{ g }}, {{ b }});
{%- endmacro -%}
{%- set temp = states(config.entity) | float(0) -%}
{%- set temp_map = {
5: "3498db",
16: "70a03c",
19: "ff9800",
24: "e74c3c"
} -%}
{%- set keys = temp_map | sort -%}
{%- set index = keys | select("lt", temp) | list | length -%}
{%- if index == 0 -%}
#{{ temp_map[keys | first] }}
{%- elif index == keys | length -%}
#{{ temp_map[keys | last] }}
{%- else -%}
{%- set start = (keys[index - 2], temp_map[keys[index - 2]]) -%}
{%- set stop = (keys[index - 1], temp_map[keys[index - 1]]) -%}
{{ interpolate(temp, start, stop) }}
{%- endif -%}
}
.: |
color: transparent
- type: state-badge
entity: sensor.kitchen_radiator_temperature
style:
top: 50%
left: 9%
card_mod:
style: |
:host {
color: transparent;
--label-badge-text-color:
{%- macro interpolate(temp, start, stop) -%}
{%- set (start_temp, start_color) = start -%}
{%- set (stop_temp, stop_color) = stop -%}
{%- set (start_r, start_g, start_b) = (int(start_color[0:2], base=16), int(start_color[2:4], base=16), int(start_color[4:6], base=16)) -%}
{%- set (stop_r, stop_g, stop_b) = (int(stop_color[0:2], base=16), int(stop_color[2:4], base=16), int(stop_color[4:6], base=16)) -%}
{%- set s = ((temp - start_temp)/(stop_temp - start_temp)) -%}
{# some channels might be negative; most browsers are probably tolerant, but in case not #}
{%- set r = max(int(start_r + s*(stop_r - start_r)), 0) -%}
{%- set g = max(int(start_g + s*(stop_g - start_g)), 0) -%}
{%- set b = max(int(start_b + s*(stop_b - start_b)), 0) -%}
rgb({{ r }}, {{ g }}, {{ b }});
{%- endmacro -%}
{%- set temp = states(config.entity) | float(0) -%}
{%- set temp_map = {
5: "3498db",
16: "70a03c",
19: "ff9800",
24: "e74c3c"
} -%}
{%- set keys = temp_map | sort -%}
{%- set index = keys | select("lt", temp) | list | length -%}
{%- if index == 0 -%}
#{{ temp_map[keys | first] }}
{%- elif index == keys | length -%}
#{{ temp_map[keys | last] }}
{%- else -%}
{%- set start = (keys[index - 2], temp_map[keys[index - 2]]) -%}
{%- set stop = (keys[index - 1], temp_map[keys[index - 1]]) -%}
{{ interpolate(temp, start, stop) }}
{%- endif -%}
}
- type: state-badge
entity: sensor.utility_room_temperature_temperature
style:
top: 55%
left: 20%
card_mod:
style: |
:host {
color: transparent;
--label-badge-text-color:
{%- macro interpolate(temp, start, stop) -%}
{%- set (start_temp, start_color) = start -%}
{%- set (stop_temp, stop_color) = stop -%}
{%- set (start_r, start_g, start_b) = (int(start_color[0:2], base=16), int(start_color[2:4], base=16), int(start_color[4:6], base=16)) -%}
{%- set (stop_r, stop_g, stop_b) = (int(stop_color[0:2], base=16), int(stop_color[2:4], base=16), int(stop_color[4:6], base=16)) -%}
{%- set s = ((temp - start_temp)/(stop_temp - start_temp)) -%}
{# some channels might be negative; most browsers are probably tolerant, but in case not #}
{%- set r = max(int(start_r + s*(stop_r - start_r)), 0) -%}
{%- set g = max(int(start_g + s*(stop_g - start_g)), 0) -%}
{%- set b = max(int(start_b + s*(stop_b - start_b)), 0) -%}
rgb({{ r }}, {{ g }}, {{ b }});
{%- endmacro -%}
{%- set temp = states(config.entity) | float(0) -%}
{%- set temp_map = {
5: "3498db",
16: "70a03c",
19: "ff9800",
24: "e74c3c"
} -%}
{%- set keys = temp_map | sort -%}
{%- set index = keys | select("lt", temp) | list | length -%}
{%- if index == 0 -%}
#{{ temp_map[keys | first] }}
{%- elif index == keys | length -%}
#{{ temp_map[keys | last] }}
{%- else -%}
{%- set start = (keys[index - 2], temp_map[keys[index - 2]]) -%}
{%- set stop = (keys[index - 1], temp_map[keys[index - 1]]) -%}
{{ interpolate(temp, start, stop) }}
{%- endif -%}
}
- type: state-badge
entity: sensor.hallway_current_temperature
style:
top: 70%
left: 9%
card_mod:
style: |
:host {
color: transparent;
--label-badge-text-color:
{%- macro interpolate(temp, start, stop) -%}
{%- set (start_temp, start_color) = start -%}
{%- set (stop_temp, stop_color) = stop -%}
{%- set (start_r, start_g, start_b) = (int(start_color[0:2], base=16), int(start_color[2:4], base=16), int(start_color[4:6], base=16)) -%}
{%- set (stop_r, stop_g, stop_b) = (int(stop_color[0:2], base=16), int(stop_color[2:4], base=16), int(stop_color[4:6], base=16)) -%}
{%- set s = ((temp - start_temp)/(stop_temp - start_temp)) -%}
{# some channels might be negative; most browsers are probably tolerant, but in case not #}
{%- set r = max(int(start_r + s*(stop_r - start_r)), 0) -%}
{%- set g = max(int(start_g + s*(stop_g - start_g)), 0) -%}
{%- set b = max(int(start_b + s*(stop_b - start_b)), 0) -%}
rgb({{ r }}, {{ g }}, {{ b }});
{%- endmacro -%}
{%- set temp = states(config.entity) | float(0) -%}
{%- set temp_map = {
5: "3498db",
16: "70a03c",
19: "ff9800",
24: "e74c3c"
} -%}
{%- set keys = temp_map | sort -%}
{%- set index = keys | select("lt", temp) | list | length -%}
{%- if index == 0 -%}
#{{ temp_map[keys | first] }}
{%- elif index == keys | length -%}
#{{ temp_map[keys | last] }}
{%- else -%}
{%- set start = (keys[index - 2], temp_map[keys[index - 2]]) -%}
{%- set stop = (keys[index - 1], temp_map[keys[index - 1]]) -%}
{{ interpolate(temp, start, stop) }}
{%- endif -%}
}
- type: state-badge
entity: sensor.conservatory_door_temperature
style:
top: 20%
left: 20%
card_mod:
style: |
:host {
color: transparent;
--label-badge-text-color:
{%- macro interpolate(temp, start, stop) -%}
{%- set (start_temp, start_color) = start -%}
{%- set (stop_temp, stop_color) = stop -%}
{%- set (start_r, start_g, start_b) = (int(start_color[0:2], base=16), int(start_color[2:4], base=16), int(start_color[4:6], base=16)) -%}
{%- set (stop_r, stop_g, stop_b) = (int(stop_color[0:2], base=16), int(stop_color[2:4], base=16), int(stop_color[4:6], base=16)) -%}
{%- set s = ((temp - start_temp)/(stop_temp - start_temp)) -%}
{# some channels might be negative; most browsers are probably tolerant, but in case not #}
{%- set r = max(int(start_r + s*(stop_r - start_r)), 0) -%}
{%- set g = max(int(start_g + s*(stop_g - start_g)), 0) -%}
{%- set b = max(int(start_b + s*(stop_b - start_b)), 0) -%}
rgb({{ r }}, {{ g }}, {{ b }});
{%- endmacro -%}
{%- set temp = states(config.entity) | float(0) -%}
{%- set temp_map = {
5: "3498db",
16: "70a03c",
19: "ff9800",
24: "e74c3c"
} -%}
{%- set keys = temp_map | sort -%}
{%- set index = keys | select("lt", temp) | list | length -%}
{%- if index == 0 -%}
#{{ temp_map[keys | first] }}
{%- elif index == keys | length -%}
#{{ temp_map[keys | last] }}
{%- else -%}
{%- set start = (keys[index - 2], temp_map[keys[index - 2]]) -%}
{%- set stop = (keys[index - 1], temp_map[keys[index - 1]]) -%}
{{ interpolate(temp, start, stop) }}
{%- endif -%}
}
- type: state-badge
entity: sensor.front_room_temperature
style:
top: 70%
left: 20%
card_mod:
style: |
:host {
color: transparent;
--label-badge-text-color:
{%- macro interpolate(temp, start, stop) -%}
{%- set (start_temp, start_color) = start -%}
{%- set (stop_temp, stop_color) = stop -%}
{%- set (start_r, start_g, start_b) = (int(start_color[0:2], base=16), int(start_color[2:4], base=16), int(start_color[4:6], base=16)) -%}
{%- set (stop_r, stop_g, stop_b) = (int(stop_color[0:2], base=16), int(stop_color[2:4], base=16), int(stop_color[4:6], base=16)) -%}
{%- set s = ((temp - start_temp)/(stop_temp - start_temp)) -%}
{# some channels might be negative; most browsers are probably tolerant, but in case not #}
{%- set r = max(int(start_r + s*(stop_r - start_r)), 0) -%}
{%- set g = max(int(start_g + s*(stop_g - start_g)), 0) -%}
{%- set b = max(int(start_b + s*(stop_b - start_b)), 0) -%}
rgb({{ r }}, {{ g }}, {{ b }});
{%- endmacro -%}
{%- set temp = states(config.entity) | float(0) -%}
{%- set temp_map = {
5: "3498db",
16: "70a03c",
19: "ff9800",
24: "e74c3c"
} -%}
{%- set keys = temp_map | sort -%}
{%- set index = keys | select("lt", temp) | list | length -%}
{%- if index == 0 -%}
#{{ temp_map[keys | first] }}
{%- elif index == keys | length -%}
#{{ temp_map[keys | last] }}
{%- else -%}
{%- set start = (keys[index - 2], temp_map[keys[index - 2]]) -%}
{%- set stop = (keys[index - 1], temp_map[keys[index - 1]]) -%}
{{ interpolate(temp, start, stop) }}
{%- endif -%}
}
- type: state-badge
entity: sensor.ellie_bedroom_temperature_temperature
style:
top: 20%
left: 70%
card_mod:
style: |
:host {
color: transparent;
--label-badge-text-color:
{%- macro interpolate(temp, start, stop) -%}
{%- set (start_temp, start_color) = start -%}
{%- set (stop_temp, stop_color) = stop -%}
{%- set (start_r, start_g, start_b) = (int(start_color[0:2], base=16), int(start_color[2:4], base=16), int(start_color[4:6], base=16)) -%}
{%- set (stop_r, stop_g, stop_b) = (int(stop_color[0:2], base=16), int(stop_color[2:4], base=16), int(stop_color[4:6], base=16)) -%}
{%- set s = ((temp - start_temp)/(stop_temp - start_temp)) -%}
{# some channels might be negative; most browsers are probably tolerant, but in case not #}
{%- set r = max(int(start_r + s*(stop_r - start_r)), 0) -%}
{%- set g = max(int(start_g + s*(stop_g - start_g)), 0) -%}
{%- set b = max(int(start_b + s*(stop_b - start_b)), 0) -%}
rgb({{ r }}, {{ g }}, {{ b }});
{%- endmacro -%}
{%- set temp = states(config.entity) | float(0) -%}
{%- set temp_map = {
5: "3498db",
16: "70a03c",
19: "ff9800",
24: "e74c3c"
} -%}
{%- set keys = temp_map | sort -%}
{%- set index = keys | select("lt", temp) | list | length -%}
{%- if index == 0 -%}
#{{ temp_map[keys | first] }}
{%- elif index == keys | length -%}
#{{ temp_map[keys | last] }}
{%- else -%}
{%- set start = (keys[index - 2], temp_map[keys[index - 2]]) -%}
{%- set stop = (keys[index - 1], temp_map[keys[index - 1]]) -%}
{{ interpolate(temp, start, stop) }}
{%- endif -%}
}
- type: state-badge
entity: sensor.office_radiator_temperature
style:
top: 21%
left: 58%
card_mod:
style: |
:host {
color: transparent;
--label-badge-text-color:
{%- macro interpolate(temp, start, stop) -%}
{%- set (start_temp, start_color) = start -%}
{%- set (stop_temp, stop_color) = stop -%}
{%- set (start_r, start_g, start_b) = (int(start_color[0:2], base=16), int(start_color[2:4], base=16), int(start_color[4:6], base=16)) -%}
{%- set (stop_r, stop_g, stop_b) = (int(stop_color[0:2], base=16), int(stop_color[2:4], base=16), int(stop_color[4:6], base=16)) -%}
{%- set s = ((temp - start_temp)/(stop_temp - start_temp)) -%}
{# some channels might be negative; most browsers are probably tolerant, but in case not #}
{%- set r = max(int(start_r + s*(stop_r - start_r)), 0) -%}
{%- set g = max(int(start_g + s*(stop_g - start_g)), 0) -%}
{%- set b = max(int(start_b + s*(stop_b - start_b)), 0) -%}
rgb({{ r }}, {{ g }}, {{ b }});
{%- endmacro -%}
{%- set temp = states(config.entity) | float(0) -%}
{%- set temp_map = {
5: "3498db",
16: "70a03c",
19: "ff9800",
24: "e74c3c"
} -%}
{%- set keys = temp_map | sort -%}
{%- set index = keys | select("lt", temp) | list | length -%}
{%- if index == 0 -%}
#{{ temp_map[keys | first] }}
{%- elif index == keys | length -%}
#{{ temp_map[keys | last] }}
{%- else -%}
{%- set start = (keys[index - 2], temp_map[keys[index - 2]]) -%}
{%- set stop = (keys[index - 1], temp_map[keys[index - 1]]) -%}
{{ interpolate(temp, start, stop) }}
{%- endif -%}
}
- type: state-badge
entity: sensor.isobel_bedroom_temperature_temperature
style:
top: 60%
left: 67%
card_mod:
style: |
:host {
color: transparent;
--label-badge-text-color:
{%- macro interpolate(temp, start, stop) -%}
{%- set (start_temp, start_color) = start -%}
{%- set (stop_temp, stop_color) = stop -%}
{%- set (start_r, start_g, start_b) = (int(start_color[0:2], base=16), int(start_color[2:4], base=16), int(start_color[4:6], base=16)) -%}
{%- set (stop_r, stop_g, stop_b) = (int(stop_color[0:2], base=16), int(stop_color[2:4], base=16), int(stop_color[4:6], base=16)) -%}
{%- set s = ((temp - start_temp)/(stop_temp - start_temp)) -%}
{# some channels might be negative; most browsers are probably tolerant, but in case not #}
{%- set r = max(int(start_r + s*(stop_r - start_r)), 0) -%}
{%- set g = max(int(start_g + s*(stop_g - start_g)), 0) -%}
{%- set b = max(int(start_b + s*(stop_b - start_b)), 0) -%}
rgb({{ r }}, {{ g }}, {{ b }});
{%- endmacro -%}
{%- set temp = states(config.entity) | float(0) -%}
{%- set temp_map = {
5: "3498db",
16: "70a03c",
19: "ff9800",
24: "e74c3c"
} -%}
{%- set keys = temp_map | sort -%}
{%- set index = keys | select("lt", temp) | list | length -%}
{%- if index == 0 -%}
#{{ temp_map[keys | first] }}
{%- elif index == keys | length -%}
#{{ temp_map[keys | last] }}
{%- else -%}
{%- set start = (keys[index - 2], temp_map[keys[index - 2]]) -%}
{%- set stop = (keys[index - 1], temp_map[keys[index - 1]]) -%}
{{ interpolate(temp, start, stop) }}
{%- endif -%}
}
- type: state-badge
entity: sensor.bedroom_motion_temperature
style:
top: 25%
left: 88%
card_mod:
style: |
:host {
color: transparent;
--label-badge-text-color:
{%- macro interpolate(temp, start, stop) -%}
{%- set (start_temp, start_color) = start -%}
{%- set (stop_temp, stop_color) = stop -%}
{%- set (start_r, start_g, start_b) = (int(start_color[0:2], base=16), int(start_color[2:4], base=16), int(start_color[4:6], base=16)) -%}
{%- set (stop_r, stop_g, stop_b) = (int(stop_color[0:2], base=16), int(stop_color[2:4], base=16), int(stop_color[4:6], base=16)) -%}
{%- set s = ((temp - start_temp)/(stop_temp - start_temp)) -%}
{# some channels might be negative; most browsers are probably tolerant, but in case not #}
{%- set r = max(int(start_r + s*(stop_r - start_r)), 0) -%}
{%- set g = max(int(start_g + s*(stop_g - start_g)), 0) -%}
{%- set b = max(int(start_b + s*(stop_b - start_b)), 0) -%}
rgb({{ r }}, {{ g }}, {{ b }});
{%- endmacro -%}
{%- set temp = states(config.entity) | float(0) -%}
{%- set temp_map = {
5: "3498db",
16: "70a03c",
19: "ff9800",
24: "e74c3c"
} -%}
{%- set keys = temp_map | sort -%}
{%- set index = keys | select("lt", temp) | list | length -%}
{%- if index == 0 -%}
#{{ temp_map[keys | first] }}
{%- elif index == keys | length -%}
#{{ temp_map[keys | last] }}
{%- else -%}
{%- set start = (keys[index - 2], temp_map[keys[index - 2]]) -%}
{%- set stop = (keys[index - 1], temp_map[keys[index - 1]]) -%}
{{ interpolate(temp, start, stop) }}
{%- endif -%}
}
- type: state-badge
entity: sensor.ensuite_temperature_temperature
style:
top: 40%
left: 85%
card_mod:
style: |
:host {
color: transparent;
--label-badge-text-color:
{%- macro interpolate(temp, start, stop) -%}
{%- set (start_temp, start_color) = start -%}
{%- set (stop_temp, stop_color) = stop -%}
{%- set (start_r, start_g, start_b) = (int(start_color[0:2], base=16), int(start_color[2:4], base=16), int(start_color[4:6], base=16)) -%}
{%- set (stop_r, stop_g, stop_b) = (int(stop_color[0:2], base=16), int(stop_color[2:4], base=16), int(stop_color[4:6], base=16)) -%}
{%- set s = ((temp - start_temp)/(stop_temp - start_temp)) -%}
{# some channels might be negative; most browsers are probably tolerant, but in case not #}
{%- set r = max(int(start_r + s*(stop_r - start_r)), 0) -%}
{%- set g = max(int(start_g + s*(stop_g - start_g)), 0) -%}
{%- set b = max(int(start_b + s*(stop_b - start_b)), 0) -%}
rgb({{ r }}, {{ g }}, {{ b }});
{%- endmacro -%}
{%- set temp = states(config.entity) | float(0) -%}
{%- set temp_map = {
5: "3498db",
16: "70a03c",
19: "ff9800",
24: "e74c3c"
} -%}
{%- set keys = temp_map | sort -%}
{%- set index = keys | select("lt", temp) | list | length -%}
{%- if index == 0 -%}
#{{ temp_map[keys | first] }}
{%- elif index == keys | length -%}
#{{ temp_map[keys | last] }}
{%- else -%}
{%- set start = (keys[index - 2], temp_map[keys[index - 2]]) -%}
{%- set stop = (keys[index - 1], temp_map[keys[index - 1]]) -%}
{{ interpolate(temp, start, stop) }}
{%- endif -%}
}
- type: state-badge
entity: sensor.lounge_motion_temperature
style:
top: 47%
left: 36%
card_mod:
style: |
:host {
color: transparent;
--label-badge-text-color:
{%- macro interpolate(temp, start, stop) -%}
{%- set (start_temp, start_color) = start -%}
{%- set (stop_temp, stop_color) = stop -%}
{%- set (start_r, start_g, start_b) = (int(start_color[0:2], base=16), int(start_color[2:4], base=16), int(start_color[4:6], base=16)) -%}
{%- set (stop_r, stop_g, stop_b) = (int(stop_color[0:2], base=16), int(stop_color[2:4], base=16), int(stop_color[4:6], base=16)) -%}
{%- set s = ((temp - start_temp)/(stop_temp - start_temp)) -%}
{# some channels might be negative; most browsers are probably tolerant, but in case not #}
{%- set r = max(int(start_r + s*(stop_r - start_r)), 0) -%}
{%- set g = max(int(start_g + s*(stop_g - start_g)), 0) -%}
{%- set b = max(int(start_b + s*(stop_b - start_b)), 0) -%}
rgb({{ r }}, {{ g }}, {{ b }});
{%- endmacro -%}
{%- set temp = states(config.entity) | float(0) -%}
{%- set temp_map = {
5: "3498db",
16: "70a03c",
19: "ff9800",
24: "e74c3c"
} -%}
{%- set keys = temp_map | sort -%}
{%- set index = keys | select("lt", temp) | list | length -%}
{%- if index == 0 -%}
#{{ temp_map[keys | first] }}
{%- elif index == keys | length -%}
#{{ temp_map[keys | last] }}
{%- else -%}
{%- set start = (keys[index - 2], temp_map[keys[index - 2]]) -%}
{%- set stop = (keys[index - 1], temp_map[keys[index - 1]]) -%}
{{ interpolate(temp, start, stop) }}
{%- endif -%}
}
image: /local/floorplan.png