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 Settings -> Devices & services -> 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.yamlconfiguration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more], 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.yamlconfiguration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more]:

# Example configuration.yaml entry
input_button:
  ring_bell:
    name: Ring bell
    icon: mdi:bell

Configuration Variables

input_button map Required

Alias for the input. Multiple entries are allowed.

name string (Optional)

Friendly name of the input.

icon icon (Optional)

Icon to display in front of the input element in the frontend.

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:

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

Actions

The input button entities exposes a single action: input_button.press

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

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