mirror of
https://github.com/home-assistant/frontend.git
synced 2026-04-02 00:27:49 +01:00
Add people at home summary tile to home overview dashboard (#30408)
* Add persons summary tile to home overview dashboard Show how many people are currently home in the Summary section of the default home dashboard. Only persons with at least one tracking device are included. The tile only appears when the map panel is loaded and at least one tracked person entity exists. Tapping navigates to the map panel. Displays a count of persons home or "Nobody" when all are away. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove persons tile from home overview strategy * Translation tweak Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
This commit is contained in:
@@ -43,6 +43,7 @@ const COLORS: Record<HomeSummary, string> = {
|
||||
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 "";
|
||||
}
|
||||
|
||||
@@ -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<HomeSummary, string> = {
|
||||
security: "mdi:security",
|
||||
media_players: "mdi:multimedia",
|
||||
energy: "mdi:lightning-bolt",
|
||||
persons: "mdi:account-multiple",
|
||||
};
|
||||
|
||||
export const HOME_SUMMARIES_FILTERS: Record<HomeSummary, EntityFilter[]> = {
|
||||
@@ -28,6 +30,7 @@ export const HOME_SUMMARIES_FILTERS: Record<HomeSummary, EntityFilter[]> = {
|
||||
security: securityEntityFilters,
|
||||
media_players: [{ domain: "media_player", entity_category: "none" }],
|
||||
energy: [], // Uses energy collection data
|
||||
persons: [{ domain: "person" }],
|
||||
};
|
||||
|
||||
export const getSummaryLabel = (
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user