Skip to content

Commit

Permalink
Make device class timestamp more permissive
Browse files Browse the repository at this point in the history
  • Loading branch information
KapJI committed Sep 11, 2021
1 parent d0edbec commit efeb22f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/panels/lovelace/cards/hui-glance-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { customElement, property, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { ifDefined } from "lit/directives/if-defined";
import checkValidDate from "../../../common/datetime/check_valid_date";
import relativeTime from "../../../common/datetime/relative_time";
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
import { computeDomain } from "../../../common/entity/compute_domain";
Expand All @@ -17,7 +18,6 @@ import { computeStateName } from "../../../common/entity/compute_state_name";
import "../../../components/entity/state-badge";
import "../../../components/ha-card";
import "../../../components/ha-icon";
import { UNAVAILABLE_STATES } from "../../../data/entity";
import {
ActionHandlerEvent,
CallServiceActionConfig,
Expand Down Expand Up @@ -319,7 +319,7 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
${computeDomain(entityConf.entity) === "sensor" &&
stateObj.attributes.device_class ===
SENSOR_DEVICE_CLASS_TIMESTAMP &&
!UNAVAILABLE_STATES.includes(stateObj.state)
checkValidDate(new Date(stateObj.state))
? html`
<hui-timestamp-display
.hass=${this.hass}
Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/entity-rows/hui-sensor-entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "lit";
import { customElement, property, state } from "lit/decorators";
import { computeStateDisplay } from "../../../common/entity/compute_state_display";
import { UNAVAILABLE_STATES } from "../../../data/entity";
import checkValidDate from "../../../common/datetime/check_valid_date";
import { ActionHandlerEvent } from "../../../data/lovelace";
import { SENSOR_DEVICE_CLASS_TIMESTAMP } from "../../../data/sensor";
import { HomeAssistant } from "../../../types";
Expand Down Expand Up @@ -71,7 +71,7 @@ class HuiSensorEntityRow extends LitElement implements LovelaceRow {
>
${stateObj.attributes.device_class ===
SENSOR_DEVICE_CLASS_TIMESTAMP &&
!UNAVAILABLE_STATES.includes(stateObj.state)
checkValidDate(new Date(stateObj.state))
? html`
<hui-timestamp-display
.hass=${this.hass}
Expand Down
4 changes: 2 additions & 2 deletions src/state-summary/state-card-display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import type { HassEntity } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import checkValidDate from "../common/datetime/check_valid_date";
import { computeDomain } from "../common/entity/compute_domain";
import { computeStateDisplay } from "../common/entity/compute_state_display";
import { computeRTL } from "../common/util/compute_rtl";
import "../components/entity/state-info";
import { UNAVAILABLE_STATES } from "../data/entity";
import { SENSOR_DEVICE_CLASS_TIMESTAMP } from "../data/sensor";
import "../panels/lovelace/components/hui-timestamp-display";
import { haStyle } from "../resources/styles";
Expand Down Expand Up @@ -42,7 +42,7 @@ export class StateCardDisplay extends LitElement {
${computeDomain(this.stateObj.entity_id) === "sensor" &&
this.stateObj.attributes.device_class ===
SENSOR_DEVICE_CLASS_TIMESTAMP &&
!UNAVAILABLE_STATES.includes(this.stateObj.state)
checkValidDate(new Date(this.stateObj.state))
? html` <hui-timestamp-display
.hass=${this.hass}
.ts=${new Date(this.stateObj.state)}
Expand Down

0 comments on commit efeb22f

Please sign in to comment.