mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Add support for no-state
and entity-no-longer-available
statistic… (#10345)
This commit is contained in:
parent
c3975e48d9
commit
a0fea94db2
@ -77,12 +77,24 @@ export interface StatisticsMetaData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type StatisticsValidationResult =
|
export type StatisticsValidationResult =
|
||||||
|
| StatisticsValidationResultNoState
|
||||||
| StatisticsValidationResultEntityNotRecorded
|
| StatisticsValidationResultEntityNotRecorded
|
||||||
|
| StatisticsValidationResultEntityNoLongerRecorded
|
||||||
| StatisticsValidationResultUnsupportedStateClass
|
| StatisticsValidationResultUnsupportedStateClass
|
||||||
| StatisticsValidationResultUnitsChanged
|
| StatisticsValidationResultUnitsChanged
|
||||||
| StatisticsValidationResultUnsupportedUnitMetadata
|
| StatisticsValidationResultUnsupportedUnitMetadata
|
||||||
| StatisticsValidationResultUnsupportedUnitState;
|
| StatisticsValidationResultUnsupportedUnitState;
|
||||||
|
|
||||||
|
export interface StatisticsValidationResultNoState {
|
||||||
|
type: "no_state";
|
||||||
|
data: { statistic_id: string };
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StatisticsValidationResultEntityNoLongerRecorded {
|
||||||
|
type: "entity_no_longer_recorded";
|
||||||
|
data: { statistic_id: string };
|
||||||
|
}
|
||||||
|
|
||||||
export interface StatisticsValidationResultEntityNotRecorded {
|
export interface StatisticsValidationResultEntityNotRecorded {
|
||||||
type: "entity_not_recorded";
|
type: "entity_not_recorded";
|
||||||
data: { statistic_id: string };
|
data: { statistic_id: string };
|
||||||
|
@ -8,18 +8,24 @@ import { computeStateName } from "../../../common/entity/compute_state_name";
|
|||||||
import "../../../components/data-table/ha-data-table";
|
import "../../../components/data-table/ha-data-table";
|
||||||
import type { DataTableColumnContainer } from "../../../components/data-table/ha-data-table";
|
import type { DataTableColumnContainer } from "../../../components/data-table/ha-data-table";
|
||||||
import {
|
import {
|
||||||
|
clearStatistics,
|
||||||
getStatisticIds,
|
getStatisticIds,
|
||||||
StatisticsMetaData,
|
StatisticsMetaData,
|
||||||
StatisticsValidationResult,
|
StatisticsValidationResult,
|
||||||
validateStatistics,
|
validateStatistics,
|
||||||
} from "../../../data/history";
|
} from "../../../data/history";
|
||||||
import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
|
import {
|
||||||
|
showAlertDialog,
|
||||||
|
showConfirmationDialog,
|
||||||
|
} from "../../../dialogs/generic/show-dialog-box";
|
||||||
import { haStyle } from "../../../resources/styles";
|
import { haStyle } from "../../../resources/styles";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { showFixStatisticsUnitsChangedDialog } from "./show-dialog-statistics-fix-units-changed";
|
import { showFixStatisticsUnitsChangedDialog } from "./show-dialog-statistics-fix-units-changed";
|
||||||
import { showFixStatisticsUnsupportedUnitMetadataDialog } from "./show-dialog-statistics-fix-unsupported-unit-meta";
|
import { showFixStatisticsUnsupportedUnitMetadataDialog } from "./show-dialog-statistics-fix-unsupported-unit-meta";
|
||||||
|
|
||||||
const FIX_ISSUES_ORDER = {
|
const FIX_ISSUES_ORDER = {
|
||||||
|
no_state: 0,
|
||||||
|
entity_no_longer_recorded: 1,
|
||||||
entity_not_recorded: 1,
|
entity_not_recorded: 1,
|
||||||
unsupported_unit_state: 2,
|
unsupported_unit_state: 2,
|
||||||
unsupported_state_class: 3,
|
unsupported_state_class: 3,
|
||||||
@ -103,7 +109,7 @@ class HaPanelDevStatistics extends LitElement {
|
|||||||
<ha-data-table
|
<ha-data-table
|
||||||
.columns=${this._columns(this.hass.localize)}
|
.columns=${this._columns(this.hass.localize)}
|
||||||
.data=${this._data}
|
.data=${this._data}
|
||||||
noDataText="No issues found!"
|
noDataText="No statistics"
|
||||||
id="statistic_id"
|
id="statistic_id"
|
||||||
clickable
|
clickable
|
||||||
@row-click=${this._rowClicked}
|
@row-click=${this._rowClicked}
|
||||||
@ -155,6 +161,20 @@ class HaPanelDevStatistics extends LitElement {
|
|||||||
);
|
);
|
||||||
const issue = issues[0];
|
const issue = issues[0];
|
||||||
switch (issue.type) {
|
switch (issue.type) {
|
||||||
|
case "no_state":
|
||||||
|
showConfirmationDialog(this, {
|
||||||
|
title: "Entity has no state",
|
||||||
|
text: html`This entity has no state at the moment, if this is an
|
||||||
|
orphaned entity, you may want to remove the long term statistics of
|
||||||
|
it from your database.<br /><br />Do you want to permanently remove
|
||||||
|
the long term statistics of ${issue.data.statistic_id} from your
|
||||||
|
database?`,
|
||||||
|
confirm: async () => {
|
||||||
|
await clearStatistics(this.hass, [issue.data.statistic_id]);
|
||||||
|
this._validateStatistics();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
break;
|
||||||
case "entity_not_recorded":
|
case "entity_not_recorded":
|
||||||
showAlertDialog(this, {
|
showAlertDialog(this, {
|
||||||
title: "Entity not recorded",
|
title: "Entity not recorded",
|
||||||
@ -172,6 +192,24 @@ class HaPanelDevStatistics extends LitElement {
|
|||||||
for more information.`,
|
for more information.`,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case "entity_no_longer_recorded":
|
||||||
|
showAlertDialog(this, {
|
||||||
|
title: "Entity no longer recorded",
|
||||||
|
text: html`We have generated statistics for this entity in the past,
|
||||||
|
but state changes of this entity are no longer recorded, therefore,
|
||||||
|
we can not track long term statistics for it anymore.
|
||||||
|
<br /><br />You probably excluded this entity, or have just included
|
||||||
|
some entities.<br /><br />See the
|
||||||
|
<a
|
||||||
|
href="https://www.home-assistant.io/integrations/recorder/#configure-filter"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer noopener"
|
||||||
|
>
|
||||||
|
recorder documentation</a
|
||||||
|
>
|
||||||
|
for more information.`,
|
||||||
|
});
|
||||||
|
break;
|
||||||
case "unsupported_state_class":
|
case "unsupported_state_class":
|
||||||
showAlertDialog(this, {
|
showAlertDialog(this, {
|
||||||
title: "Unsupported state class",
|
title: "Unsupported state class",
|
||||||
|
@ -3879,7 +3879,9 @@
|
|||||||
"unsupported_unit_state": "The unit (''{state_unit}'') of this entity doesn't match a unit of device class ''{device_class}''.",
|
"unsupported_unit_state": "The unit (''{state_unit}'') of this entity doesn't match a unit of device class ''{device_class}''.",
|
||||||
"unsupported_unit_metadata": "The unit (''{metadata_unit}'') of the recorded statistics doesn't match the supported unit ''{supported_unit}'' of device class ''{device_class}''.",
|
"unsupported_unit_metadata": "The unit (''{metadata_unit}'') of the recorded statistics doesn't match the supported unit ''{supported_unit}'' of device class ''{device_class}''.",
|
||||||
"unsupported_state_class": "The state class ''{state_class}'' of this entity is not supported.",
|
"unsupported_state_class": "The state class ''{state_class}'' of this entity is not supported.",
|
||||||
"entity_not_recorded": "This entity is excluded from being recorded."
|
"entity_not_recorded": "This entity is excluded from being recorded.",
|
||||||
|
"entity_no_longer_recorded": "This entity is no longer being recorded.",
|
||||||
|
"no_state": "There is no state available for this entity."
|
||||||
},
|
},
|
||||||
"fix_issue": {
|
"fix_issue": {
|
||||||
"fix": "Fix issue",
|
"fix": "Fix issue",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user