Delete weekdays key from time condition when emptied from the UI (#14992)

Co-authored-by: Paul Bottein <paul.bottein@gmail.com>
fixes undefined
This commit is contained in:
karwosts 2023-01-24 05:30:29 -08:00 committed by GitHub
parent 134670604b
commit 10369ff952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -152,7 +152,9 @@ export class HaTimeCondition extends LitElement implements ConditionElement {
delete newValue.mode_before;
Object.keys(newValue).forEach((key) =>
newValue[key] === undefined || newValue[key] === ""
newValue[key] === undefined ||
newValue[key] === "" ||
(Array.isArray(newValue[key]) && newValue[key].length === 0)
? delete newValue[key]
: {}
);