这两天在折腾esphome来接入homeassistant,感觉啥都可以来控制,
物料说明:nodemcu一个,四路继电器一个,200v to 3.3v模块一个,
1.首先上代码
esphome:
name: my_out
platform: ESP8266
board: nodemcuv2
wifi:
ssid: "Xiaomi"
password: "1292993725"
# Enable logging
logger:
# Enable Home Assistant API
api:
password: "1292993725"
ota:
password: "1292993725"
binary_sensor:
- platform: gpio
#第一个按钮(内部引用,对外隐藏)
name: "key0"
#是否对外隐藏(true/false)
internal: true
pin:
# Use pin number 0
number: D1
mode: INPUT
filters:
- invert:
- delayed_on: 40ms
- delayed_off: 40ms
on_click:
- min_length: 50ms
max_length: 350ms
then:
- switch.toggle: switch_0
- platform: gpio
#第一个按钮(内部引用,对外隐藏)
name: "key1"
#是否对外隐藏(true/false)
internal: true
pin:
# Use pin number 0
number: D2
mode: INPUT_PULLUP
#inverted: True
filters:
- invert:
- delayed_on: 40ms
- delayed_off: 40ms
on_click:
- min_length: 50ms
max_length: 350ms
then:
- switch.toggle: switch_1
- platform: gpio
#第一个按钮(内部引用,对外隐藏)
name: "key2"
#是否对外隐藏(true/false)
internal: true
pin:
# Use pin number 0
number: D3
mode: INPUT
filters:
- invert:
- delayed_on: 40ms
- delayed_off: 40ms
on_click:
- min_length: 50ms
max_length: 350ms
then:
- switch.toggle: switch_2
- platform: gpio
#第一个按钮(内部引用,对外隐藏)
name: "key3"
#是否对外隐藏(true/false)
internal: true
pin:
# Use pin number 0
number: D4
mode: INPUT
filters:
- invert:
- delayed_on: 40ms
- delayed_off: 40ms
on_click:
- min_length: 50ms
max_length: 350ms
then:
- switch.toggle: switch_3
switch:
- platform: gpio
id: switch_0
pin:
number: D5
inverted: yes
icon: "mdi:fan-off"
name: "close"
interlock: [switch_1,switch_2,switch_3]
- platform: gpio
id: switch_1
pin:
number: D6
inverted: yes
icon: "mdi:fan"
name: "1挡"
interlock: [switch_0,switch_2,switch_3]
- platform: gpio
id: switch_2
pin:
number: D7
inverted: yes
icon: "mdi:fan"
name: "2挡"
interlock: [switch_1,switch_0,switch_3]
- platform: gpio
id: switch_3
pin:
number: D8
inverted: yes
icon: "mdi:fan"
name: "3挡"
interlock: [switch_1,switch_2,switch_0]
- platform: template
name: "Gate Remote"
icon: "mdi:gate"
internal: yes
turn_on_action:
- switch.turn_on: switch_3
- delay: 500ms
- switch.turn_off: switch_3
# Example configuration entry
# Prevent relay #1 and relay #2 from being activated at the same time.
2.按照先前文章进入esphome控制界面,编译,下载到nodemcu
3.依照教程连线
大功告成。