Button simple click double click long press

Good morning!
I want to use a single push button to control 3 different devices
Single click: lighting
Long press: ventilation
Double click: air conditioning
HA 2023 on RPI CM4
Help with configuration

Help with configuring what? Do you have a button? If so, what sort of button?

How do you currently control lights, air conditioning etc?

Some more detail about what you hope to achieve and what you currently have would be good.

here is my configuration for the light and the fan
alias: Mise en marche et arret brasseur salon
description: “”
trigger:

  • platform: state
    entity_id:
    • binary_sensor.cm4_in3
      from: “off”
      for:
      hours: 0
      minutes: 0
      seconds: 3
      to: null
      condition: []
      action:
  • if:
    • condition: state
      entity_id: switch.cm4_relais3
      state: “off”
      then:
    • service: fan.turn_on
      data: {}
      target:
      entity_id:
      - fan.cm4_relais3
      else:
    • service: fan.turn_off
      data: {}
      target:
      entity_id:
      - fan.cm4_relais3
      area_id: salon
      mode: single
      alias: Mise marche et arret lampe salon
      description: “”
      trigger:
  • platform: state
    entity_id:
    • binary_sensor.cm4_in2
      from: “off”
      for:
      hours: 0
      minutes: 0
      seconds: 0.2
      to: “on”
      condition: []
      action:
  • if:
    • condition: state
      entity_id: switch.cm4_relais2
      state: “off”
      for:
      hours: 0
      minutes: 0
      seconds: 0
      then:
    • service: light.turn_on
      data: {}
      target:
      area_id: salon
      entity_id: light.cm4_relais2
      else:
    • service: light.turn_off
      data: {}
      target:
      area_id: salon
      entity_id: light.cm4_relais2
      mode: single
      My problem
      simple click the lamp turns on
      simple click again the lamp goes out
      long press on the same button the fan starts
      press long again the fan turns off but the lamp also turns on

Ok - so some progress.

A couple of things - and apologies if you have little or no English, but please read at least point 11 of the linked page below. Your yaml must be posted in code (preformatted text) tags, which look like </> on the posting toolbar. This will improve the readability of your code and also ensure that people can see if the indentation is correct. You don’t need to re-post, just edit the post above to include the tags.

Secondly, I assume you don’t have a device at the moment with a suitable button to click? If you have a Zigbee hub, some Zigbee buttons support click, double click and other actions. I can’t help you choose one - but if you post a Zigbee question maybe someone can.

Personally I am more comfortable making my own button device with ESPHome. This will require you to assemble some hardware and do a small bit of yaml coding.