diff --git a/webapp/src/components/NodeEditor/OptionManager/TriggerTime.tsx b/webapp/src/components/NodeEditor/OptionManager/TriggerTime.tsx index d0076d7..71623a3 100644 --- a/webapp/src/components/NodeEditor/OptionManager/TriggerTime.tsx +++ b/webapp/src/components/NodeEditor/OptionManager/TriggerTime.tsx @@ -20,7 +20,7 @@ export const TriggerTime: OptionManager = { value={state.at} onChange={_at => setState({ ...state, - at: _at, + at: _at ?? {}, })} /> diff --git a/webapp/src/types/automations/triggers.ts b/webapp/src/types/automations/triggers.ts index b78c9a8..989da96 100644 --- a/webapp/src/types/automations/triggers.ts +++ b/webapp/src/types/automations/triggers.ts @@ -50,7 +50,7 @@ export interface AutomationTriggerTemplate extends AutomationTriggerBase { } export interface AutomationTriggerTime extends AutomationTriggerBase { platform: 'time'; - at: string | string[]; + at: AutomationTime; } export interface AutomationTriggerTimePattern extends AutomationTriggerBase { platform: 'time_pattern'; @@ -64,7 +64,7 @@ export interface AutomationTriggerWebhook extends AutomationTriggerBase { } export interface AutomationTriggerZone extends AutomationTriggerBase { platform: 'zone'; - entity_id: string; + entity_id: string | string[]; zone: string; event: 'enter' | 'leave'; } diff --git a/webapp/src/utils/defaults.ts b/webapp/src/utils/defaults.ts index 71c8ef2..2ebaf55 100644 --- a/webapp/src/utils/defaults.ts +++ b/webapp/src/utils/defaults.ts @@ -6,7 +6,7 @@ export const getConditionDefaultValues = (condition: AutomationCondition['condit if ( (condition === 'or') || (condition === 'and') || - (condition === 'not') + (condition === 'not') ) { return { conditions: [] @@ -29,7 +29,7 @@ export const getConditionDefaultValues = (condition: AutomationCondition['condit } as TimeCondition['condition_data'] } else if (condition === 'trigger') { return { - id: [] + id: "" } as TriggerCondition['condition_data'] } else if (condition === 'zone') { return { @@ -42,12 +42,12 @@ export const getConditionDefaultValues = (condition: AutomationCondition['condit } export const defaultAutomation = (id: string): AutomationData => ({ - metadata: { - id, - alias: "New Automation", - description: "", - mode: "single", - }, - trigger: [], - sequence: [], + metadata: { + id, + alias: "New Automation", + description: "", + mode: "single", + }, + trigger: [], + sequence: [], })