Button


A button entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service.
[Learn more]
is an entity that can fire an eventAn event is when something happens.
[Learn more]
/ trigger an actionActions are used in several places in Home Assistant. As part of a script or automation, actions define what is going to happen once a trigger is activated. In scripts, an action is called sequence.
[Learn more]
towards a deviceA device is a model representing a physical or logical unit that contains entities. or serviceA service carries out one specific task, for example: turn on the light in the living room. A service has targets and data and can be called by actions, a dashboard, or via voice command.
[Learn more]
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.

Building block integration

This button is a building block integration that cannot be added to your Home Assistant directly but is used and provided by other integrations.

A building block integration differs from the typical integration that connects to a device or service. Instead, other integrations that do integrate a device or service into Home Assistant use this button building block to provide entities, services, and other functionality that you can use in your automations or dashboards.

If one of your integrations features this building block, this page documents the functionality the button building block offers.

The state of a button

The button entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service.
[Learn more]
is stateless, as in, it cannot have a state like the on or off state that, for example, a normal switch entity has.

Every button entity does keep track of the timestamp of when the last time the button entity has been pressed in the Home Assistant UI or pressed via a service call.

Because the stateThe state holds the information of interest of an entity, for example, if a light is on or off. Each entity has exactly one state and the state only holds one value at a time. However, entities can store attributes related to that state such as brightness, color, or a unit of measurement.
[Learn more]
of a button entity in Home Assistant is a timestamp, it means we can use it in our automations. For example:

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

Services

The button entities exposes a single serviceA service carries out one specific task, for example: turn on the light in the living room. A service has targets and data and can be called by actions, a dashboard, or via voice command.
[Learn more]
: button.press

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

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

Device class

The way these buttons are displayed in the frontend can be modified in the customize section. The following device classes are supported for buttons:

Example of device class icons.

  • 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.