mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Graceful fallback if translations for device automations are missing (#4824)
* Graceful fallback if translations for device automations are missing * Update src/data/device_automation.ts Co-Authored-By: Bram Kragten <mail@bramkragten.nl> * Update src/data/device_automation.ts Co-Authored-By: Bram Kragten <mail@bramkragten.nl> * Update src/data/device_automation.ts Co-Authored-By: Bram Kragten <mail@bramkragten.nl> * tweak Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
parent
981c798e22
commit
e7e8dff0ec
@ -101,14 +101,16 @@ export const localizeDeviceAutomationAction = (
|
|||||||
action: DeviceAction
|
action: DeviceAction
|
||||||
) => {
|
) => {
|
||||||
const state = action.entity_id ? hass.states[action.entity_id] : undefined;
|
const state = action.entity_id ? hass.states[action.entity_id] : undefined;
|
||||||
return hass.localize(
|
return (
|
||||||
`component.${action.domain}.device_automation.action_type.${action.type}`,
|
|
||||||
"entity_name",
|
|
||||||
state ? computeStateName(state) : "<unknown>",
|
|
||||||
"subtype",
|
|
||||||
hass.localize(
|
hass.localize(
|
||||||
`component.${action.domain}.device_automation.action_subtype.${action.subtype}`
|
`component.${action.domain}.device_automation.action_type.${action.type}`,
|
||||||
)
|
"entity_name",
|
||||||
|
state ? computeStateName(state) : action.entity_id || "<unknown>",
|
||||||
|
"subtype",
|
||||||
|
hass.localize(
|
||||||
|
`component.${action.domain}.device_automation.action_subtype.${action.subtype}`
|
||||||
|
) || action.subtype
|
||||||
|
) || `"${action.subtype}" ${action.type}`
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -119,14 +121,16 @@ export const localizeDeviceAutomationCondition = (
|
|||||||
const state = condition.entity_id
|
const state = condition.entity_id
|
||||||
? hass.states[condition.entity_id]
|
? hass.states[condition.entity_id]
|
||||||
: undefined;
|
: undefined;
|
||||||
return hass.localize(
|
return (
|
||||||
`component.${condition.domain}.device_automation.condition_type.${condition.type}`,
|
|
||||||
"entity_name",
|
|
||||||
state ? computeStateName(state) : "<unknown>",
|
|
||||||
"subtype",
|
|
||||||
hass.localize(
|
hass.localize(
|
||||||
`component.${condition.domain}.device_automation.condition_subtype.${condition.subtype}`
|
`component.${condition.domain}.device_automation.condition_type.${condition.type}`,
|
||||||
)
|
"entity_name",
|
||||||
|
state ? computeStateName(state) : condition.entity_id || "<unknown>",
|
||||||
|
"subtype",
|
||||||
|
hass.localize(
|
||||||
|
`component.${condition.domain}.device_automation.condition_subtype.${condition.subtype}`
|
||||||
|
) || condition.subtype
|
||||||
|
) || `"${condition.subtype}" ${condition.type}`
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -135,13 +139,15 @@ export const localizeDeviceAutomationTrigger = (
|
|||||||
trigger: DeviceTrigger
|
trigger: DeviceTrigger
|
||||||
) => {
|
) => {
|
||||||
const state = trigger.entity_id ? hass.states[trigger.entity_id] : undefined;
|
const state = trigger.entity_id ? hass.states[trigger.entity_id] : undefined;
|
||||||
return hass.localize(
|
return (
|
||||||
`component.${trigger.domain}.device_automation.trigger_type.${trigger.type}`,
|
|
||||||
"entity_name",
|
|
||||||
state ? computeStateName(state) : "<unknown>",
|
|
||||||
"subtype",
|
|
||||||
hass.localize(
|
hass.localize(
|
||||||
`component.${trigger.domain}.device_automation.trigger_subtype.${trigger.subtype}`
|
`component.${trigger.domain}.device_automation.trigger_type.${trigger.type}`,
|
||||||
)
|
"entity_name",
|
||||||
|
state ? computeStateName(state) : trigger.entity_id || "<unknown>",
|
||||||
|
"subtype",
|
||||||
|
hass.localize(
|
||||||
|
`component.${trigger.domain}.device_automation.trigger_subtype.${trigger.subtype}`
|
||||||
|
) || trigger.subtype
|
||||||
|
) || `"${trigger.subtype}" ${trigger.type}`
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user