11import {
2+ mdiAlertCircle ,
23 mdiDelete ,
34 mdiDevices ,
45 mdiDragHorizontalVariant ,
56 mdiPencil ,
67 mdiPlus ,
78} from "@mdi/js" ;
89import type { CSSResultGroup , TemplateResult } from "lit" ;
9- import { css , html , LitElement } from "lit" ;
10+ import { css , html , LitElement , nothing } from "lit" ;
1011import { repeat } from "lit/directives/repeat" ;
1112import { customElement , property } from "lit/decorators" ;
1213import { fireEvent } from "../../../../common/dom/fire_event" ;
@@ -15,10 +16,12 @@ import "../../../../components/ha-button";
1516import "../../../../components/ha-icon-button" ;
1617import "../../../../components/ha-sortable" ;
1718import "../../../../components/ha-svg-icon" ;
19+ import "../../../../components/ha-tooltip" ;
1820import type {
1921 DeviceConsumptionEnergyPreference ,
2022 EnergyPreferences ,
2123 EnergyPreferencesValidation ,
24+ EnergyValidationIssue ,
2225} from "../../../../data/energy" ;
2326import { saveEnergyPreferences } from "../../../../data/energy" ;
2427import type { StatisticsMetaData } from "../../../../data/recorder" ;
@@ -93,7 +96,7 @@ export class EnergyDeviceSettings extends LitElement {
9396 ${ repeat (
9497 this . preferences . device_consumption ,
9598 ( device ) => device . stat_consumption ,
96- ( device ) => html `
99+ ( device , index ) => html `
97100 <div class= "row" .device = ${ device } >
98101 <div class= "handle" >
99102 <ha- svg- icon
@@ -108,6 +111,10 @@ export class EnergyDeviceSettings extends LitElement {
108111 this . statsMetadata ?. [ device . stat_consumption ]
109112 ) } </ span
110113 >
114+ ${ this . _renderIssueIndicator (
115+ this . validationResult ?. device_consumption [ index ] ,
116+ index
117+ ) }
111118 <ha- icon- butto n
112119 .label = ${ this . hass . localize ( "ui.common.edit" ) }
113120 @click = ${ this . _editDevice }
@@ -144,6 +151,31 @@ export class EnergyDeviceSettings extends LitElement {
144151 ` ;
145152 }
146153
154+ private _renderIssueIndicator (
155+ issues : EnergyValidationIssue [ ] | undefined ,
156+ index : number
157+ ) {
158+ if ( ! issues ?. length ) {
159+ return nothing ;
160+ }
161+ const titles = issues . map (
162+ ( issue ) =>
163+ this . hass . localize ( `component.energy.issues.${ issue . type } .title` ) ||
164+ issue . type
165+ ) ;
166+ const label = titles . join ( "\n" ) ;
167+ const id = `issue-icon-${ index } ` ;
168+ return html `
169+ <ha- svg- icon
170+ id= ${ id }
171+ class= "issue-icon"
172+ .path = ${ mdiAlertCircle }
173+ aria- label= ${ label }
174+ > </ ha- svg- icon>
175+ <ha- to oltip .for = ${ id } placement= "to p"> ${ label } </ ha- to oltip>
176+ ` ;
177+ }
178+
147179 private _itemMoved ( ev : CustomEvent ) : void {
148180 ev . stopPropagation ( ) ;
149181 const { oldIndex, newIndex } = ev . detail ;
@@ -244,6 +276,9 @@ export class EnergyDeviceSettings extends LitElement {
244276 cursor : move; /* fallback if grab cursor is unsupported */
245277 cursor : grab;
246278 }
279+ .issue-icon {
280+ color : var (--warning-color );
281+ }
247282 ` ,
248283 ] ;
249284 }
0 commit comments