I am hoping this can be done but everything I have tried so far doesn’t work.
I am using floorplan as a lovelace card. I have the following code working to place an icon on my plan.
- name: Weather Today Icon
entities:
- sensor.bom_brisbane_icon_0
image_template: ' var imageName = "";
switch (entity.state) {
case "sunny": imageName = "day"; break;
case "clear": imageName = "clear-day" break;
case "mostly-sunny": imageName = "fair-day"; break;
case "partly-cloudy": imageName = "cloudy-day-3"; break;
case "cloudy": imageName = "cloudy-day-3"; break;
default: imageName = "weather_sunset"; break; }
return "/local/icons/weather_icons/animated/" + imageName + ".svg"; '
Now I just want to make a slight change and have the icons change between day and night. At the moment if the state of the entity is “clear” then I always get “clear-day” as the icon but I want “clear-night” if it is after sunset. So I have tried multiple variations of the following but haven’t been able to get it to work. (I am just trying to get the “clear” line to work but it will expand to the others) Can it be done?
- name: Weather Today Icon
entities:
- sensor.bom_brisbane_icon_0
image_template: ' var imageName = "";
switch (entity.state) {
case "sunny": imageName = "day"; break;
case "clear": imageName = "clear-" + sun.sun.state == "below_horizon" ? "night" : "day" ; break;
case "mostly-sunny": imageName = "fair-day"; break;
case "partly-cloudy": imageName = "cloudy-day-3"; break;
case "cloudy": imageName = "cloudy-day-3"; break;
default: imageName = "weather_sunset"; break; }
return "/local/icons/weather_icons/animated/" + imageName + ".svg"; '