Smart Home Automation Forum
how to use one click , double , holed click for automation esphome - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KC868-A16S (https://www.kincony.com/forum/forumdisplay.php?fid=47)
+--- Thread: how to use one click , double , holed click for automation esphome (/showthread.php?tid=2960)



how to use one click , double , holed click for automation esphome - engmohades - 06-02-2023

can give me example contain one click , double , holed click for automation esphome for kc868-a16s

please write the code to use it


RE: how to use one click , double , holed click for automation esphome - admin - 06-03-2023

just use AUTOMATION by different mode:

on_click (Optional, Automation): An automation to perform when the button is held down for a specified period of time. See on_click.

on_double_click (Optional, Automation): An automation to perform when the button is pressed twice for specified periods of time. See on_double_click.

on_multi_click (Optional, Automation): An automation to perform when the button is pressed in a specific sequence. See on_multi_click.

here have details: https://esphome.io/components/binary_sensor/index.html


RE: how to use one click , double , holed click for automation esphome - engmohades - 06-03-2023

can write code  example contains (  on_click -  on_double_click -  on_multi_click ) ? 

i tryed but not work 

Code:
binary_sensor:
  - platform: gpio
    # ...
    on_click:
    - min_length: 50ms
      max_length: 350ms
      then:
        - switch.turn_off: relay_1
    - min_length: 500ms
      max_length: 1000ms
      then:
        - switch.turn_on: relay_1
Code:
  - platform: gpio
    # ...
    on_double_click:
      min_length: 50ms
      max_length: 350ms
      then:
        - switch.turn_off: relay_1
Code:
binary_sensor:
  - platform: gpio
    # ...
    on_multi_click:
    - timing:
        - ON for at most 1s
        - OFF for at most 1s
        - ON for 0.5s to 1s
        - OFF for at least 0.2s
      then:
        - logger.log: "Double-Clicked"
Code:
on_multi_click:
- timing:
    - ON for at most 1s
    - OFF for at most 1s
    - ON for at most 1s
    - OFF for at least 0.2s
  then:
    - logger.log: "Double Clicked"
- timing:
    - ON for 1s to 2s
    - OFF for at least 0.5s
  then:
    - logger.log: "Single Long Clicked"
- timing:
    - ON for at most 1s
    - OFF for at least 0.5s
  then:
    - logger.log: "Single Short Clicked"



RE: how to use one click , double , holed click for automation esphome - admin - 06-03-2023

next week when i have free time, write a demo config for you.


RE: how to use one click , double , holed click for automation esphome - engmohades - 06-04-2023

(06-03-2023, 11:20 PM)admin Wrote: next week when i have free time, write a demo config for you.
thank you very much


RE: how to use one click , double , holed click for automation esphome - admin - 06-05-2023

this is 3 mode for KC868-A16S controller set by ESPHome:
1-click: toggle relay1
2-click: toggle relay2
3-click: toggle relay3
actually you can add 4-click, 5-click, 6-click, ........

tested with KC868-A16S
   

mainin use these code:

binary_sensor:
  - platform: gpio
    name: "a16s-input1"
    on_multi_click:
    - timing:
        - ON for at most 0.5s
        - OFF for at most 0.5s
        - ON for at most 0.5s
        - OFF for at most 0.5s
        - ON for at most 0.5s
        - OFF for at least 0.5s
      then:
        - switch.toggle: a16s_output3
    - timing:
        - ON for at most 0.5s
        - OFF for at most 0.5s
        - ON for at most 0.5s
        - OFF for at least 0.5s
      then:
        - switch.toggle: a16s_output2
    - timing:
        - ON for at most 0.5s
        - OFF for at least 0.5s
      then:
        - switch.toggle: a16s_output1
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 0
      mode: INPUT
      inverted: true


.txt   Made_for_ESPHome_KC868-A16S - multi-click.txt (Size: 6.28 KB / Downloads: 136)

sample config code from ESPHome github: https://github.com/jesserockz/esphome-configs/blob/main/modules/devices/zemismart/button.yaml