mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 03:36:44 +00:00
✨ Fire custom LL event (#4361)
This commit is contained in:
parent
c2d551bb7c
commit
dd17a153d2
@ -69,6 +69,10 @@ export interface NoActionConfig extends BaseActionConfig {
|
||||
action: "none";
|
||||
}
|
||||
|
||||
export interface CustomActionConfig extends BaseActionConfig {
|
||||
action: "fire-dom-event";
|
||||
}
|
||||
|
||||
export interface BaseActionConfig {
|
||||
confirmation?: ConfirmationRestrictionConfig;
|
||||
}
|
||||
@ -88,7 +92,8 @@ export type ActionConfig =
|
||||
| NavigateActionConfig
|
||||
| UrlActionConfig
|
||||
| MoreInfoActionConfig
|
||||
| NoActionConfig;
|
||||
| NoActionConfig
|
||||
| CustomActionConfig;
|
||||
|
||||
export const fetchConfig = (
|
||||
conn: Connection,
|
||||
|
@ -5,6 +5,12 @@ import { toggleEntity } from "./entity/toggle-entity";
|
||||
import { ActionConfig } from "../../../data/lovelace";
|
||||
import { forwardHaptic } from "../../../data/haptics";
|
||||
|
||||
declare global {
|
||||
interface HASSDomEvents {
|
||||
"ll-custom": ActionConfig;
|
||||
}
|
||||
}
|
||||
|
||||
export const handleAction = (
|
||||
node: HTMLElement,
|
||||
hass: HomeAssistant,
|
||||
@ -76,7 +82,7 @@ export const handleAction = (
|
||||
forwardHaptic("light");
|
||||
}
|
||||
break;
|
||||
case "call-service": {
|
||||
case "call-service":
|
||||
if (!actionConfig.service) {
|
||||
forwardHaptic("failure");
|
||||
return;
|
||||
@ -84,6 +90,8 @@ export const handleAction = (
|
||||
const [domain, service] = actionConfig.service.split(".", 2);
|
||||
hass.callService(domain, service, actionConfig.service_data);
|
||||
forwardHaptic("light");
|
||||
}
|
||||
break;
|
||||
case "fire-dom-event":
|
||||
fireEvent(node, "ll-custom", actionConfig);
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user