diff --git a/src/panels/lovelace/cards/hui-home-summary-card.ts b/src/panels/lovelace/cards/hui-home-summary-card.ts index 935d56ff99..8e49bb3ed9 100644 --- a/src/panels/lovelace/cards/hui-home-summary-card.ts +++ b/src/panels/lovelace/cards/hui-home-summary-card.ts @@ -43,6 +43,7 @@ const COLORS: Record = { security: "blue-grey", media_players: "blue", energy: "amber", + persons: "green", }; @customElement("hui-home-summary-card") @@ -257,6 +258,21 @@ export class HuiHomeSummaryCard const totalConsumption = consumption.total.used_total; return formatConsumptionShort(this.hass, totalConsumption, "kWh"); } + case "persons": { + const personsFilters = HOME_SUMMARIES_FILTERS.persons.map((filter) => + generateEntityFilter(this.hass!, filter) + ); + const personEntities = findEntities(allEntities, personsFilters); + const personsHome = personEntities.filter((entityId) => { + const s = this.hass!.states[entityId]?.state; + return s === "home"; + }); + return personsHome.length + ? this.hass.localize("ui.card.home-summary.count_persons_home", { + count: personsHome.length, + }) + : this.hass.localize("ui.card.home-summary.nobody_home"); + } } return ""; } diff --git a/src/panels/lovelace/strategies/home/helpers/home-summaries.ts b/src/panels/lovelace/strategies/home/helpers/home-summaries.ts index 76e08e5727..c8b101ffc5 100644 --- a/src/panels/lovelace/strategies/home/helpers/home-summaries.ts +++ b/src/panels/lovelace/strategies/home/helpers/home-summaries.ts @@ -10,6 +10,7 @@ export const HOME_SUMMARIES = [ "security", "media_players", "energy", + "persons", ] as const; export type HomeSummary = (typeof HOME_SUMMARIES)[number]; @@ -20,6 +21,7 @@ export const HOME_SUMMARIES_ICONS: Record = { security: "mdi:security", media_players: "mdi:multimedia", energy: "mdi:lightning-bolt", + persons: "mdi:account-multiple", }; export const HOME_SUMMARIES_FILTERS: Record = { @@ -28,6 +30,7 @@ export const HOME_SUMMARIES_FILTERS: Record = { security: securityEntityFilters, media_players: [{ domain: "media_player", entity_category: "none" }], energy: [], // Uses energy collection data + persons: [{ domain: "person" }], }; export const getSummaryLabel = ( diff --git a/src/translations/en.json b/src/translations/en.json index d95cedd9ee..c3827cd241 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -216,7 +216,9 @@ "count_alarms_disarmed": "{count} {count, plural,\n one {disarmed}\n other {disarmed}\n}", "all_secure": "All secure", "no_media_playing": "No media playing", - "count_media_playing": "{count} {count, plural,\n one {playing}\n other {playing}\n}" + "count_media_playing": "{count} {count, plural,\n one {playing}\n other {playing}\n}", + "count_persons_home": "{count} {count, plural,\n one {person}\n other {people}\n}", + "nobody_home": "No one home" }, "toggle-group": { "all_off": "All off", @@ -8218,7 +8220,8 @@ "media_players": "Media players", "other_devices": "Other devices", "weather": "Weather", - "energy": "Today's energy" + "energy": "Today's energy", + "persons": "People at home" }, "welcome_user": "Welcome {user}", "summaries": "Summaries",