Correctly handle seconds in top "delay" key (#8415)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
Philip Allgaier 2021-02-19 11:03:25 +01:00 committed by GitHub
parent d51fd1e2f9
commit 77911980cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,13 +22,17 @@ export class HaDelayAction extends LitElement implements ActionElement {
let data: HaFormTimeData = {};
if (typeof this.action.delay !== "object") {
if (isNaN(this.action.delay)) {
const parts = this.action.delay?.toString().split(":") || [];
data = {
hours: Number(parts[0]),
minutes: Number(parts[1]),
seconds: Number(parts[2]),
milliseconds: Number(parts[3]),
hours: Number(parts[0]) || 0,
minutes: Number(parts[1]) || 0,
seconds: Number(parts[2]) || 0,
milliseconds: Number(parts[3]) || 0,
};
} else {
data = { seconds: this.action.delay };
}
} else {
const { days, minutes, seconds, milliseconds } = this.action.delay;
let { hours } = this.action.delay || 0;
@ -46,7 +50,8 @@ export class HaDelayAction extends LitElement implements ActionElement {
.data=${data}
enableMillisecond
@value-changed=${this._valueChanged}
></ha-time-input>
>
</ha-time-input>
`;
}