Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
B2 ESPHome yaml for home assistant with tuya
#1
Code:
esphome:
  name: b2
  friendly_name: b2
  platformio_options:
    board_build.extra_flags:
      # WIFI_CONTROL_SELF_MODE = 0
      # WIFI_CONTROL_SELF_MODE = 1
      - "-DWIFI_CONTROL_SELF_MODE=1"

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

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

# Enable logging
logger:
#   hardware_uart: USB_SERIAL_JTAG
# Enable Home Assistant API
api:

ethernet:
  type: W5500
  clk_pin: GPIO1
  mosi_pin: GPIO2
  miso_pin: GPIO41
  cs_pin: GPIO42
  interrupt_pin: GPIO43
  reset_pin: GPIO44

i2c:
   - id: bus_a
     sda: 8
     scl: 18
     scan: true
     frequency: 400kHz

uart:
  - id: uart_1    #RS485
    baud_rate: 9600
    debug:
      direction: BOTH
      dummy_receiver: true
      after:
        timeout: 10ms
    tx_pin: 38
    rx_pin: 39

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

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

switch:
  - platform: uart
    uart_id: uart_1
    name: "RS485 Button"
    data: [0x11, 0x22, 0x33, 0x44, 0x55]

  - platform: gpio
    name: "b2-output01"
    id: "b2_output01"
    pin: 4
    inverted: false
  - platform: tuya_wifi_mcu
    name: b2-output1-tuya
    dp_id: 1
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "b2_output01"

  - platform: gpio
    name: "b2-output02"
    id: "b2_output02"
    pin: 46
    inverted: false
  - platform: tuya_wifi_mcu
    name: b2-output2-tuya
    dp_id: 2
    # hide from homeassistant ui
    internal: true
    # bind other switch, sync state
    bind_switch_id: "b2_output02"   

binary_sensor:
  - platform: gpio
    name: "b2-input01"
    id: "b2_input01"
    pin:
      number: 6
      inverted: true
  - platform: tuya_wifi_mcu
    name: b2-input1-tuya
    dp_id: 111
    bind_binary_sensor_id: b2_input01
    internal: true


  - platform: gpio
    name: "b2-input02"
    id: "b2_input02"
    pin:
      number: 7
      inverted: true
  - platform: tuya_wifi_mcu
    name: b2-input2-tuya
    dp_id: 112
    bind_binary_sensor_id: b2_input02
    internal: true

##pull-up resistance on PCB
  - platform: gpio
    name: "b2-W1-io47"
    pin:
      number: 47
      inverted: true

  - platform: gpio
    name: "b2-W1-io48"
    pin:
      number: 48
      inverted: true

  - platform: gpio
    name: "b2-W1-io17"
    pin:
      number: 17
      inverted: true

  - platform: gpio
    name: "b2-W1-io40"
    pin:
      number: 40
      inverted: true


ads1115:
  - address: 0x48
sensor:
  - platform: ads1115
    multiplexer: 'A0_GND'
    gain: 6.144
    resolution: 16_BITS
    name: "ADS1115 Channel A0-GND"
    update_interval: 5s
  - platform: ads1115
    multiplexer: 'A1_GND'
    gain: 6.144
    name: "ADS1115 Channel A1-GND"
    update_interval: 5s
  - platform: ads1115
    multiplexer: 'A2_GND'
    gain: 6.144
    name: "ADS1115 Channel A2-GND"
    update_interval: 5s
  - platform: ads1115
    multiplexer: 'A3_GND'
    gain: 6.144
    name: "ADS1115 Channel A3-GND"
    update_interval: 5s

web_server:
  port: 80

font:
  - file: "gfonts://Roboto"
    id: roboto
    size: 20

display:
  - platform: ssd1306_i2c
    i2c_id: bus_a
    model: "SSD1306 128x64"
    address: 0x3C
    lambda: |-
      it.printf(0, 0, id(roboto), "KinCony B2");
download yaml file:

.txt   B2-HA-Tuya.txt (Size: 3.58 KB / Downloads: 5)
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)