Hi,
i made a custom svg washing machine icon and wanted to animate the water. For some reason as soon i apply any animation the water just disappears.
Here is my button card template icon
icon_waschmaschiene:
styles:
custom_fields:
icon:
- width: 100%
- fill: >
[[[
return (variables.state === 'on' || variables.state === 'playing') ? '#107b10' : '#9da0a2';
]]]
custom_fields:
icon: >
[[[
let state = variables.state === 'on' ? 'on' : null;
return `
<svg viewBox="0 0 250 250">
<style>
@keyframes on {
0% {
transform: rotate(0deg) translate(-1.5%, 0%);
}
100% {
transform: rotate(-360deg) translate(-1.5%, 0%);
}
}
@keyframes off {
0% {
transform: rotateY(-360deg) translate(-1.5%, 0%);
}
45% {
transform: rotateY(-40deg);
}
55% {
transform: rotateY(0deg);
}
65% {
transform: rotateY(-15deg);
}
75% {
transform: rotateY(0deg);
}
85% {
transform: rotateY(-5deg);
}
95% {
transform: rotateY(0deg);
}
}
.on {
transform-origin: 49% 60%;
animation: on 1s linear infinite;
animation-fill-mode: both;
animation-delay: 0s;
}
</style>
<svg viewBox="0 0 250 250">
<svg width="250" height="250" viewBox="0 0 250 250" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect class="{state}" width="150.88" height="207.1" rx="7.09" style="fill: #9ea0a2"/>
<circle id="b2de5806-67c9-4b5d-9fee-83d0f6dde951" data-name="AuswahlRad" cx="123.77" cy="13.28" r="6.17" style="fill: none;stroke: #000;stroke-miterlimit: 10"/>
<line y1="45.98" x2="33.21" y2="45.83" style="fill: none;stroke: #000;stroke-miterlimit: 10"/>
<path d="M7197.48,7140.75c-12.86-.39-19.87,2.29-23.95,5a53.17,53.17,0,0,1-10.91,5.87,52.42,52.42,0,0,1-7.38,2.27" transform="translate(-7122.03 -7108.03)" style="fill: none;stroke: #000;stroke-miterlimit: 10"/>
<line x1="151.04" y1="32.57" x2="75.44" y2="32.72" style="fill: none;stroke: #000;stroke-miterlimit: 10"/>
<line x1="51.14" x2="51.5" y2="37.7" style="fill: none;stroke: #000;stroke-miterlimit: 10"/>
<rect id="b53d26cb-9447-4261-93c3-e3f8a2d8288f" data-name="Display" x="56.33" y="7.05" width="42.32" height="15.67" style="fill: #0f0f0f"/>
<rect id="a092cc82-ad97-49f2-ab67-5a42acf72815" data-name="Filter" x="5.69" y="162.91" width="46.26" height="38.88" rx="4" style="fill: #d6d6d6"/>
<rect id="a05b31c1-989a-4f06-b836-d74b0ef7e89b" data-name="Waschmittel" x="70.17" y="162.91" width="75.49" height="38.88" rx="4" style="fill: #d6d6d6"/>
<path id="b72f9b3b-834a-4a30-a6c6-19655e543854" data-name="grauer rahmen" d="M7199.5,7144.34a55.16,55.16,0,1,0,55.16,55.16A55.15,55.15,0,0,0,7199.5,7144.34Zm0,101.79a46.57,46.57,0,1,1,46.57-46.56A46.56,46.56,0,0,1,7199.46,7246.13Z" transform="translate(-7122.03 -7108.03)" style="fill: #4f4f4f"/>
<path class="${state}" id="wasser" d="M7200.2,7218.55c-12.93-2.38-13.47-4.43-21.19-4.76a48.42,48.42,0,0,0-22.16,4.56,46.57,46.57,0,0,0,85.07.33,100.78,100.78,0,0,1-13.25,1.77A115.82,115.82,0,0,1,7200.2,7218.55Z" transform="translate(-7122.03 -7108.03)" style="fill: #6161f2"/>
</svg>
</svg>
`;
]]]