mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-24 01:37:23 +00:00
Add input_button (#20764)
This commit is contained in:
parent
f73d44b331
commit
dd2d933406
88
source/_integrations/input_button.markdown
Normal file
88
source/_integrations/input_button.markdown
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
---
|
||||||
|
title: Input Button
|
||||||
|
description: Instructions on how to use the Input Button helper with Home Assistant.
|
||||||
|
ha_category:
|
||||||
|
- Automation
|
||||||
|
ha_release: 2022.2
|
||||||
|
ha_quality_scale: internal
|
||||||
|
ha_codeowners:
|
||||||
|
- '@home-assistant/core'
|
||||||
|
ha_domain: input_button
|
||||||
|
---
|
||||||
|
|
||||||
|
The Input Button helper integration allows you to define buttons that
|
||||||
|
can be pressed via the user interface, and can be used to trigger things,
|
||||||
|
like an automation.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
The preferred way to configure button helpers is via the user interface.
|
||||||
|
To add one, go to **{% my helpers title="Configuration -> Helpers" %}**
|
||||||
|
and click the add button; next choose the "**Button**" option.
|
||||||
|
|
||||||
|
To be able to add **Helpers** via the user interface you should have
|
||||||
|
`default_config:` in your `configuration.yaml`, it should already be there by
|
||||||
|
default unless you removed it. If you removed `default_config:` from your
|
||||||
|
configuration, you must add `input_button:` to your `configuration.yaml` first,
|
||||||
|
then you can use the UI.
|
||||||
|
|
||||||
|
Input buttons can also be configured via `configuration.yaml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# Example configuration.yaml entry
|
||||||
|
input_button:
|
||||||
|
ring_bell:
|
||||||
|
name: Ring bell
|
||||||
|
icon: mdi:bell
|
||||||
|
```
|
||||||
|
|
||||||
|
{% configuration %}
|
||||||
|
input_button:
|
||||||
|
description: Alias for the input. Multiple entries are allowed.
|
||||||
|
required: true
|
||||||
|
type: map
|
||||||
|
keys:
|
||||||
|
name:
|
||||||
|
description: Friendly name of the input.
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
icon:
|
||||||
|
description: Icon to display in front of the input element in the frontend.
|
||||||
|
required: false
|
||||||
|
type: icon
|
||||||
|
{% endconfiguration %}
|
||||||
|
|
||||||
|
## Automation Examples
|
||||||
|
|
||||||
|
The `input_button` entity is stateless, as in, it cannot have a state like the
|
||||||
|
`on` or `off` state that, for example, a normal switch entity has.
|
||||||
|
|
||||||
|
Every input button entity does keep track of the timestamp of when the last time
|
||||||
|
the input button entity has been pressed in the Home Assistant UI or pressed via
|
||||||
|
a service call.
|
||||||
|
|
||||||
|
Because the state of a input button entity in Home Assistant is a timestamp, it
|
||||||
|
means we can use it in our automations. For example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
trigger:
|
||||||
|
- platform: state
|
||||||
|
entity_id: button.my_button
|
||||||
|
action:
|
||||||
|
- service: notify.frenck
|
||||||
|
data:
|
||||||
|
message: "My button has been pressed!"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Services
|
||||||
|
|
||||||
|
The input button entities exposes a single service:
|
||||||
|
{% my developer_call_service service="input_button.press" %}
|
||||||
|
|
||||||
|
This service can be called to trigger a button press for that entity.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- service: input_button.press
|
||||||
|
target:
|
||||||
|
entity_id: input_button.my_button
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user