01-03-2023, 05:19 AM
you can try these code for KC868-A16:
--------------------------------------------------------
esphome:
name: relay1
platform: ESP32
board: esp32dev
# Example configuration entry for ESP32
i2c:
sda: 4
scl: 5
scan: true
id: bus_a
# Example configuration entry
ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO17_OUT
phy_addr: 0
# Example configuration entry
pcf8574:
- id: 'pcf8574_hub_out_1' # for output channel 1-8
address: 0x24
- id: 'pcf8574_hub_out_2' # for output channel 9-16
address: 0x25
- id: 'pcf8574_hub_in_1' # for input channel 1-8
address: 0x21
- id: 'pcf8574_hub_in_2' # for input channel 9-16
address: 0x22
# Individual outputs
switch:
- platform: gpio
name: "light1"
pin:
pcf8574: pcf8574_hub_out_1
# Use pin number 0
number: 0
# One of INPUT or OUTPUT
mode: OUTPUT
inverted: false
- platform: gpio
name: "light9"
pin:
pcf8574: pcf8574_hub_out_2
# Use pin number 0
number: 0
# One of INPUT or OUTPUT
mode: OUTPUT
inverted: false
binary_sensor:
- platform: gpio
name: "input1"
pin:
pcf8574: pcf8574_hub_in_1
# Use pin number 0
number: 0
# One of INPUT or OUTPUT
mode: INPUT
inverted: false
- platform: gpio
name: "input9"
pin:
pcf8574: pcf8574_hub_in_2
# Use pin number 0
number: 0
# One of INPUT or OUTPUT
mode: INPUT
inverted: false
# Enable logging
logger:
# Enable Home Assistant API
api:
--------------------------------------------------------
esphome:
name: relay1
platform: ESP32
board: esp32dev
# Example configuration entry for ESP32
i2c:
sda: 4
scl: 5
scan: true
id: bus_a
# Example configuration entry
ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO17_OUT
phy_addr: 0
# Example configuration entry
pcf8574:
- id: 'pcf8574_hub_out_1' # for output channel 1-8
address: 0x24
- id: 'pcf8574_hub_out_2' # for output channel 9-16
address: 0x25
- id: 'pcf8574_hub_in_1' # for input channel 1-8
address: 0x21
- id: 'pcf8574_hub_in_2' # for input channel 9-16
address: 0x22
# Individual outputs
switch:
- platform: gpio
name: "light1"
pin:
pcf8574: pcf8574_hub_out_1
# Use pin number 0
number: 0
# One of INPUT or OUTPUT
mode: OUTPUT
inverted: false
- platform: gpio
name: "light9"
pin:
pcf8574: pcf8574_hub_out_2
# Use pin number 0
number: 0
# One of INPUT or OUTPUT
mode: OUTPUT
inverted: false
binary_sensor:
- platform: gpio
name: "input1"
pin:
pcf8574: pcf8574_hub_in_1
# Use pin number 0
number: 0
# One of INPUT or OUTPUT
mode: INPUT
inverted: false
- platform: gpio
name: "input9"
pin:
pcf8574: pcf8574_hub_in_2
# Use pin number 0
number: 0
# One of INPUT or OUTPUT
mode: INPUT
inverted: false
# Enable logging
logger:
# Enable Home Assistant API
api: