mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-20 15:56:35 +00:00
Automation description small fixes (#14055)
This commit is contained in:
parent
0c800344d2
commit
391cc95883
@ -60,18 +60,32 @@ export const describeTrigger = (
|
||||
|
||||
base += ` ${entity} is`;
|
||||
|
||||
if ("above" in trigger) {
|
||||
if (trigger.above !== undefined) {
|
||||
base += ` above ${trigger.above}`;
|
||||
}
|
||||
|
||||
if ("below" in trigger && "above" in trigger) {
|
||||
if (trigger.below !== undefined && trigger.above !== undefined) {
|
||||
base += " and";
|
||||
}
|
||||
|
||||
if ("below" in trigger) {
|
||||
if (trigger.below !== undefined) {
|
||||
base += ` below ${trigger.below}`;
|
||||
}
|
||||
|
||||
if (trigger.for) {
|
||||
let duration: string | null;
|
||||
if (typeof trigger.for === "number") {
|
||||
duration = secondsToDuration(trigger.for);
|
||||
} else if (typeof trigger.for === "string") {
|
||||
duration = trigger.for;
|
||||
} else {
|
||||
duration = formatDuration(trigger.for);
|
||||
}
|
||||
if (duration) {
|
||||
base += ` for ${duration}`;
|
||||
}
|
||||
}
|
||||
|
||||
return base;
|
||||
}
|
||||
|
||||
@ -424,17 +438,19 @@ export const describeCondition = (
|
||||
|
||||
base += ` ${entity} is ${states}`;
|
||||
|
||||
if ("for" in condition) {
|
||||
let duration: string;
|
||||
if (condition.for) {
|
||||
let duration: string | null;
|
||||
if (typeof condition.for === "number") {
|
||||
duration = `for ${secondsToDuration(condition.for)!}`;
|
||||
duration = secondsToDuration(condition.for);
|
||||
} else if (typeof condition.for === "string") {
|
||||
duration = `for ${condition.for}`;
|
||||
duration = condition.for;
|
||||
} else {
|
||||
duration = `for ${JSON.stringify(condition.for)}`;
|
||||
duration = formatDuration(condition.for);
|
||||
}
|
||||
if (duration) {
|
||||
base += ` for ${duration}`;
|
||||
}
|
||||
}
|
||||
|
||||
return base;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ export const describeAction = <T extends ActionType>(
|
||||
return "Activate a scene";
|
||||
}
|
||||
const sceneStateObj = entityId ? hass.states[entityId] : undefined;
|
||||
return `Active scene ${
|
||||
return `Activate scene ${
|
||||
sceneStateObj ? computeStateName(sceneStateObj) : entityId
|
||||
}`;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user