#按键点击操作中press与click(press + release)冲突,click的同时也会触发press,因此修改为如下的timing方式
on_multi_click:
#双击(x秒内按两下,松开按键0.2秒之后反馈状态)
- timing:
- ON for at most 0.5s
- OFF for at most 0.5s
- ON for at most 0.5s
- OFF for at least 0.2s
then:
- lambda: |-
id(${node_id}_action).publish_state("double");
id(${node_id}_switch_timeout).turn_on();
- while:
condition:
lambda: |-
return id(${node_id}_switch_timeout).state;
then:
- delay: 10ms
invalid_cooldown: 0s
#长按(按键时长为x秒到y秒之间,松开按键0.2秒之后发送状态)
- timing:
- ON for at least 0.7s
- OFF for at least 0.2s
then:
- switch.toggle: ${node_id}_relay
invalid_cooldown: 0s
#短按(x秒内按一下,松开按键0.3秒之后反馈状态)
#短按作为情景开关使用,不直接断开继电器...
#...而是向服务器发送控制指令,由服务器关闭对指定设备进行遥控
- timing:
- ON for at most 0.3s
- OFF for at least 0.2s
then:
- lambda: |-
id(${node_id}_action).publish_state("single");
id(${node_id}_switch_timeout).turn_on();
- while:
condition:
lambda: |-
return id(${node_id}_switch_timeout).state;
then:
- delay: 10ms
esphome:
name: cs22
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "IbFuJmYh3j38wgt0r41RD8tVSj42A1b1AwyZnxyhmxk="
binary_sensor:
- platform: gpio
pin:
number: GPIO3
mode: INPUT_PULLUP
inverted: true
id: ${node_id}_toggle_button
internal: true
#按键点击操作中press与click(press + release)冲突,click的同时也会触发press,因此修改为如下的timing方式
on_multi_click:
#双击(x秒内按两下,松开按键0.2秒之后反馈状态)
- timing:
- ON for at most 0.5s
- OFF for at most 0.5s
- ON for at most 0.5s
- OFF for at least 0.2s
then:
- lambda: |-
id(${node_id}_action).publish_state("double");
id(${node_id}_switch_timeout).turn_on();
- while:
condition:
lambda: |-
return id(${node_id}_switch_timeout).state;
then:
- delay: 10ms
invalid_cooldown: 0s
#长按(按键时长为x秒到y秒之间,松开按键0.2秒之后发送状态)
- timing:
- ON for at least 0.7s
- OFF for at least 0.2s
then:
- switch.toggle: ${node_id}_relay
invalid_cooldown: 0s
#短按(x秒内按一下,松开按键0.3秒之后反馈状态)
#短按作为情景开关使用,不直接断开继电器...
#...而是向服务器发送控制指令,由服务器关闭对指定设备进行遥控
- timing:
- ON for at most 0.3s
- OFF for at least 0.2s
then:
- lambda: |-
id(${node_id}_action).publish_state("single");
id(${node_id}_switch_timeout).turn_on();
- while:
condition:
lambda: |-
return id(${node_id}_switch_timeout).state;
then:
- delay: 10ms
invalid_cooldown: 0s
ota:
password: "6aaa75f442e319c5f87c020dfdbfbc86"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Cs22 Fallback Hotspot"
password: "w81VnRFNHVLi"
captive_portal:
binary_sensor:
- platform: gpio
pin:
number: GPIO14
mode: INPUT_PULLUP
inverted: true
id: dc1
internal: true
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 least 0.2s
then:
- mqtt.publish:
topic: esphome32/senso/ir
payload: "double"
- timing:
- ON for at most 0.3s
- OFF for at least 0.2s
then:
- mqtt.publish:
topic: esphome32/senso/ir
payload: "single"
- timing:
- ON for at least 0.7s
then:
- mqtt.publish:
topic: esphome32/senso/ir
payload: "hold"
- timing:
- ON for at least 0.7s
- OFF for at least 0.2s
then:
- mqtt.publish:
topic: esphome32/senso/ir
payload: "Not_hold"