add icon-color to Tile card #3
Replies: 3 comments 26 replies
-
@Mariusthvdb, customElements.whenDefined("hui-tile-card").then(() => {
const tileCard = customElements.get("hui-tile-card");
if (!tileCard) return;
if (tileCard.prototype?.updated) {
const originalUpdated = tileCard.prototype.updated;
tileCard.prototype.updated = function customUpdated(changedProps) {
if (
!changedProps.has('_config') ||
!changedProps.has('hass')
) {
return;
}
const { _config, hass } = this;
const entityId = _config?.entity;
const states = hass?.states;
const iconColor = states?.[entityId]?.attributes?.icon_color;
if (iconColor) {
this.style?.setProperty('--icon-primary-color', _stateObj.attributes.icon_color);
}
originalUpdated.call(this, changedProps);
}
}
}); |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi, From my understanding the problem is, that on every update of the Furthermore, just setting |
Beta Was this translation helpful? Give feedback.
-
continuing from #1 (reply in thread)
seems the logical progression, with Tile card getting more and more popular to, have this plugin also colorize the icon on that card.
I copied the code used for the button card and edited, but this is not working yet ofc.
card_modding the Tile card is less obvious than other cards, so maybe there is much more to is getting this plugin to touch the Tile card too
Hope it can be done without too much effort, or complexity.
Beta Was this translation helpful? Give feedback.
All reactions