Prerequisites:
To configure mutli-click on Esphome in boneIO ESP you’d need to find binary_sensor part of your config. Let’s say you want to control light1, light2, light3.
light:
- platform: binary
name: 'Light 01'
output: out_01
id: light_01
- platform: binary
name: 'Light 02'
output: out_02
id: light_02
- platform: binary
name: 'Light 03'
output: out_03
id: light_03
Let’s configure IN_01 of boneIO ESP 32x10:
Standard configuration looks like this:
binary_sensor:
- platform: gpio
name: 'IN_01'
id: in_01
pin:
pcf8574: pcf_inputs_1to14
number: 0
mode:
input: true
inverted: true
on_press:
then:
- light.toggle: light_01
Let’s remove on_press
option
binary_sensor:
- platform: gpio
name: 'IN_01'
id: in_01
pin:
pcf8574: pcf_inputs_1to14
number: 0
mode:
input: true
inverted: true
Now let’s add on_multi_click action.
binary_sensor:
- platform: gpio
name: 'IN_01'
id: in_01
pin:
pcf8574: pcf_inputs_1to14
number: 0
mode:
input: true
inverted: true
on_multi_click:
- timing: # double click
- ON for at most 1s
- OFF for at most 0.5s
- ON for at most 1s
- OFF for at least 0.2s
then:
- light.toggle: light_02
- logger.log: 'Double Click'
- timing: # single click
- ON for at most 1s
- OFF for at least 0.5s
then:
- light.toggle: light_01
- logger.log: 'Single Click'
- timing: # long click
- ON for at least 1.4s
then:
- light.toggle: light_03
- logger.log: 'Long Click'
Ok. It’s ready, now just upload new firmware to your device. You might need to adapt timings for your wall switches to work best for you.
Instead of handling multi click in Esphome, you can deal with it in Home Assistant. To do that for IN_01, do. You could remove name from binary sensor, as it’s not used in Home Assistant anymore.
event:
- platform: template
name: "IN_01E"
id: "in_01e"
event_types:
- "single"
- "double"
- "long"
binary_sensor:
- platform: gpio
id: in_01
pin:
pcf8574: pcf_inputs_1to14
number: 0
mode:
input: true
inverted: true
on_multi_click:
- timing: # double click
- ON for at most 1s
- OFF for at most 0.5s
- ON for at most 1s
- OFF for at least 0.2s
then:
- light.toggle: light_02
- event.trigger:
id: in_01e
event_type: "double"
- logger.log: 'Double Click'
- timing: # single click
- ON for at most 1s
- OFF for at least 0.5s
then:
- light.toggle: light_01
- event.trigger:
id: in_01e
event_type: "single"
- logger.log: 'Single Click'
- timing: # long click
- ON for at least 1.4s
then:
- light.toggle: light_03
- event.trigger:
id: in_01e
event_type: "long"
- logger.log: 'Long Click'