Skip to content

Commit

Permalink
Rename live timer to remaining time and remove remaining attribute fr…
Browse files Browse the repository at this point in the history
…om state content list
  • Loading branch information
piitaya committed Jul 15, 2024
1 parent dac22e5 commit d95f123
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 20 deletions.
5 changes: 3 additions & 2 deletions src/components/entity/ha-entity-state-content-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import type { HaComboBox } from "../ha-combo-box";
const HIDDEN_ATTRIBUTES = [
"access_token",
"available_modes",
"battery_icon",
"battery_level",
"code_arm_required",
"code_format",
"color_modes",
Expand Down Expand Up @@ -51,6 +53,7 @@ const HIDDEN_ATTRIBUTES = [
"precipitation_unit",
"preset_modes",
"pressure_unit",
"remaining",
"sound_mode_list",
"source_list",
"state_class",
Expand All @@ -64,8 +67,6 @@ const HIDDEN_ATTRIBUTES = [
"unit_of_measurement",
"visibility_unit",
"wind_speed_unit",
"battery_icon",
"battery_level",
];

@customElement("ha-entity-state-content-picker")
Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/cards/hui-tile-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
return ["state", "current_temperature"];
}
if (domain === "update") {
return "update_state";
return "install_status";
}
if (domain === "timer") {
return "timer_state";
return "reamining_time";
}
return "state";
}
Expand Down
6 changes: 3 additions & 3 deletions src/panels/lovelace/entity-rows/hui-timer-entity-row.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LitElement, PropertyValues, html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import "../../../state-display/state-display-timer";
import "../../../state-display/ha-timer-remaining-time";
import { HomeAssistant } from "../../../types";
import { hasConfigOrEntityChanged } from "../common/has-changed";
import "../components/hui-generic-entity-row";
Expand Down Expand Up @@ -38,10 +38,10 @@ class HuiTimerEntityRow extends LitElement {
return html`
<hui-generic-entity-row .hass=${this.hass} .config=${this._config}>
<div class="text-content">
<state-display-timer
<ha-timer-remaining-time
.hass=${this.hass}
.stateObj=${stateObj}
></state-display-timer>
></ha-timer-remaining-time>
</div>
</hui-generic-entity-row>
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { customElement, property, state } from "lit/decorators";
import { computeDisplayTimer, timerTimeRemaining } from "../data/timer";
import type { HomeAssistant } from "../types";

@customElement("state-display-timer")
class StateDisplayTimer extends ReactiveElement {
@customElement("ha-timer-remaining-time")
class HaTimerRemainingTime extends ReactiveElement {
@property({ attribute: false }) public hass!: HomeAssistant;

@property({ attribute: false }) public stateObj!: HassEntity;
Expand Down Expand Up @@ -69,6 +69,6 @@ class StateDisplayTimer extends ReactiveElement {

declare global {
interface HTMLElementTagNameMap {
"state-display-timer": StateDisplayTimer;
"ha-timer-remaining-time": HaTimerRemainingTime;
}
}
12 changes: 6 additions & 6 deletions src/state-display/state-display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import type { HomeAssistant } from "../types";
const TIMESTAMP_STATE_DOMAINS = ["button", "input_button", "scene"];

export const STATE_DISPLAY_SPECIAL_CONTENT = [
"live_timer",
"remaining_time",
"install_status",
] as const;

export const STATE_DISPLAY_SPECIAL_CONTENT_DOMAINS: Record<
(typeof STATE_DISPLAY_SPECIAL_CONTENT)[number],
string[]
> = {
live_timer: ["timer"],
remaining_time: ["timer"],
install_status: ["update"],
};

Expand Down Expand Up @@ -94,13 +94,13 @@ class StateDisplay extends LitElement {
${computeUpdateStateDisplay(stateObj as UpdateEntity, this.hass!)}
`;
}
if (content === "live_timer") {
import("./state-display-timer");
if (content === "remaining_time") {
import("./ha-timer-remaining-time");
return html`
<state-display-timer
<ha-timer-remaining-time
.hass=${this.hass}
.stateObj=${stateObj}
></state-display-timer>
></ha-timer-remaining-time>
`;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/state-summary/state-card-timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators";
import "../components/entity/state-info";
import { haStyle } from "../resources/styles";
import "../state-display/state-display-timer";
import "../state-display/ha-timer-remaining-time";
import { HomeAssistant } from "../types";

@customElement("state-card-timer")
Expand All @@ -23,10 +23,10 @@ class StateCardTimer extends LitElement {
.inDialog=${this.inDialog}
></state-info>
<div class="state">
<state-display-timer
<ha-timer-remaining-time
.hass=${this.hass}
.stateObj=${this.stateObj}
></state-display-timer>
></ha-timer-remaining-time>
</div>
</div>
`;
Expand Down
2 changes: 1 addition & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@
"state": "State",
"last_changed": "Last changed",
"last_updated": "Last updated",
"live_timer": "Live timer",
"remaining_time": "Remaining time",
"install_status": "Install status"
}
},
Expand Down

0 comments on commit d95f123

Please sign in to comment.