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