Skip to content

Commit ffdf22d

Browse files
Add button entity (home-assistant#20105)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
1 parent 57e75c0 commit ffdf22d

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

source/_integrations/button.markdown

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: Button
3+
description: Instructions on how to set up your button with Home Assistant.
4+
ha_category:
5+
- Button
6+
ha_release: 2021.12
7+
ha_quality_scale: internal
8+
ha_domain: button
9+
ha_codeowners:
10+
- '@home-assistant/core'
11+
---
12+
13+
A button entity is an entity that can fire an event / trigger an action towards
14+
a device or service but remains stateless from the Home Assistant perspective.
15+
16+
It can be compared to a real live momentary switch, push-button, or some other
17+
form of a stateless switch.
18+
19+
The button entities cannot be implemented manually, but can be provided by
20+
other integrations.
21+
22+
## The state of a button
23+
24+
The button entity is stateless, as in, it cannot have a state like the `on` or
25+
`off` state that, for example, a normal switch entity has.
26+
27+
Every button entity does keep track of the timestamp of when the last time
28+
the button entity has been pressed in the Home Assistant UI or pressed via
29+
a service call.
30+
31+
Because the state of a button entity in Home Assistant is a timestamp, it
32+
means we can use it in our automations. For example:
33+
34+
```yaml
35+
trigger:
36+
- platform: state
37+
entity_id: button.my_button
38+
action:
39+
- service: notify.frenck
40+
data:
41+
message: "My button has been pressed!"
42+
```
43+
44+
## Services
45+
46+
The button entities exposes a single service: {% my developer_call_service service="button.press" %}
47+
48+
This service can be called to trigger a button press for that entity.
49+
50+
```yaml
51+
- service: button.press
52+
target:
53+
entity_id: button.my_button
54+
```

0 commit comments

Comments
 (0)