Compare commits

...

2 Commits

Author SHA1 Message Date
Paul Bottein
0cbf0ca08c Use not 2026-02-03 14:02:10 +01:00
Paul Bottein
130cbb3309 Add toggle lights button on light dashboard 2026-02-03 14:02:10 +01:00

View File

@@ -45,6 +45,16 @@ const processAreasForLight = (
}
if (areaCards.length > 0) {
// Visibility condition: any light is on
const anyOnCondition = {
condition: "or" as const,
conditions: areaLights.map((entityId) => ({
condition: "state" as const,
entity: entityId,
state: "on",
})),
};
cards.push({
heading_style: "subtitle",
type: "heading",
@@ -53,6 +63,38 @@ const processAreasForLight = (
action: "navigate",
navigation_path: `/home/areas-${area.area_id}`,
},
badges: [
{
type: "button",
icon: "mdi:power",
tap_action: {
action: "perform-action",
perform_action: "light.turn_on",
target: {
area_id: area.area_id,
},
},
visibility: [
{
condition: "not",
conditions: [anyOnCondition],
},
],
},
{
type: "button",
icon: "mdi:power",
color: "orange",
tap_action: {
action: "perform-action",
perform_action: "light.turn_off",
target: {
area_id: area.area_id,
},
},
visibility: [anyOnCondition],
},
] satisfies LovelaceCardConfig[],
});
cards.push(...areaCards);
}