Buttons: add more examples (#32965)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
c0ffeeca7 2024-06-10 13:47:22 +02:00 committed by GitHub
parent 7265c9651d
commit 09423a2fe8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 61 additions and 3 deletions

View File

@ -128,7 +128,12 @@ type: button
entity: light.living_room
```
Button card with a button name and a script that runs when card is tapped:
Button card with a button name and a [script](/docs/scripts/) that runs when card is tapped:
<p class='img'>
<img src='/images/dashboards/entity_button_complex_card.png' alt='Screenshot of the Button card with script service'>
Screenshot of the button card with script service.
</p>
```yaml
type: button
@ -141,7 +146,60 @@ tap_action:
entity_id: script.turn_off_lights
```
Example of 4 buttons on a vertical stack card:
<p class='img'>
<img src='/images/dashboards/entity_button_complex_card.png' alt='Screenshot of the Button card with script service'>
Screenshot of the button card with script service.
<img src='/images/dashboards/buttons_on_vertical_stack_card.png' alt='Screenshot of a vertical stack card with 4 buttons and an entity selector'>
Screenshot of a vertical stack card with 4 buttons and an entity selector.
</p>
The image shows a vertical stack card with 4 buttons arranged in a horizontal stack card and an entity selector. The buttons use the toggle action to run a script, for example, the Netflix script, which starts up the TV and opens Netflix. To learn how to create scripts, refer to [scripts](/docs/scripts/).
```yaml
cards:
- entities:
- entity: input_select.living_room_scene
name: Scene
show_header_toggle: false
type: entities
- type: horizontal-stack
cards:
- name: Watch Netflix
entity: script.netflix
type: button
tap_action:
action: toggle
hold_action:
action: more-info
show_name: true
show_icon: true
- name: Watch YouTube
entity: script.youtube
type: button
tap_action:
action: toggle
hold_action:
action: more-info
show_name: true
show_icon: true
- name: Wake PC
entity: script.wake_on_lan
type: button
tap_action:
action: toggle
icon: mdi:desktop-tower
show_name: true
show_icon: true
show_state: false
- name: Go to sleep
entity: script.sleep
type: button
tap_action:
action: toggle
icon: mdi:sleep
hold_action:
action: more-info
show_name: true
show_icon: true
type: vertical-stack
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB