I am currently in the process of migrating my configuration to Lovelace and I am getting desperate. I created a picture-elements card with my floor plans and I now want to place light icons on it. While the placing works fine I am not able to set a state based color for the icons even though It feels, that I tried every ‘solution’ I could find in the internet. So my yaml for the current tab looks like this:
You can’t do what you’re trying to do with the base element. No picture-element elements have a ‘state’ attribute. I’m not sure where you got it from, but you can’t just add any field and expect it to work. All available fields are present in the documentation for each element.
You can get the card-mod custom card that has templating. That will allow you to modify any style based on the state.
thank you for your answer. I am not sure, that I get it. Yes, I am aware that the picture-element does not offer any state field/attribute. But as far as I understood it the state in this case is not refering to the picture element, but to the specific sublements, here the icon, which again refers to the switch entity, which offers on and off states. I mean, also the toggle action (which worHi,
thank you for your answer. I am not sure, that I get it. Yes, I am aware that the picture-element does not offer any state field/attribute. But as far as I understood it the state in this case is not refering to the picture element, but to the specific sublements, here the icon, which again refers to the switch entity, which offers on and off states. I mean, also the toggle action (which works) must work somehow even though nor the picture-element nor the icon don’t offer this functionality by themselves, right?
Also I found serveral similar snippets, which apparently are supposed to work, when I sort out this one difference, which I cannot figure out currently and prevents it working for me. I think having icons representing the lights and showing the state within the picture-element card should be one of the most common use scenarios. Do I really need a custom card for this?ks) must work somehow even though nor the picture-element nor the icon don’t offer this functionality by themselves, right?
Also I found serveral similar snippets, which apparently are supposed to work, when I sort out this one difference, which I cannot figure out currently and prevents it working for me. I think having icons representing the lights and showing the state within the picture-element card should be one of the most common use scenarios. Do I really need a custom card for this?
Yes, you really need a custom card because the state field is not available for this element. It doesn’t matter that you found other code that works because this specific element does not allow it.
It sets the predefined state colors. The colors used in the yaml where only test colors for me because the original icon’s light grey was barely visible as overlay on my floor plan.
Well you should clarify that next time. Using odd colors like that are what prompted the answer you received. You would have gotten your solution day-of instead of 4 days later.