Franck Nijhof b825527486
Change trigger platform key to trigger (#34901)
* Change trigger platform key to trigger

* Error sneaked in
2024-09-25 14:20:46 +02:00

2.6 KiB

title description ha_category ha_release ha_quality_scale ha_domain ha_codeowners ha_integration_type related
Button Instructions on how to set up your button with Home Assistant.
Button
2021.12 internal button
@home-assistant/core
entity
docs title
/docs/configuration/customizing-devices/ Customizing devices
docs title
/dashboards/ Dashboard

A button {% term entity %} is an entity that can fire an {% term event %} / trigger an {% term action %} towards a {% term device %} or {% term service %} but remains stateless from the Home Assistant perspective.

It can be compared to a real live momentary switch, push-button, or some other form of a stateless switch.

{% include integrations/building_block_integration.md %}

The state of a button

The button {% term entity %} is stateless, as in, it cannot have a state like the on or off state that, for example, a normal switch entity has.

The state of a button is a timestamp showing the date and time of the last time the button had been pressed in the Home Assistant UI or via an action.

Screenshot showing the state of a button entity in the developer tools Screenshot showing the state of a button entity in the developer tools.

In addition, the entity can have the following states:

  • Unavailable: The entity is currently unavailable.
  • Unknown: The state is not yet known.

Because the {% term state %} of a button entity in Home Assistant is a timestamp, it means we can use it in our automations. For example:

triggers:
  - trigger: state
    entity_id: button.my_button
actions:
  - action: notify.frenck
    data:
      message: "My button has been pressed!"

Actions

The button entities exposes a single {% term action %}: {% my developer_call_service service="button.press" %}

This action can be called to trigger a button press for that entity.

- action: button.press
  target:
    entity_id: button.my_button

Device class

{% include integrations/device_class_intro.md %}

The screenshot shows different icons representing different device classes for buttons:

Example of device class icons.

The following device classes are supported for buttons:

  • None: Generic button. This is the default and doesn't need to be set.
  • identify: The button is used to identify a device.
  • restart: The button restarts the device.
  • update: The button updates the software of the device.