Clean graph in security and climate view in home dashboard (#26833)
parent
645ba3f9c1
commit
1786235c86
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue