mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-12 11:56:29 +00:00
Add blog post for action event for custom cards (#1830)
This commit is contained in:
parent
3d1fec126b
commit
38e05aeb7f
48
blog/2023-07-07-action-event-custom-cards.md
Normal file
48
blog/2023-07-07-action-event-custom-cards.md
Normal file
@ -0,0 +1,48 @@
|
||||
---
|
||||
author: Paul Bottein
|
||||
authorURL: https://github.com/piitaya
|
||||
authorTwitter: piitaya
|
||||
title: Action event for custom cards
|
||||
---
|
||||
|
||||
In the Home Assistant Core 2023.7 release, we introduced `hass-action` for custom cards.
|
||||
|
||||
If you are a custom cards developer, you can now use any [card action](https://www.home-assistant.io/dashboards/actions/) in your custom card by using the new `hass-action`.
|
||||
|
||||
Example :
|
||||
|
||||
```js
|
||||
// Define the action config
|
||||
const actionConfig = {
|
||||
entity: "sensor.temperature",
|
||||
tap_action: {
|
||||
action: "more-info",
|
||||
},
|
||||
hold_action: {
|
||||
action: "assist",
|
||||
start_listening: true,
|
||||
},
|
||||
};
|
||||
|
||||
// Open more info on tap action
|
||||
const event = new Event("hass-action", {
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
});
|
||||
event.detail = {
|
||||
config: actionConfig,
|
||||
action: "tap",
|
||||
};
|
||||
this.dispatchEvent(event);
|
||||
|
||||
// Open assist dialog on hold action
|
||||
const event = new Event("hass-action", {
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
});
|
||||
event.detail = {
|
||||
config: actionConfig,
|
||||
action: "hold",
|
||||
};
|
||||
this.dispatchEvent(event);
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user