So yesterday I fiddled with my picture-elements and with help from here (thanks), managed to get my custom-ui mods replaced by card-mod. One of the most difficult (for me) was my baseboard heaters and this is the code I got working:
- entity: climate.neviweb130_climate_martin
type: image
image: /local/heat-0.png
card_mod:
style:
hui-image $: |
#image {
{% set power = state_attr(config.entity, 'heat_level')|int(0) %}
{% if power < 1 %}
content: url(/local/heat-0.png)
{% elif power < 21 %}
content: url(/local/heat-1.png)
{% elif power < 41 %}
content: url(/local/heat-2.png)
{% elif power < 61 %}
content: url(/local/heat-3.png)
{% elif power < 81 %}
content: url(/local/heat-4.png)
{% else %}
content: url(/local/heat-5.png)
{% endif %};
}
style:
left: 50%
top: 20%
transform: translate(-50%,-50%) scale(0.25, 0.25)
Now I’m trying to do the same through a simple Entities card and of course, it can’t be as easy as a copy paste. This is what I currently have and it’s not working. The image never change to show the power delivered by the baseboard. I had to remove type:image otherwise it would generate an error.
- entity: climate.neviweb130_climate_martin
image: /local/heat-0.png
card_mod:
style:
hui-image $: |
#image {
{% set power = state_attr(config.entity, 'heat_level')|int(0) %}
{% if power < 1 %}
content: url(/local/heat-0.png)
{% elif power < 21 %}
content: url(/local/heat-1.png)
{% elif power < 41 %}
content: url(/local/heat-2.png)
{% elif power < 61 %}
content: url(/local/heat-3.png)
{% elif power < 81 %}
content: url(/local/heat-4.png)
{% else %}
content: url(/local/heat-5.png)
{% endif %};
}
I finally got further. Went through a deep rabbit hole but turns out it’s simpler than I expect. I still have to template it but at least now, I can show the image I want, except, the icon is still drawn, although I’m telling to NOT display it.
Note that any card-mod styling has a transition which is more or less visible. And in some cases the same can be achieved by using other methods like “external JS” or simply creating a template sensor with a dynamic entity_picture.
Check your screenshot , the inner ha-state-icon element is located under state-badge - but also inside a so called shadow root.
The shadow root in cardmod is presented as “$”.
To better understand how it works, go to the main cardmod thread - 1st post - fantastic link at the bottom, it will lead to lo a list of tutorials and examples.
Might be useful.
Of course in case if you are ready to learn ))).