From 7fa697a7680e90fde51a569244706e25f4a24f23 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Mon, 26 May 2025 10:50:42 +0200 Subject: [PATCH] Add actions section and add domains to other section in area dashboard (#25558) * Add actions section and add domains to other section in area dashboard * Add timer and input button * Better grouping --- .../strategies/areas/area-view-strategy.ts | 24 ++++++++++++++-- .../areas/areas-overview-view-strategy.ts | 1 + .../areas/helpers/areas-strategy-helper.ts | 28 ++++++++++++++++++- src/translations/en.json | 3 +- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/panels/lovelace/strategies/areas/area-view-strategy.ts b/src/panels/lovelace/strategies/areas/area-view-strategy.ts index c2c2597a9f..2fc8a0256d 100644 --- a/src/panels/lovelace/strategies/areas/area-view-strategy.ts +++ b/src/panels/lovelace/strategies/areas/area-view-strategy.ts @@ -76,8 +76,15 @@ export class AreaViewStrategy extends ReactiveElement { const computeTileCard = computeAreaTileCardConfig(hass, area.name, true); - const { lights, climate, covers, media_players, security, others } = - groupedEntities; + const { + lights, + climate, + covers, + media_players, + security, + actions, + others, + } = groupedEntities; if (lights.length > 0) { sections.push({ @@ -146,6 +153,19 @@ export class AreaViewStrategy extends ReactiveElement { }); } + if (actions.length > 0) { + sections.push({ + type: "grid", + cards: [ + computeHeadingCard( + hass.localize("ui.panel.lovelace.strategy.areas.groups.actions"), + AREA_STRATEGY_GROUP_ICONS.actions + ), + ...actions.map(computeTileCard), + ], + }); + } + if (others.length > 0) { sections.push({ type: "grid", diff --git a/src/panels/lovelace/strategies/areas/areas-overview-view-strategy.ts b/src/panels/lovelace/strategies/areas/areas-overview-view-strategy.ts index fde3545216..c8cda13888 100644 --- a/src/panels/lovelace/strategies/areas/areas-overview-view-strategy.ts +++ b/src/panels/lovelace/strategies/areas/areas-overview-view-strategy.ts @@ -54,6 +54,7 @@ export class AreasOverviewViewStrategy extends ReactiveElement { ...groups.climate, ...groups.media_players, ...groups.security, + ...groups.actions, ...groups.others, ]; diff --git a/src/panels/lovelace/strategies/areas/helpers/areas-strategy-helper.ts b/src/panels/lovelace/strategies/areas/helpers/areas-strategy-helper.ts index 3c64b21457..065393e258 100644 --- a/src/panels/lovelace/strategies/areas/helpers/areas-strategy-helper.ts +++ b/src/panels/lovelace/strategies/areas/helpers/areas-strategy-helper.ts @@ -22,6 +22,7 @@ export const AREA_STRATEGY_GROUPS = [ "covers", "media_players", "security", + "actions", "others", ] as const; @@ -31,6 +32,7 @@ export const AREA_STRATEGY_GROUP_ICONS = { covers: "mdi:blinds-horizontal", media_players: "mdi:multimedia", security: "mdi:security", + actions: "mdi:robot", others: "mdi:shape", }; @@ -121,6 +123,18 @@ export const getAreaGroupedEntities = ( entity_category: "none", }), ], + actions: [ + generateEntityFilter(hass, { + domain: ["script", "scene"], + area: area, + entity_category: "none", + }), + generateEntityFilter(hass, { + domain: ["automation"], + area: area, + entity_category: "none", + }), + ], others: [ generateEntityFilter(hass, { domain: "vacuum", @@ -138,7 +152,19 @@ export const getAreaGroupedEntities = ( entity_category: "none", }), generateEntityFilter(hass, { - domain: ["switch", "select", "input_boolean", "input_select"], + domain: ["switch", "button", "input_boolean", "input_button"], + area: area, + entity_category: "none", + }), + generateEntityFilter(hass, { + domain: [ + "select", + "number", + "input_select", + "input_number", + "counter", + "timer", + ], area: area, entity_category: "none", }), diff --git a/src/translations/en.json b/src/translations/en.json index 24ababb65d..725074c0ca 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -6571,8 +6571,9 @@ "lights": "Lights", "covers": "Covers", "climate": "Climate", - "media_players": "Entertainment", + "media_players": "Media players", "security": "Security", + "actions": "Actions", "others": "Others" } }