mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Add before offset to sun condition description (#18152)
This commit is contained in:
parent
ae35fd1eb8
commit
a3532a41da
@ -955,23 +955,43 @@ const tryDescribeCondition = (
|
|||||||
base += " sun";
|
base += " sun";
|
||||||
|
|
||||||
if (condition.after) {
|
if (condition.after) {
|
||||||
let duration = "";
|
let after_duration = "";
|
||||||
|
|
||||||
if (condition.after_offset) {
|
if (condition.after_offset) {
|
||||||
if (typeof condition.after_offset === "number") {
|
if (typeof condition.after_offset === "number") {
|
||||||
duration = ` offset by ${secondsToDuration(condition.after_offset)!}`;
|
after_duration = ` offset by ${secondsToDuration(
|
||||||
|
condition.after_offset
|
||||||
|
)!}`;
|
||||||
} else if (typeof condition.after_offset === "string") {
|
} else if (typeof condition.after_offset === "string") {
|
||||||
duration = ` offset by ${condition.after_offset}`;
|
after_duration = ` offset by ${condition.after_offset}`;
|
||||||
} else {
|
} else {
|
||||||
duration = ` offset by ${JSON.stringify(condition.after_offset)}`;
|
after_duration = ` offset by ${JSON.stringify(
|
||||||
|
condition.after_offset
|
||||||
|
)}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
base += ` after ${condition.after}${duration}`;
|
base += ` after ${condition.after}${after_duration}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (condition.before) {
|
if (condition.before) {
|
||||||
base += ` before ${condition.before}`;
|
let before_duration = "";
|
||||||
|
|
||||||
|
if (condition.before_offset) {
|
||||||
|
if (typeof condition.before_offset === "number") {
|
||||||
|
before_duration = ` offset by ${secondsToDuration(
|
||||||
|
condition.before_offset
|
||||||
|
)!}`;
|
||||||
|
} else if (typeof condition.before_offset === "string") {
|
||||||
|
before_duration = ` offset by ${condition.before_offset}`;
|
||||||
|
} else {
|
||||||
|
before_duration = ` offset by ${JSON.stringify(
|
||||||
|
condition.before_offset
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
base += ` before ${condition.before}${before_duration}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return base;
|
return base;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user