From 1786235c86aeaae96fdf11c68fb097094aceb250 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Tue, 2 Sep 2025 14:58:56 +0200 Subject: [PATCH] Clean graph in security and climate view in home dashboard (#26833) --- .../home/home-climate-view-strategy.ts | 37 +++++-------------- .../home/home-security-view-strategy.ts | 23 +----------- 2 files changed, 11 insertions(+), 49 deletions(-) diff --git a/src/panels/lovelace/strategies/home/home-climate-view-strategy.ts b/src/panels/lovelace/strategies/home/home-climate-view-strategy.ts index 041314e615..80df571287 100644 --- a/src/panels/lovelace/strategies/home/home-climate-view-strategy.ts +++ b/src/panels/lovelace/strategies/home/home-climate-view-strategy.ts @@ -12,30 +12,11 @@ import { } from "../areas/helpers/areas-strategy-helper"; import { getHomeStructure } from "./helpers/home-structure"; import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries"; -import { computeStateName } from "../../../../common/entity/compute_state_name"; -import { computeObjectId } from "../../../../common/entity/compute_object_id"; export interface HomeClimateViewStrategyConfig { type: "home-climate"; } -const createTempHumidBadge = (hass: HomeAssistant, entityId: string) => { - const stateObj = hass.states[entityId]; - return { - type: "tile", - entity: entityId, - name: stateObj - ? computeStateName(stateObj) - : computeObjectId(entityId).replace(/_/g, " "), - features: [ - { - type: "history-chart", - hours_to_show: 3, - }, - ], - }; -}; - const processAreasForClimate = ( areaIds: string[], hass: HomeAssistant, @@ -64,15 +45,17 @@ const processAreasForClimate = ( }, }); - if (hass.areas[areaId].temperature_entity_id) { - cards.push( - createTempHumidBadge(hass, hass.areas[areaId].temperature_entity_id) - ); + if (area.temperature_entity_id) { + cards.push({ + ...computeTileCard(area.temperature_entity_id), + features: [{ type: "history-chart" }], + }); } - if (hass.areas[areaId].humidity_entity_id) { - cards.push( - createTempHumidBadge(hass, hass.areas[areaId].humidity_entity_id) - ); + if (area.humidity_entity_id) { + cards.push({ + ...computeTileCard(area.humidity_entity_id), + features: [{ type: "history-chart" }], + }); } for (const entityId of areaEntities) { diff --git a/src/panels/lovelace/strategies/home/home-security-view-strategy.ts b/src/panels/lovelace/strategies/home/home-security-view-strategy.ts index c231ffd336..44ed682a15 100644 --- a/src/panels/lovelace/strategies/home/home-security-view-strategy.ts +++ b/src/panels/lovelace/strategies/home/home-security-view-strategy.ts @@ -12,9 +12,6 @@ import { } from "../areas/helpers/areas-strategy-helper"; import { getHomeStructure } from "./helpers/home-structure"; import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries"; -import { computeDomain } from "../../../../common/entity/compute_domain"; -import { computeStateName } from "../../../../common/entity/compute_state_name"; -import { computeObjectId } from "../../../../common/entity/compute_object_id"; export interface HomeSecurityViewStrategyConfig { type: "home-security"; @@ -49,25 +46,7 @@ const processAreasForSecurity = ( }); for (const entityId of areaEntities) { - const stateObj = hass.states[entityId]; - cards.push( - computeDomain(entityId) === "binary_sensor" && - stateObj?.attributes.device_class === "motion" - ? { - type: "tile", - entity: entityId, - name: stateObj - ? computeStateName(stateObj) - : computeObjectId(entityId).replace(/_/g, " "), - features: [ - { - type: "history-chart", - hours_to_show: 6, - }, - ], - } - : computeTileCard(entityId) - ); + cards.push(computeTileCard(entityId)); } } }