本帖最后由 情非殇 于 2019-10-26 21:48 编辑
esphome:
name: nodemcu_01
platform: ESP8266
board: nodemcuv2
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_passwd
use_address: 172.22.1.247
logger:
api:
password: !secret api_passwd
reboot_timeout: 30min
ota:
safe_mode: True
password: !secret ota_passwd
port: 8266
web_server:
port: 80
binary_sensor:
- platform: gpio
pin:
number: D3
mode: INPUT_PULLUP
inverted: True
name: "BUTTON"
id: button
on_press:
then:
- switch.turn_on: relay_green
on_release:
if:
condition:
- switch.is_on: relay_green
then:
- switch.turn_off: relay_green
on_click:
min_length: 50ms
max_length: 500ms
then:
- script.execute: open_door
on_multi_click:
- timing:
- ON for 2s to 4s
- OFF for at least 0.5s
then:
- switch.toggle: relay_red
- platform: gpio
pin:
number: D2
mode: INPUT_PULLUP
inverted: True
name: "BELL"
id: bell
on_press:
if:
condition:
- switch.is_on: relay_red
then:
- delay: 500ms
- script.execute: open_door
switch:
- platform: gpio
pin: D0
name: "LED_GREEN"
id: relay_green
on_turn_on:
- delay: 2.1s
- if:
condition:
for:
time: 2s
condition:
switch.is_on: relay_green
then:
- switch.turn_off: relay_green
- platform: gpio
pin: D1
name: "LED_RED"
id: relay_red
on_turn_on:
- switch.turn_on: mute
on_turn_off:
- switch.turn_off: mute
- platform: gpio
pin: D5
name: "RELAY_KA1"
id: relay_ka1
- platform: gpio
pin: D6
name: "RELAY_KA2"
id: relay_ka2
- platform: gpio
pin: D7
name: "RELAY_KEY"
id: relay_key
- platform: gpio
pin: D8
name: "MUTE"
id: mute
sensor:
- platform: uptime
name: Uptime Sensor
script:
- id: open_door
then:
- switch.turn_on: relay_ka2
- delay: 10ms
- switch.turn_on: relay_ka1
- delay: 800ms
- switch.turn_on: relay_key
- delay: 100ms
- switch.turn_off: relay_key
- delay: 1500ms
- switch.turn_off: relay_ka1
- delay: 10ms
- switch.turn_off: relay_ka2
- logger.log: ok, the door is open! perfect!
|