Remove alert classes and only use slot sensors for areas dashboard (#25937)

* Remove alert classes and only used slot sensors for areas dashboard

* Rename group to sensors

* Rename group to sensors
This commit is contained in:
Paul Bottein 2025-06-26 13:05:05 +02:00 committed by GitHub
parent 675310afdf
commit 3dd3a80054
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 41 additions and 25 deletions

View File

@ -218,6 +218,13 @@ export class HaAreasFloorsDisplayEditor extends LitElement {
align-items: center; align-items: center;
gap: 8px; gap: 8px;
} }
ha-expansion-panel {
margin-bottom: 8px;
--expansion-panel-summary-padding: 0 16px;
}
ha-expansion-panel [slot="leading-icon"] {
margin-inline-end: 16px;
}
`; `;
} }

View File

@ -89,20 +89,19 @@ export class AreasOverviewViewStrategy extends ReactiveElement {
(control) => controlEntities[control].length > 0 (control) => controlEntities[control].length > 0
); );
const sensorClasses: string[] = [];
if (area.temperature_entity_id) {
sensorClasses.push("temperature");
}
if (area.humidity_entity_id) {
sensorClasses.push("humidity");
}
return { return {
type: "area", type: "area",
area: area.area_id, area: area.area_id,
display_type: "compact", display_type: "compact",
sensor_classes: ["temperature", "humidity"], sensor_classes: sensorClasses,
alert_classes: [
"water_leak",
"smoke",
"gas",
"co",
"motion",
"occupancy",
"presence",
],
exclude_entities: hiddenEntities, exclude_entities: hiddenEntities,
features: filteredControls.length features: filteredControls.length
? [ ? [

View File

@ -1,28 +1,30 @@
import { mdiThermometerWater } from "@mdi/js";
import { css, html, LitElement, nothing } from "lit"; import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../../../../common/dom/fire_event"; import { fireEvent } from "../../../../../common/dom/fire_event";
import "../../../../../components/ha-areas-display-editor"; import "../../../../../components/ha-areas-display-editor";
import type { AreasDisplayValue } from "../../../../../components/ha-areas-display-editor"; import type { AreasDisplayValue } from "../../../../../components/ha-areas-display-editor";
import "../../../../../components/ha-areas-floors-display-editor";
import "../../../../../components/ha-entities-display-editor"; import "../../../../../components/ha-entities-display-editor";
import "../../../../../components/ha-icon";
import "../../../../../components/ha-icon-button"; import "../../../../../components/ha-icon-button";
import "../../../../../components/ha-icon-button-prev"; import "../../../../../components/ha-icon-button-prev";
import "../../../../../components/ha-icon"; import "../../../../../components/ha-svg-icon";
import {
updateAreaRegistryEntry,
type AreaRegistryEntry,
} from "../../../../../data/area_registry";
import { buttonLinkStyle } from "../../../../../resources/styles";
import type { HomeAssistant } from "../../../../../types"; import type { HomeAssistant } from "../../../../../types";
import { showAreaRegistryDetailDialog } from "../../../../config/areas/show-dialog-area-registry-detail";
import type { LovelaceStrategyEditor } from "../../types";
import type { AreasDashboardStrategyConfig } from "../areas-dashboard-strategy";
import type { AreaStrategyGroup } from "../helpers/areas-strategy-helper"; import type { AreaStrategyGroup } from "../helpers/areas-strategy-helper";
import { import {
AREA_STRATEGY_GROUP_ICONS, AREA_STRATEGY_GROUP_ICONS,
AREA_STRATEGY_GROUPS, AREA_STRATEGY_GROUPS,
getAreaGroupedEntities, getAreaGroupedEntities,
} from "../helpers/areas-strategy-helper"; } from "../helpers/areas-strategy-helper";
import type { LovelaceStrategyEditor } from "../../types";
import type { AreasDashboardStrategyConfig } from "../areas-dashboard-strategy";
import { showAreaRegistryDetailDialog } from "../../../../config/areas/show-dialog-area-registry-detail";
import {
updateAreaRegistryEntry,
type AreaRegistryEntry,
} from "../../../../../data/area_registry";
import { buttonLinkStyle } from "../../../../../resources/styles";
import "../../../../../components/ha-areas-floors-display-editor";
@customElement("hui-areas-dashboard-strategy-editor") @customElement("hui-areas-dashboard-strategy-editor")
export class HuiAreasDashboardStrategyEditor export class HuiAreasDashboardStrategyEditor
@ -58,14 +60,18 @@ export class HuiAreasDashboardStrategyEditor
</div> </div>
<ha-expansion-panel <ha-expansion-panel
.header=${this.hass!.localize( .header=${this.hass!.localize(
`ui.panel.lovelace.strategy.areas.header` `ui.panel.lovelace.strategy.areas.sensors`
)} )}
expanded expanded
outlined outlined
> >
<ha-svg-icon
slot="leading-icon"
.path=${mdiThermometerWater}
></ha-svg-icon>
<p> <p>
${this.hass!.localize( ${this.hass!.localize(
`ui.panel.lovelace.strategy.areas.header_description`, `ui.panel.lovelace.strategy.areas.sensors_description`,
{ {
edit_the_area: html` edit_the_area: html`
<button class="link" @click=${this._editArea} .area=${area}> <button class="link" @click=${this._editArea} .area=${area}>
@ -213,9 +219,13 @@ export class HuiAreasDashboardStrategyEditor
ha-expansion-panel { ha-expansion-panel {
margin-bottom: 8px; margin-bottom: 8px;
max-width: 600px; max-width: 600px;
--expansion-panel-summary-padding: 0 16px;
}
ha-expansion-panel [slot="leading-icon"] {
margin-inline-end: 16px;
} }
ha-expansion-panel p { ha-expansion-panel p {
margin: 8px 2px; margin: 8px 8px 16px 8px;
} }
button.link { button.link {
color: var(--primary-color); color: var(--primary-color);

View File

@ -6673,8 +6673,8 @@
}, },
"areas": { "areas": {
"no_entities": "No entities in this area.", "no_entities": "No entities in this area.",
"header": "Area badges", "sensors": "Sensors",
"header_description": "To display temperature and humidity sensors in the overview and in the area view, add a sensor to that area and {edit_the_area} to configure related sensors.", "sensors_description": "To display temperature and humidity sensors in the overview and in the area view, add a sensor to that area and {edit_the_area} to configure related sensors.",
"edit_the_area": "edit the area", "edit_the_area": "edit the area",
"groups": { "groups": {
"lights": "Lights", "lights": "Lights",