mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
improve duration rendering for state trigger (#13723)
This commit is contained in:
parent
f164ad0b89
commit
78187c5b0b
@ -1,3 +1,4 @@
|
|||||||
|
import { formatDuration } from "../common/datetime/format_duration";
|
||||||
import secondsToDuration from "../common/datetime/seconds_to_duration";
|
import secondsToDuration from "../common/datetime/seconds_to_duration";
|
||||||
import { ensureArray } from "../common/ensure-array";
|
import { ensureArray } from "../common/ensure-array";
|
||||||
import { computeStateName } from "../common/entity/compute_state_name";
|
import { computeStateName } from "../common/entity/compute_state_name";
|
||||||
@ -140,17 +141,19 @@ export const describeTrigger = (
|
|||||||
base += ` to ${to}`;
|
base += ` to ${to}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("for" in trigger) {
|
if (trigger.for) {
|
||||||
let duration: string;
|
let duration: string | null;
|
||||||
if (typeof trigger.for === "number") {
|
if (typeof trigger.for === "number") {
|
||||||
duration = `${secondsToDuration(trigger.for)!}`;
|
duration = secondsToDuration(trigger.for);
|
||||||
} else if (typeof trigger.for === "string") {
|
} else if (typeof trigger.for === "string") {
|
||||||
duration = `${trigger.for}`;
|
duration = trigger.for;
|
||||||
} else {
|
} else {
|
||||||
duration = `${JSON.stringify(trigger.for)}`;
|
duration = formatDuration(trigger.for);
|
||||||
}
|
}
|
||||||
|
|
||||||
base += ` for ${duration}`;
|
if (duration) {
|
||||||
|
base += ` for ${duration}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return base;
|
return base;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user