What I meant is that a lot of code from custom-ui is no longer relevant (at least if you don’t use the states-ui). Custom-ui has a lot of code to create custom cards for the states-ui. That is basically what I meant. The customize.yaml option of Custom-UI is only a small portion of the code, the rest of the code is all related to the states-ui. So for lovelace this is a component which can do way more than we actually need.
Regarding frontend vs backend, it is actually the backend that puts load on your pi, the frontend puts load on your client device. The more templates in the frontend, the longer it takes for a device to load the page. The same is true for the backend, the more sensors, automations, customizations etc you have the more it will put a strain on your pi. When using a pi, you probably prefer to do templates in the frontend as that will lower the load on your pi, but it increases it on your client.
One of those examples are the template you shared with me in my own thread last week. The one sending out a greeting like Good Morning etc. You and I both used a sensor handled by the backend. A sensor like this will put load on the pi instead of the client device. I have since moved to a frontend based sensor which puts the load on your browser instead.
In my opinion it is hard to balance both especially when you have a massive setup. In general, if you have decent hardware, doing everything in the backend will certainly load your pages faster. But if you don’t use decent hardware it is probably best to let the client do the work (as most smartphones today are pretty powerful).
Btw, you can still use Custom-UI with lovelace, I use it too!
Edit: if you’re interested in that frontend greetings template without the need for a sensor I am happy to share it.
I use Custom-UI just to modify the appearance of icons. If it can be done with Lovelace then I’ll uninstall Custom-UI (because it throws the occasional error in my log).
How would one replicate the following functionality with Lovelace?
Change climate icon’s appearance and color depending on its state and its hvac_status attribute.
climate.thermostat:
templates:
icon: >
if (state === "off") return "mdi:power-off";
if (attributes.hvac_action === "heating") return "mdi:fire";
if (attributes.hvac_action === "cooling") return "mdi:snowflake";
if (attributes.hvac_action === "auto") return "mdi:autorenew";
if (attributes.hvac_action === "idle") return "mdi:sleep";
return "mdi:power-off";
icon_color: >
if (attributes.hvac_action === "off") return "gray";
if (attributes.hvac_action === "heating") return "red";
if (attributes.hvac_action === "cooling") return "blue";
if (attributes.hvac_action === "auto") return "green";
if (attributes.hvac_action === "idle") return "black";
return "gray";
Change a sensor icon’s appearance and color depending on its state.
sensor.security_status:
templates:
icon: >
if (state === 'Disarmed, Ready') return 'mdi:thumb-up-outline';
if (state === 'Stay, Ready') return 'mdi:shield';
return 'mdi:thumb-down-outline';
icon_color: >
if (state === 'Disarmed, Ready') return 'green';
if (state === 'Stay, Ready') return 'green';
return '#FDD835';
it depends on the method you want to use. With lovelace, theres’s about 9000 ways to get what you want. For example, in the button card, the code is identical to what you have there. It the template card (that uses jinja) it’s jinja code. For the 100% template card, the code is identical.
EDIT: This goes on the individual entity. You may be able to put this on the card and it will apply to all items in the card (I believe, I haven’t done it but it claims to work).
Thank you! I’m reading through the docs now and it looks promising. I need to apply dynamic styling on a per-entity basis and, based on what I’ve read so far, this looks like it will do the trick. If I’m successful, I’ll post examples so others can compare the changes I made to get from Custom-UI to card-mod.
If you combine it with lovelace_gen, you can compartmentalize everything you want for lovelace as well.
I’m in the process of shifting over to lovelace_gen, it’s taking quite some time, but in the end the overhead will be much easier to manage.
EDIT: Ask away as well. I have some intimate knowledge with this crap at the moment. lovelace_gen looks scary but it’s quite easy once you understand the flow.
I’ve learned how to dynamically change the icon’s color but can’t find an example of how to dynamically change the icon. Does card-mod support it or will I need to use something else?
The beauty of going 100% lovelace is that you can come up with crazy crap. This is a mock card that I recently came up with that shows door status, last opened, and who opened it.
Problem with lovelace is that it isn’t system wide. Meaning that if you open up the more-info window you’d still see the default icon. This is also true for all other areas of the interface where you can’t define an icon. The beauty of customizer is that it is a 100% system wide and it even reflects to the “devices and integrations page in the UI”.
But true lovelace is more versatile, I use both for this reason.