Skip to content

Commit

Permalink
Fix invalid trigger and conditions types
Browse files Browse the repository at this point in the history
  • Loading branch information
silamon committed Oct 25, 2023
1 parent 65ccb4f commit beddbe1
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/data/automation_i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,13 +661,15 @@ const tryDescribeTrigger = (
}`;
}

if (typeof trigger.platform) {
return hass.localize(
`ui.panel.config.automation.editor.triggers.type.${trigger.platform}.label`
);
}
return hass.localize(
`ui.panel.config.automation.editor.triggers.unknown_trigger`
const triggerType = trigger.platform
? hass.localize(
`ui.panel.config.automation.editor.triggers.type.${trigger.platform}.label`
)
: "";

return (
triggerType ||
hass.localize(`ui.panel.config.automation.editor.triggers.unknown_trigger`)
);
};

Expand Down Expand Up @@ -1105,12 +1107,16 @@ const tryDescribeCondition = (
return `When triggered by ${condition.id}`;
}

if (condition.condition) {
return hass.localize(
`ui.panel.config.automation.editor.conditions.type.${condition.condition}.label`
);
}
return hass.localize(
`ui.panel.config.automation.editor.conditions.unknown_condition`
const conditionType = condition.condition
? hass.localize(
`ui.panel.config.automation.editor.conditions.type.${condition.condition}.label`
)
: "";

return (
conditionType ||
hass.localize(
`ui.panel.config.automation.editor.conditions.unknown_condition`
)
);
};

0 comments on commit beddbe1

Please sign in to comment.