5V/12V ESP8266双路WiFi继电器(uart总线)

5V/12V ESP8266双路WiFi继电器


uart:                                    //定义uart总线
  baud_rate: 115200                      //定义uart波特率
  tx_pin: GPIO1                          //定义tx接入IO
  rx_pin: GPIO3                          //定义rx接入IO
 
  debug:
    direction: BOTH
    dummy_receiver: false
    after:
      delimiter: "\n"
    sequence:
      - lambda: UARTDebug::log_string(direction, bytes);

switch:                                 //定义开关
  - platform: template
    id: relay1                          //自定义开关ID(后面代码要用到)
    optimistic: false
    turn_on_action:
      - uart.write: [0xA0, 0x01, 0x01, 0xA2]
    turn_off_action:
      - uart.write: [0xA0, 0x01, 0x00, 0xA1]

  - platform: template                 //定义类型
    id: relay2                         //自定义开关ID(后面代码要用到)
    optimistic: true
    turn_on_action:
      - uart.write: [0xA0, 0x02, 0x01, 0xA3]
    turn_off_action:
      - uart.write: [0xA0, 0x02, 0x00, 0xA2]

  - platform: template                 //定义类型
    name: "FansPower"                  //自定义实体名称
    id: FansPower                      //自定义实体id
    turn_on_action:
    - switch.turn_on: relay1            
    turn_off_action:
    - switch.turn_off: relay1  

  - platform: template                 //定义类型
    name: "PTCPower"                   //自定义实体名称
    id: PTCPower                       //自定义实体id
    turn_on_action:
    - switch.turn_on: relay2
    turn_off_action:
    - switch.turn_off: relay2   

标签: none

添加新评论