esphome 改造老式风扇

这两天在折腾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

安装esphome

3.依照教程连线

大功告成。

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值