Fallback to 0 for undefined offsets (#12823)

This commit is contained in:
Joakim Sørensen 2022-05-30 16:57:28 +02:00 committed by GitHub
parent 1e011bfe34
commit ab65ce819f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,7 +106,9 @@ export class HaCalendarTrigger extends LitElement implements TriggerElement {
const offsetType = ev.detail.value.offset_type === "before" ? "-" : "";
const newTrigger = {
...ev.detail.value,
offset: `${offsetType}${duration.hours}:${duration.minutes}:${duration.seconds}`,
offset: `${offsetType}${duration.hours ?? 0}:${duration.minutes ?? 0}:${
duration.seconds ?? 0
}`,
};
delete newTrigger.offset_type;
fireEvent(this, "value-changed", { value: newTrigger });