Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to use one click , double , holed click for automation esphome
#1
can give me example contain one click , double , holed click for automation esphome for kc868-a16s

please write the code to use it
Reply
#2
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
Reply
#3
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"
Reply
#4
next week when i have free time, write a demo config for you.
Reply
#5
(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
Reply
#6
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: 188)

sample config code from ESPHome github: https://github.com/jesserockz/esphome-co...utton.yaml
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)