Skip to content

Instantly share code, notes, and snippets.

@jldesignseu
Forked from albertnis/bedside_button.yaml
Created June 4, 2022 20:10
Show Gist options
  • Save jldesignseu/ce6fd345ca844fdb5ac63da53aa802a1 to your computer and use it in GitHub Desktop.
Save jldesignseu/ce6fd345ca844fdb5ac63da53aa802a1 to your computer and use it in GitHub Desktop.
Making a custom multi-click push button using ESPHome
esphome:
name: bedside_button
platform: ESP8266
board: esp12e
wifi:
ssid: "ssid"
password: "example"
logger:
api:
password: "example"
ota:
password: "example"
light:
- platform: monochromatic
id: bedside_indicator
name: "Bedside Indicator"
output: led_out
default_transition_length: .3s
restore_mode: RESTORE_DEFAULT_OFF
output:
- platform: esp8266_pwm
id: led_out
pin: GPIO13
binary_sensor:
- platform: gpio
pin:
number: GPIO5
mode: INPUT_PULLUP
id: raw_switch_state
internal: true
filters:
- invert:
- delayed_on: 30ms
- delayed_off: 30ms
on_multi_click:
- timing:
- ON for 40ms to 400ms
- OFF for at least 330ms
then:
- text_sensor.template.publish:
id: bedside_button
state: !lambda 'return "single";'
- timing:
- ON for 40ms to 400ms
- OFF for 40ms to 300ms
- ON for 40ms to 400ms
- OFF for at least 330ms
then:
- text_sensor.template.publish:
id: bedside_button
state: !lambda 'return "double";'
- timing:
- ON for 40ms to 400ms
- OFF for 40ms to 300ms
- ON for 40ms to 400ms
- OFF for 40ms to 300ms
- ON for 40ms to 400ms
- OFF for at least 50ms
then:
- text_sensor.template.publish:
id: bedside_button
state: !lambda 'return "triple";'
- timing:
- ON for at least 2s
then:
- text_sensor.template.publish:
id: bedside_button
state: !lambda 'return "hold";'
text_sensor:
- platform: template
name: "Bedside button"
id: bedside_button
icon: "mdi:toggle-switch"
on_value:
then:
- if:
condition:
text_sensor.state:
id: bedside_button
state: ""
else:
- delay: 20ms
- text_sensor.template.publish:
id: bedside_button
state: !lambda 'return "";'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment