From 10369ff952fe6a9a868d0bbe6c0023b1d5c070bf Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Tue, 24 Jan 2023 05:30:29 -0800 Subject: [PATCH] Delete weekdays key from time condition when emptied from the UI (#14992) Co-authored-by: Paul Bottein fixes undefined --- .../condition/types/ha-automation-condition-time.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/panels/config/automation/condition/types/ha-automation-condition-time.ts b/src/panels/config/automation/condition/types/ha-automation-condition-time.ts index ce08d1654d..108644ffe5 100644 --- a/src/panels/config/automation/condition/types/ha-automation-condition-time.ts +++ b/src/panels/config/automation/condition/types/ha-automation-condition-time.ts @@ -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] : {} );