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