Last active
November 24, 2022 14:49
-
-
Save LilTrublMakr/94d2fb3a8e98385c05ded3a066c54653 to your computer and use it in GitHub Desktop.
Garage Door SVG Animation (Not working)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NOTES: | |
The switch does not have an on/off state. The states I am mostly concerned about is "Open" and "Closed". | |
There are also "Opening" and "Closing" but they are unreliable. It is also listed as a 'cover': cover.garage-door | |
Right now, I believe that it is always displaying the else statement. When simulating the open or | |
closed state, the card does not display the animation. It just swapps the card colors with the | |
'door closed' (else) icon. | |
-------------------- | |
icon_garage: | |
styles: | |
custom_fields: | |
icon: | |
- width: 100% | |
- margin-left: -5% | |
- margin-top: -15% | |
- fill: > | |
[[[ return variables.state_on ? '#4b5254' : '#9da0a2'; ]]] | |
custom_fields: | |
icon: > | |
[[[ | |
let style = ` | |
<style> | |
@keyframes opening { | |
0% { opacity: 1; } | |
100% { opacity: 0; } | |
} | |
.garage-bottom-opening { | |
animation: on 0.66s ease; | |
animation-fill-mode: forwards; | |
} | |
.garage-mid-opening { | |
animation: on 0.66s ease; | |
animation-delay: 0.66s; | |
animation-fill-mode: forwards; | |
} | |
.garage-top-opening { | |
animation: on 0.66s ease; | |
animation-delay: 1.32s; | |
animation-fill-mode: forwards; | |
} | |
@keyframes closing { | |
0% { opacity: 0; } | |
100% { opacity: 1; } | |
} | |
.garage-bottom-closing { | |
animation: on 0.66s ease; | |
animation-delay: 1.32s; | |
animation-fill-mode: forwards; | |
} | |
.garage-mid-closing { | |
animation: on 0.66s ease; | |
animation-delay: 0.66s; | |
animation-fill-mode: forwards; | |
} | |
.garage-top-closing { | |
animation: on 0.66s ease; | |
animation-fill-mode: forwards; | |
} | |
</style> | |
`; | |
if (variables.state_on && variables.timeout < 2000) { | |
return ` | |
<svg viewBox="0 0 24 24"> | |
${style} | |
<polyline class="garage-house" points="22,9 22,20 20,20 20,11 4,11 4,20 2,20 2,9 12,5 22,9 "/> | |
<polyline class="garage-top-opening" points="19,12 5,12 5,14 19,14 19,12 "/> | |
<rect class="garage-mid-opening" x="5" y="15" width="14" height="2"/> | |
<polyline class="garage-bottom-opening" points="19,18 5,18 5,20 19,20 19,18 "/> | |
</svg> | |
`; | |
} | |
if (variables.state_on && variables.timeout > 2000) { | |
return ` | |
<svg viewBox="0 0 24 24"> | |
<polyline class="garage-house" points="22,9 22,20 20,20 20,11 4,11 4,20 2,20 2,9 12,5 22,9 "/> | |
</svg> | |
`; | |
} | |
if (variables.state === 'Closed' && variables.timeout < 2000) { | |
return ` | |
<svg viewBox="0 0 24 24"> | |
${style} | |
<polyline class="garage-house" points="22,9 22,20 20,20 20,11 4,11 4,20 2,20 2,9 12,5 22,9 "/> | |
<polyline class="garage-top-closing" points="19,12 5,12 5,14 19,14 19,12 "/> | |
<rect class="garage-mid-closing" x="5" y="15" width="14" height="2"/> | |
<polyline class="garage-bottom-closing" points="19,18 5,18 5,20 19,20 19,18 "/> | |
</svg> | |
`; | |
} else { | |
return ` | |
<svg viewBox="0 0 24 24"> | |
<polyline class="garage-house" points="22,9 22,20 20,20 20,11 4,11 4,20 2,20 2,9 12,5 22,9 "/> | |
<polyline class="garage-top" points="19,12 5,12 5,14 19,14 19,12 "/> | |
<rect class="garage-mid" x="5" y="15" width="14" height="2"/> | |
<polyline class="garage-bottom" points="19,18 5,18 5,20 19,20 19,18 "/> | |
</svg> | |
`; | |
} | |
]]] |
Did you ever sort this out ?
Yes, I did eventually:
icon_garage:
styles:
custom_fields:
icon:
- width: 100%
- margin-left: -5%
- margin-top: -15%
- fill: >
[[[ return variables.state_on ? '#4b5254' : '#9da0a2'; ]]]
custom_fields:
icon: >
[[[
let style = `
<style>
@keyframes opening {
0% { opacity: 1; }
100% { opacity: 0; }
}
.garage-bottom-opening {
animation: opening 0.66s ease;
animation-fill-mode: forwards;
}
.garage-mid-opening {
animation: opening 0.66s ease;
animation-delay: 0.66s;
animation-fill-mode: forwards;
}
.garage-top-opening {
animation: opening 0.66s ease;
animation-delay: 1.32s;
animation-fill-mode: forwards;
}
@keyframes closing {
0% { opacity: 0; }
100% { opacity: 1; }
}
.garage-bottom-closing {
opacity: 0;
animation: closing 0.66s ease;
animation-delay: 1.32s;
animation-fill-mode: forwards;
}
.garage-mid-closing {
opacity: 0;
animation: closing 0.66s ease;
animation-delay: 0.66s;
animation-fill-mode: forwards;
}
.garage-top-closing {
opacity: 0;
animation: closing 0.66s ease;
animation-fill-mode: forwards;
}
</style>
`;
if (variables.state_on && variables.timeout < 2000) {
return `
<svg viewBox="0 0 24 24">
${style}
<polyline class="garage-house" points="22,9 22,20 20,20 20,11 4,11 4,20 2,20 2,9 12,5 22,9 "/>
<rect class="garage-top-opening" x="5" y="12" width="14" height="2"/>
<rect class="garage-mid-opening" x="5" y="15" width="14" height="2"/>
<rect class="garage-bottom-opening" x="5" y="18" width="14" height="2"/>
</svg>
`;
}
if (variables.state_on && variables.timeout > 2000) {
return `
<svg viewBox="0 0 24 24">
<polyline class="garage-house" points="22,9 22,20 20,20 20,11 4,11 4,20 2,20 2,9 12,5 22,9 "/>
</svg>
`;
}
if (variables.state === 'closed' && variables.timeout < 2000) {
return `
<svg viewBox="0 0 24 24">
${style}
<polyline class="garage-house" points="22,9 22,20 20,20 20,11 4,11 4,20 2,20 2,9 12,5 22,9 "/>
<rect class="garage-top-closing" x="5" y="12" width="14" height="2"/>
<rect class="garage-mid-closing" x="5" y="15" width="14" height="2"/>
<rect class="garage-bottom-closing" x="5" y="18" width="14" height="2"/>
</svg>
`;
} else {
return `
<svg viewBox="0 0 24 24">
<polyline class="garage-house" points="22,9 22,20 20,20 20,11 4,11 4,20 2,20 2,9 12,5 22,9 "/>
<rect x="5" y="12" width="14" height="2"/>
<rect x="5" y="15" width="14" height="2"/>
<rect x="5" y="18" width="14" height="2"/>
</svg>
`;
}
]]]
What does the actual button-card look like ? I'm struggling w/ the state when trying to use this... curious what you're passing
Here is what it looks like: https://github.com/LilTrublMakr/Home-Assistant-Icons/tree/master/SVG/LTM-Garage
Thanks for posting... I see you mentioned adding open to the base template, which makes sense but you didnt mention the other states like closing
,opening
, closed
, ect
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did you ever sort this out ?