mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Cleanup remaining entity not-found warnings (#2779)
This commit is contained in:
parent
2ada32be02
commit
3db79607b7
@ -12,6 +12,7 @@ import { styleMap } from "lit-html/directives/style-map";
|
|||||||
import "@material/mwc-ripple";
|
import "@material/mwc-ripple";
|
||||||
|
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
|
import "../components/hui-warning";
|
||||||
|
|
||||||
import isValidEntityId from "../../../common/entity/valid_entity_id";
|
import isValidEntityId from "../../../common/entity/valid_entity_id";
|
||||||
import stateIcon from "../../../common/entity/state_icon";
|
import stateIcon from "../../../common/entity/state_icon";
|
||||||
@ -91,9 +92,13 @@ class HuiEntityButtonCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
if (!stateObj) {
|
if (!stateObj) {
|
||||||
return html`
|
return html`
|
||||||
<div class="not-found">
|
<hui-warning
|
||||||
Entity not available: ${this._config.entity}
|
>${this.hass.localize(
|
||||||
</div>
|
"ui.panel.lovelace.warning.entity_not_found",
|
||||||
|
"entity",
|
||||||
|
this._config.entity
|
||||||
|
)}</hui-warning
|
||||||
|
>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,11 +162,6 @@ class HuiEntityButtonCard extends LitElement implements LovelaceCard {
|
|||||||
ha-icon[data-state="unavailable"] {
|
ha-icon[data-state="unavailable"] {
|
||||||
color: var(--state-icon-unavailable-color);
|
color: var(--state-icon-unavailable-color);
|
||||||
}
|
}
|
||||||
.not-found {
|
|
||||||
flex: 1;
|
|
||||||
background-color: yellow;
|
|
||||||
padding: 8px;
|
|
||||||
}
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,11 +297,6 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
|
|||||||
padding-top: calc(var(--base-unit) * 0.15);
|
padding-top: calc(var(--base-unit) * 0.15);
|
||||||
font-size: calc(var(--base-unit) * 0.3);
|
font-size: calc(var(--base-unit) * 0.3);
|
||||||
}
|
}
|
||||||
.not-found {
|
|
||||||
flex: 1;
|
|
||||||
background-color: yellow;
|
|
||||||
padding: 8px;
|
|
||||||
}
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import { LovelaceCardConfig, ActionConfig } from "../../../data/lovelace";
|
|||||||
import { longPress } from "../common/directives/long-press-directive";
|
import { longPress } from "../common/directives/long-press-directive";
|
||||||
import { EntityConfig } from "../entity-rows/types";
|
import { EntityConfig } from "../entity-rows/types";
|
||||||
import { processConfigEntities } from "../common/process-config-entities";
|
import { processConfigEntities } from "../common/process-config-entities";
|
||||||
|
import { handleClick } from "../common/handle-click";
|
||||||
|
|
||||||
import computeStateDisplay from "../../../common/entity/compute_state_display";
|
import computeStateDisplay from "../../../common/entity/compute_state_display";
|
||||||
import computeStateName from "../../../common/entity/compute_state_name";
|
import computeStateName from "../../../common/entity/compute_state_name";
|
||||||
@ -21,7 +22,7 @@ import applyThemesOnElement from "../../../common/dom/apply_themes_on_element";
|
|||||||
import "../../../components/entity/state-badge";
|
import "../../../components/entity/state-badge";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-icon";
|
import "../../../components/ha-icon";
|
||||||
import { handleClick } from "../common/handle-click";
|
import "../components/hui-warning";
|
||||||
|
|
||||||
export interface ConfigEntity extends EntityConfig {
|
export interface ConfigEntity extends EntityConfig {
|
||||||
tap_action?: ActionConfig;
|
tap_action?: ActionConfig;
|
||||||
@ -176,10 +177,6 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
|
|||||||
state-badge {
|
state-badge {
|
||||||
margin: 8px 0;
|
margin: 8px 0;
|
||||||
}
|
}
|
||||||
.not-found {
|
|
||||||
background-color: yellow;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@ -189,10 +186,13 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
if (!stateObj) {
|
if (!stateObj) {
|
||||||
return html`
|
return html`
|
||||||
<div class="entity not-found">
|
<hui-warning
|
||||||
<div class="name">${entityConf.entity}</div>
|
>${this.hass!.localize(
|
||||||
Entity Not Available
|
"ui.panel.lovelace.warning.entity_not_found",
|
||||||
</div>
|
"entity",
|
||||||
|
entityConf.entity
|
||||||
|
)}</hui-warning
|
||||||
|
>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import { LovelaceCard, LovelaceCardEditor } from "../types";
|
|||||||
import { LovelaceCardConfig } from "../../../data/lovelace";
|
import { LovelaceCardConfig } from "../../../data/lovelace";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
|
import { fetchRecent } from "../../../data/history";
|
||||||
|
|
||||||
import applyThemesOnElement from "../../../common/dom/apply_themes_on_element";
|
import applyThemesOnElement from "../../../common/dom/apply_themes_on_element";
|
||||||
import computeStateName from "../../../common/entity/compute_state_name";
|
import computeStateName from "../../../common/entity/compute_state_name";
|
||||||
@ -19,7 +20,7 @@ import stateIcon from "../../../common/entity/state_icon";
|
|||||||
|
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-icon";
|
import "../../../components/ha-icon";
|
||||||
import { fetchRecent } from "../../../data/history";
|
import "../components/hui-warning";
|
||||||
|
|
||||||
const midPoint = (
|
const midPoint = (
|
||||||
_Ax: number,
|
_Ax: number,
|
||||||
@ -199,15 +200,27 @@ class HuiSensorCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
const stateObj = this.hass.states[this._config.entity];
|
const stateObj = this.hass.states[this._config.entity];
|
||||||
|
|
||||||
|
if (!stateObj) {
|
||||||
|
return html`
|
||||||
|
<hui-warning
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.lovelace.warning.entity_not_found",
|
||||||
|
"entity",
|
||||||
|
this._config.entity
|
||||||
|
)}</hui-warning
|
||||||
|
>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
let graph;
|
let graph;
|
||||||
|
|
||||||
if (stateObj && this._config.graph === "line") {
|
if (stateObj && this._config.graph === "line") {
|
||||||
if (!stateObj.attributes.unit_of_measurement) {
|
if (!stateObj.attributes.unit_of_measurement) {
|
||||||
graph = html`
|
return html`
|
||||||
<div class="not-found">
|
<hui-warning
|
||||||
Entity: ${this._config.entity} - Has no Unit of Measurement and
|
>Entity: ${this._config.entity} - Has no Unit of Measurement and
|
||||||
therefore can not display a line graph.
|
therefore can not display a line graph.</hui-warning
|
||||||
</div>
|
>
|
||||||
`;
|
`;
|
||||||
} else if (!this._history) {
|
} else if (!this._history) {
|
||||||
graph = svg`
|
graph = svg`
|
||||||
@ -233,34 +246,26 @@ class HuiSensorCard extends LitElement implements LovelaceCard {
|
|||||||
return html`
|
return html`
|
||||||
${this.renderStyle()}
|
${this.renderStyle()}
|
||||||
<ha-card @click="${this._handleClick}">
|
<ha-card @click="${this._handleClick}">
|
||||||
${!stateObj
|
<div class="flex">
|
||||||
? html`
|
<div class="icon">
|
||||||
<div class="not-found">
|
<ha-icon
|
||||||
Entity not available: ${this._config.entity}
|
.icon="${this._config.icon || stateIcon(stateObj)}"
|
||||||
</div>
|
></ha-icon>
|
||||||
`
|
</div>
|
||||||
: html`
|
<div class="header">
|
||||||
<div class="flex">
|
<span class="name"
|
||||||
<div class="icon">
|
>${this._config.name || computeStateName(stateObj)}</span
|
||||||
<ha-icon
|
>
|
||||||
.icon="${this._config.icon || stateIcon(stateObj)}"
|
</div>
|
||||||
></ha-icon>
|
</div>
|
||||||
</div>
|
<div class="flex info">
|
||||||
<div class="header">
|
<span id="value">${stateObj.state}</span>
|
||||||
<span class="name"
|
<span id="measurement"
|
||||||
>${this._config.name || computeStateName(stateObj)}</span
|
>${this._config.unit ||
|
||||||
>
|
stateObj.attributes.unit_of_measurement}</span
|
||||||
</div>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex info">
|
<div class="graph"><div>${graph}</div></div>
|
||||||
<span id="value">${stateObj.state}</span>
|
|
||||||
<span id="measurement"
|
|
||||||
>${this._config.unit ||
|
|
||||||
stateObj.attributes.unit_of_measurement}</span
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="graph"><div>${graph}</div></div>
|
|
||||||
`}
|
|
||||||
</ha-card>
|
</ha-card>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@ -399,11 +404,6 @@ class HuiSensorCard extends LitElement implements LovelaceCard {
|
|||||||
align-self: flex-end;
|
align-self: flex-end;
|
||||||
margin: auto 8px;
|
margin: auto 8px;
|
||||||
}
|
}
|
||||||
.not-found {
|
|
||||||
flex: 1;
|
|
||||||
background-color: yellow;
|
|
||||||
padding: 8px;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
import "../../../components/entity/state-badge";
|
|
||||||
import "../../../components/ha-relative-time";
|
|
||||||
import "../../../components/ha-icon";
|
|
||||||
|
|
||||||
import computeStateName from "../../../common/entity/compute_state_name";
|
import computeStateName from "../../../common/entity/compute_state_name";
|
||||||
import {
|
import {
|
||||||
LitElement,
|
LitElement,
|
||||||
@ -11,10 +7,16 @@ import {
|
|||||||
PropertyValues,
|
PropertyValues,
|
||||||
property,
|
property,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
|
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { EntitiesCardEntityConfig } from "../cards/hui-entities-card";
|
import { EntitiesCardEntityConfig } from "../cards/hui-entities-card";
|
||||||
import { computeRTL } from "../../../common/util/compute_rtl";
|
import { computeRTL } from "../../../common/util/compute_rtl";
|
||||||
|
|
||||||
|
import "../../../components/entity/state-badge";
|
||||||
|
import "../../../components/ha-relative-time";
|
||||||
|
import "../../../components/ha-icon";
|
||||||
|
import "../components/hui-warning";
|
||||||
|
|
||||||
class HuiGenericEntityRow extends LitElement {
|
class HuiGenericEntityRow extends LitElement {
|
||||||
@property() public hass?: HomeAssistant;
|
@property() public hass?: HomeAssistant;
|
||||||
@property() public config?: EntitiesCardEntityConfig;
|
@property() public config?: EntitiesCardEntityConfig;
|
||||||
@ -30,7 +32,13 @@ class HuiGenericEntityRow extends LitElement {
|
|||||||
|
|
||||||
if (!stateObj) {
|
if (!stateObj) {
|
||||||
return html`
|
return html`
|
||||||
<div class="not-found">Entity not available: [[config.entity]]</div>
|
<hui-warning
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.lovelace.warning.entity_not_found",
|
||||||
|
"entity",
|
||||||
|
this.config.entity
|
||||||
|
)}</hui-warning
|
||||||
|
>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,11 +115,6 @@ class HuiGenericEntityRow extends LitElement {
|
|||||||
display: block;
|
display: block;
|
||||||
color: var(--secondary-text-color);
|
color: var(--secondary-text-color);
|
||||||
}
|
}
|
||||||
.not-found {
|
|
||||||
flex: 1;
|
|
||||||
background-color: yellow;
|
|
||||||
padding: 8px;
|
|
||||||
}
|
|
||||||
state-badge {
|
state-badge {
|
||||||
flex: 0 0 40px;
|
flex: 0 0 40px;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user