Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
KC868-E8T added Tuya module yaml file for ESPHome
#1
Code:
esphome:
  name: e8t-tuya
  friendly_name: e8t-tuya
  platformio_options:
    board_build.extra_flags:
      # WIFI_CONTROL_SELF_MODE = 0
      # WIFI_CONTROL_SELF_MODE = 1
      - "-DWIFI_CONTROL_SELF_MODE=1"
  platform: ESP32
  board: esp32dev
  on_boot:  #Power chip BL0939 initialization
    priority: 600
    then:
      - uart.write:
          id: uart_1
          data: [0xA5, 0x39, 0x42, 0x00, 0x00, 0xDF]
      - delay: 1ms
      - uart.write:
          id: uart_1
          data: [0xA5, 0x38, 0x3C, 0x00, 0x00, 0xE6]
      - delay: 1ms
      - uart.write:
          id: uart_1
          data: [0xA5, 0x39, 0x42, 0x00, 0x00, 0xDF]
      - delay: 1ms
      - uart.write:
          id: uart_1
          data: [0xA5, 0x3A, 0x01, 0x00, 0x00, 0x1F]
      - delay: 1ms
      - uart.write:
          id: uart_1
          data: [0xA5, 0x39, 0x00, 0x00, 0x00, 0x21]

external_components:
  - source:
      type: git
      url: https://github.com/hzkincony/esphome-tuya-wifi-mcu
      ref: v1.1.0

uart:
  - id: uart_1
    tx_pin: GPIO12
    rx_pin: GPIO39
    baud_rate: 4800
    parity: NONE
    stop_bits: 2   
 
  # - id: uart_2
  #   tx_pin: GPIO33
  #   rx_pin: GPIO36
  #   baud_rate: 4800
  #   parity: NONE
  #   stop_bits: 2 

  - id: tuya_mcu_uart
    tx_pin: GPIO13
    rx_pin: GPIO16
    baud_rate: 9600

tuya_wifi_mcu:
  # tuya mcu product id
  product_id: d8vwzka9smrcjznp
  uart_id: tuya_mcu_uart
  wifi_reset_pin: 28
  wifi_led_pin: 16


# Enable logging
logger:
  # baud_rate: 0

# Enable Home Assistant API
api:

ota:
  password: "d83d604e4f0ae287fb041dbaf31524d9"


# Example configuration entry
ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO17_OUT
  phy_addr: 0
 


sensor:
  - platform: bl0939
    uart_id: uart_1
    update_interval: 10s
    voltage:
      name: 'BL0939A Voltage'
    current_1:
      name: 'BL0939A Current 1'
    current_2:
      name: 'BL0939A Current 2'
    active_power_1:
      name: 'BL0939A Active Power 1'
    active_power_2:
      name: 'BL0939A Active Power 2'
    energy_1:
      name: 'BL0939A Energy 1'
    energy_2:
      name: 'BL0939A Energy 2'
    energy_total:
      name: 'BL0939A Energy Total'
     
     
     
  # - platform: bl0939
  #   uart_id: uart_2
  #   update_interval: 10s
  #   voltage:
  #     name: 'BL0939B Voltage'
  #   current_1:
  #     name: 'BL0939B Current 1'
  #   current_2:
  #     name: 'BL0939B Current 2'
  #   active_power_1:
  #     name: 'BL0939B Active Power 1'
  #   active_power_2:
  #     name: 'BL0939B Active Power 2'
  #   energy_1:
  #     name: 'BL0939B Energy 1'
  #   energy_2:
  #     name: 'BL0939B Energy 2'
  #   energy_total:
  #     name: 'BL0939B Energy Total'
     

# Example configuration entry for ESP32
i2c:
  sda: 4
  scl: 5
  scan: true
  id: bus_a
 
pcf8574:
  - id: 'pcf8574_hub_out_1'  # for output channel 1-8
    address: 0x24

  - id: 'pcf8574_hub_in_1'  # for input channel 1-8
    address: 0x22

   
# Individual outputs
switch:
  - platform: gpio
    name: "e8t_output1"
    id: "e8t_output1"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 0
      mode: OUTPUT
      inverted: true

  - platform: tuya_wifi_mcu
    name: e8t-output1-tuya
    dp_id: 1
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "e8t_output1"


  - platform: gpio
    name: "e8t_output2"
    id: "e8t_output2"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 1
      mode: OUTPUT
      inverted: true

  - platform: tuya_wifi_mcu
    name: e8t-output2-tuya
    dp_id: 2
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "e8t_output2"
     
  - platform: gpio
    name: "e8t_output3"
    id: "e8t_output3"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 2
      mode: OUTPUT
      inverted: true

  - platform: tuya_wifi_mcu
    name: e8t-output3-tuya
    dp_id: 3
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "e8t_output3"
     
  - platform: gpio
    name: "e8t_output4"
    id: "e8t_output4"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 3
      mode: OUTPUT
      inverted: true

  - platform: tuya_wifi_mcu
    name: e8t-output4-tuya
    dp_id: 4
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "e8t_output4"
     
  - platform: gpio
    name: "e8t_output5"
    id: "e8t_output5"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 4
      mode: OUTPUT
      inverted: true

  - platform: tuya_wifi_mcu
    name: e8t-output5-tuya
    dp_id: 5
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "e8t_output5"
     
  - platform: gpio
    name: "e8t_output6"
    id: "e8t_output6"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 5
      mode: OUTPUT
      inverted: true

  - platform: tuya_wifi_mcu
    name: e8t-output6-tuya
    dp_id: 6
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "e8t_output6"

  - platform: gpio
    name: "e8t_output7"
    id: "e8t_output7"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 6
      mode: OUTPUT
      inverted: true

  - platform: tuya_wifi_mcu
    name: e8t-output7-tuya
    dp_id: 123
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "e8t_output7"
     
  - platform: gpio
    name: "e8t_output8"
    id: "e8t_output8"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 7
      mode: OUTPUT
      inverted: true

  - platform: tuya_wifi_mcu
    name: e8t-output8-tuya
    dp_id: 124
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "e8t_output8"

binary_sensor:
  - platform: gpio
    name: "e8t_input1"
    id: "e8t_input1"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 0
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: e8t_input1 Tuya
    dp_id: 122
    bind_binary_sensor_id: e8t_input1
    internal: true

  - platform: gpio
    name: "e8t_input2"
    id: "e8t_input2"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 1
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: e8t_input2 Tuya
    dp_id: 121
    bind_binary_sensor_id: e8t_input2
    internal: true

  - platform: gpio
    name: "e8t_input3"
    id: "e8t_input3"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 2
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: e8t_input3 Tuya
    dp_id: 120
    bind_binary_sensor_id: e8t_input3
    internal: true

  - platform: gpio
    name: "e8t_input4"
    id: "e8t_input4"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 3
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: e8t_input4 Tuya
    dp_id: 119
    bind_binary_sensor_id: e8t_input4
    internal: true

  - platform: gpio
    name: "e8t_input5"
    id: "e8t_input5"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 4
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: e8t_input5 Tuya
    dp_id: 118
    bind_binary_sensor_id: e8t_input5
    internal: true

  - platform: gpio
    name: "e8t_input6"
    id: "e8t_input6"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 5
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: e8t_input6 Tuya
    dp_id: 117
    bind_binary_sensor_id: e8t_input6
    internal: true

  - platform: gpio
    name: "e8t_input7"
    id: "e8t_input7"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 6
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: e8t_input7 Tuya
    dp_id: 116
    bind_binary_sensor_id: e8t_input7
    internal: true

  - platform: gpio
    name: "e8t_input8"
    id: "e8t_input8"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 7
      mode: INPUT
      inverted: true
  - platform: tuya_wifi_mcu
    name: e8t_input8 Tuya
    dp_id: 115
    bind_binary_sensor_id: e8t_input8
    internal: true

web_server:
  port: 80

download yaml file: 
.txt   KC868-E8T-HA-Tuya.txt (Size: 8.39 KB / Downloads: 62)
   
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)