ESPHome Pushbutton as binary_sensor in Lovelace UI

Hello!

I have a (binary_sensor) Pushbutton with on_click and double-click that toggle my Relais.
How can I use it in the frontend?

Same as any other binary sensor.

@nickrout I dont understand.
Sensor can only show state and History but can not Funktion “on_click”…
It is a light button with a 5 min delay that toggled a relay (switch). I would like to control this light in the Lovelace…
My Config: ESP8266 with ESPHome for Button and Relais and Home Assistant Frontend.
Sorry for my bad english. I am from germany…

I think you are confusing a device and it’s representation in the ui.

I think too. What is the best for momentary switch with Timer?
I will:
on_click = light on for 5 min
double_click = light on for 1h
long_press = light off
All of this should work with a momentary-button, in the Lovelace-UI and later via the 433MHz MQTT bridge.
The most important thing: the momentary-button should work with ESPHome even without a home assistant!

My solution:

binary_sensor:
  - platform: gpio
    name: "Licht Tor 5/60min"
    device_class: light
    on_click:        # Klick = Timer 5 min
    - min_length: 50ms
      max_length: 1s
      then:
      - logger.log: "One-Clicked"
      - switch.turn_on: Relais01
      - delay: 5min
      - switch.turn_off: Relais01
    - min_length: 1s # längerer Druck = Licht aus
      max_length: 3s
      then:
      - logger.log: "Long-Clicked=off"
      - switch.turn_off: Relais01
      - delay: 500ms
    on_double_click: # Doppelklick = Timer 1h
      - logger.log: "Double-Clicked"
      - switch.turn_on: Relais01 # Quittierung
      - delay: 500ms
      - switch.turn_off: Relais01
      - delay: 500ms
      - switch.turn_on: Relais01 # Licht ein für 1h
      - delay: 1h
      - switch.turn_off: Relais01
    pin:
      mcp23017: mcp23017_hub_i
      number: 0
      mode: INPUT_PULLUP
      inverted: True