mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 16:26:43 +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`;
|
base += ` ${entity} is`;
|
||||||
|
|
||||||
if ("above" in trigger) {
|
if (trigger.above !== undefined) {
|
||||||
base += ` above ${trigger.above}`;
|
base += ` above ${trigger.above}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("below" in trigger && "above" in trigger) {
|
if (trigger.below !== undefined && trigger.above !== undefined) {
|
||||||
base += " and";
|
base += " and";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("below" in trigger) {
|
if (trigger.below !== undefined) {
|
||||||
base += ` below ${trigger.below}`;
|
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;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,17 +438,19 @@ export const describeCondition = (
|
|||||||
|
|
||||||
base += ` ${entity} is ${states}`;
|
base += ` ${entity} is ${states}`;
|
||||||
|
|
||||||
if ("for" in condition) {
|
if (condition.for) {
|
||||||
let duration: string;
|
let duration: string | null;
|
||||||
if (typeof condition.for === "number") {
|
if (typeof condition.for === "number") {
|
||||||
duration = `for ${secondsToDuration(condition.for)!}`;
|
duration = secondsToDuration(condition.for);
|
||||||
} else if (typeof condition.for === "string") {
|
} else if (typeof condition.for === "string") {
|
||||||
duration = `for ${condition.for}`;
|
duration = condition.for;
|
||||||
} else {
|
} else {
|
||||||
duration = `for ${JSON.stringify(condition.for)}`;
|
duration = formatDuration(condition.for);
|
||||||
}
|
}
|
||||||
|
if (duration) {
|
||||||
base += ` for ${duration}`;
|
base += ` for ${duration}`;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ export const describeAction = <T extends ActionType>(
|
|||||||
return "Activate a scene";
|
return "Activate a scene";
|
||||||
}
|
}
|
||||||
const sceneStateObj = entityId ? hass.states[entityId] : undefined;
|
const sceneStateObj = entityId ? hass.states[entityId] : undefined;
|
||||||
return `Active scene ${
|
return `Activate scene ${
|
||||||
sceneStateObj ? computeStateName(sceneStateObj) : entityId
|
sceneStateObj ? computeStateName(sceneStateObj) : entityId
|
||||||
}`;
|
}`;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user