esphome: name: kinconyf8 friendly_name: kinconyf8 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-kc868-ha ref: v3.0.1 - source: type: git url: https://github.com/hzkincony/esphome-tuya-wifi-mcu ref: v1.1.0 # Enable logging logger: level: DEBUG # hardware_uart: USB_SERIAL_JTAG # Enable Home Assistant API api: encryption: key: "WeVOuL5oNhjXcfzXtTirlOwvtWvCD5yqIxd3oV4es1k=" ethernet: type: W5500 clk_pin: GPIO42 mosi_pin: GPIO43 miso_pin: GPIO44 cs_pin: GPIO41 interrupt_pin: GPIO2 reset_pin: GPIO1 id: eth0 manual_ip: static_ip: 192.168.0.101 gateway: 192.168.0.1 subnet: 255.255.255.0 ota: - platform: esphome password: "cf8a7840b0274ba8f0bbdcb4a2a0bc8f" # --- Template Text Sensor for Ethernet IP --- i2c: - id: bus_a sda: 8 scl: 18 scan: true frequency: 400kHz pcf8574: - id: 'pcf8574_hub_in_1' # for input channel 1-16 i2c_id: bus_a address: 0x24 pcf8575: true uart: - id: uart_1 #RS485 baud_rate: 9600 debug: direction: BOTH dummy_receiver: true after: timeout: 10ms tx_pin: 16 rx_pin: 17 kc868_ha: switch: - platform: gpio name: "f8-output01" id: "f8_output01" pin: pcf8574: pcf8574_hub_in_1 number: 8 mode: OUTPUT inverted: true - platform: gpio name: "f8-output02" id: "f8_output02" pin: pcf8574: pcf8574_hub_in_1 number: 9 mode: OUTPUT inverted: true - platform: gpio name: "f8-output03" id: "f8_output03" pin: pcf8574: pcf8574_hub_in_1 number: 10 mode: OUTPUT inverted: true - platform: gpio name: "f8-output04" id: "f8_output04" pin: pcf8574: pcf8574_hub_in_1 number: 11 mode: OUTPUT inverted: true - platform: gpio name: "f8-output05" id: "f8_output05" pin: pcf8574: pcf8574_hub_in_1 number: 12 mode: OUTPUT inverted: true - platform: gpio name: "f8-output06" id: "f8_output06" pin: pcf8574: pcf8574_hub_in_1 number: 13 mode: OUTPUT inverted: true - platform: gpio name: "f8-output07" id: "f8_output07" pin: pcf8574: pcf8574_hub_in_1 number: 14 mode: OUTPUT inverted: true - platform: gpio name: "f8-output08" id: "f8_output08" pin: pcf8574: pcf8574_hub_in_1 number: 15 mode: OUTPUT inverted: true binary_sensor: - platform: gpio name: "f8-input01" id: "f8_input01" pin: pcf8574: pcf8574_hub_in_1 number: 0 mode: INPUT inverted: true on_press: then: - switch.toggle: f8_output01 - platform: gpio name: "f8-input02" id: "f8_input02" pin: pcf8574: pcf8574_hub_in_1 number: 1 mode: INPUT inverted: true on_press: then: - switch.toggle: f8_output02 - platform: gpio name: "f8-input03" id: "f8_input03" pin: pcf8574: pcf8574_hub_in_1 number: 2 mode: INPUT inverted: true on_press: then: - switch.toggle: f8_output03 - platform: gpio name: "f8-input04" id: "f8_input04" pin: pcf8574: pcf8574_hub_in_1 number: 3 mode: INPUT inverted: true on_press: then: - switch.toggle: f8_output04 - platform: gpio name: "f8-input05" id: "f8_input05" pin: pcf8574: pcf8574_hub_in_1 number: 4 mode: INPUT inverted: true on_press: then: - switch.toggle: f8_output05 - platform: gpio name: "f8-input06" id: "f8_input06" pin: pcf8574: pcf8574_hub_in_1 number: 5 mode: INPUT inverted: true on_press: then: - switch.toggle: f8_output06 - platform: gpio name: "f8-input07" id: "f8_input07" pin: pcf8574: pcf8574_hub_in_1 number: 6 mode: INPUT inverted: true on_press: then: - switch.toggle: f8_output07 - platform: gpio name: "f8-input08" id: "f8_input08" pin: pcf8574: pcf8574_hub_in_1 number: 7 mode: INPUT inverted: true on_press: then: - switch.toggle: f8_output08 - platform: kc868_ha target_relay_controller_addr: 1 # Default value is 1, corresponds to the Target Relay Controller Addr parameter in HA485_Ctrl software switch_adapter_addr: 10 # Default value is 10, corresponds to the Switch Adapter Addr parameter in HA485_Ctrl software bind_output: 1 # Corresponds to the BindOutput parameter in HA485_Ctrl software name: "binary_sensor 1" - platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 10 bind_output: 2 name: "binary_sensor 2" - platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 10 bind_output: 3 name: "binary_sensor 3" - platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 10 bind_output: 4 name: "binary_sensor 4" - platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 10 bind_output: 5 name: "binary_sensor 5" - platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 10 bind_output: 6 name: "binary_sensor 6" ##pull-up resistance on PCB - platform: gpio name: "f8-W1-io48" pin: number: 48 inverted: true - platform: gpio name: "f8-W1-io47" pin: number: 47 inverted: true - platform: gpio name: "f8-W1-io21" pin: number: 21 inverted: true - platform: gpio name: "f8-W1-io15" pin: number: 15 inverted: true ## without resistance on PCB - platform: gpio name: "f8-W1-io14" pin: number: 14 inverted: false - platform: gpio name: "f8-433M" pin: number: 40 inverted: false - platform: gpio name: "f8-io0" pin: number: 0 inverted: false sensor: web_server: port: 80 font: - file: "gfonts://Roboto" id: roboto size: 20 # Expose the Ethernet IP to a text_sensor text_sensor: - platform: template name: "F8 Ethernet IP" id: f8_ethernet_ip lambda: |- auto ips = id(eth0).get_ip_addresses(); if (ips.empty()) { return std::string("lucian"); } return ips[0].str(); display: - platform: ssd1306_i2c i2c_id: bus_a model: "SSD1306 128x64" address: 0x3C lambda: |- // 1) Always clear the screen and draw a label so we know the update ran it.fill(COLOR_OFF); it.print(0, 0, id(roboto), "Eth IP Addr:"); // 2) Pull get_ip_addresses() directly from `eth0`: auto ips = id(eth0).get_ip_addresses(); if (ips.empty()) { // If no DHCP lease yet, show a fallback message in small font it.print(0, 18, id(roboto), "No IP yet"); } else { // Once DHCP succeeds, ips[0] will be the primary IPv4—print it in larger font // Note: `esphome::network::IPAddress::str()` returns a std::string std::string ip_str = ips[0].str(); it.printf(0, 18, id(roboto), "%s", ip_str.c_str()); }