Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions src/panels/lovelace/common/handle-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { forwardHaptic } from "../../../data/haptics";
import { ActionConfig } from "../../../data/lovelace";
import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box";
import { HomeAssistant } from "../../../types";
import { showToast } from "../../../util/toast";
import { toggleEntity } from "./entity/toggle-entity";

declare global {
Expand Down Expand Up @@ -54,9 +55,12 @@ export const handleAction = async (
text:
actionConfig.confirmation.text ||
hass.localize(
"ui.panel.lovelace.cards.action_confirmation",
"ui.panel.lovelace.cards.actions.action_confirmation",
"action",
actionConfig.action
hass.localize(
"ui.panel.lovelace.editor.action-editor.actions." +
actionConfig.action
) || actionConfig.action
),
}))
) {
Expand All @@ -70,29 +74,58 @@ export const handleAction = async (
fireEvent(node, "hass-more-info", {
entityId: config.entity ? config.entity : config.camera_image!,
});
} else {
showToast(node, {
message: hass.localize(
"ui.panel.lovelace.cards.actions.no_entity_more_info"
),
});
forwardHaptic("failure");
}
break;
}
case "navigate":
if (actionConfig.navigation_path) {
navigate(node, actionConfig.navigation_path);
} else {
showToast(node, {
message: hass.localize(
"ui.panel.lovelace.cards.actions.no_navigation_path"
),
});
forwardHaptic("failure");
}
break;
case "url": {
if (actionConfig.url_path) {
window.open(actionConfig.url_path);
} else {
showToast(node, {
message: hass.localize("ui.panel.lovelace.cards.actions.no_url"),
});
forwardHaptic("failure");
}
break;
}
case "toggle": {
if (config.entity) {
toggleEntity(hass, config.entity!);
forwardHaptic("light");
} else {
showToast(node, {
message: hass.localize(
"ui.panel.lovelace.cards.actions.no_entity_toggle"
),
});
forwardHaptic("failure");
}
break;
}
case "call-service": {
if (!actionConfig.service) {
showToast(node, {
message: hass.localize("ui.panel.lovelace.cards.actions.no_service"),
});
forwardHaptic("failure");
return;
}
Expand Down
15 changes: 11 additions & 4 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2421,7 +2421,14 @@
"lovelace": {
"cards": {
"confirm_delete": "Are you sure you want to delete this card?",
"action_confirmation": "Are you sure you want to exectue action \"{action}\"?",
"actions": {
"action_confirmation": "Are you sure you want to exectue action \"{action}\"?",
"no_entity_more_info": "No entity provided for more info dialog",
"no_entity_toggle": "No entity provided to toggle",
"no_navigation_path": "No navigation path specified",
"no_url": "No URL to open specified",
"no_service": "No service for execution specified"
},
"empty_state": {
"title": "Welcome Home",
"no_devices": "This page allows you to control your devices, however it looks like you have no devices set up yet. Head to the integrations page to get started.",
Expand All @@ -2444,7 +2451,7 @@
"url": "Open window to {url_path}",
"toggle": "Toggle {name}",
"call_service": "Call service {name}",
"more_info": "Show more-info: {name}"
"more_info": "Show more info: {name}"
},
"safe-mode": {
"header": "Safe Mode Activated",
Expand Down Expand Up @@ -2673,7 +2680,7 @@
"button": {
"name": "Button",
"description": "The Button card allows you to add buttons to perform tasks.",
"default_action_help": "The default action depends on the entity's capabilities, it will either be toggled or the more info will be shown."
"default_action_help": "The default action depends on the entity's capabilities, it will either be toggled or the more info dialog will be shown."
},
"entity-filter": {
"name": "Entity Filter",
Expand Down Expand Up @@ -2789,7 +2796,7 @@
},
"picture-glance": {
"name": "Picture Glance",
"description": "The Picture Glance card shows an image and corresponding entity states as an icon. The entities on the right side allow toggle actions, others show the more information dialog.",
"description": "The Picture Glance card shows an image and corresponding entity states as an icon. The entities on the right side allow toggle actions, others show the more info dialog.",
"state_entity": "State Entity"
},
"plant-status": {
Expand Down