esphome: name: "kincony-e16s-red" friendly_name: Kincony-E16S-Red esp32: board: esp32dev framework: type: arduino # Example configuration entry for ESP32 i2c: sda: 16 scl: 15 scan: true id: bus_a external_components: - source: type: git url: https://github.com/hzkincony/esphome-kc868-ha refresh: 0s uart: - id: rs485 tx_pin: 32 rx_pin: 13 baud_rate: 9600 debug: direction: BOTH dummy_receiver: false kc868_ha: uart_id: rs485 # Enable logging logger: baud_rate: 0 # Enable Home Assistant API api: reboot_timeout: 0s encryption: key: !secret encryption_key on_client_disconnected: then: - delay: 1s - script.execute: update_api_alarm on_client_connected: then: - delay: 1s - script.execute: update_api_alarm ota: - platform: esphome password: !secret ota_password wifi: ssid: !secret wifi_ssid password: !secret wifi_password reboot_timeout: 0s on_connect: then: - script.stop: update_wifi_alarm on_disconnect: then: - script.execute: update_wifi_alarm # Example configuration entry #ethernet: # type: LAN8720 # mdc_pin: GPIO23 # mdio_pin: GPIO18 # clk_mode: GPIO17_OUT # phy_addr: 0 # Optional manual IP # manual_ip: # static_ip: 192.168.1.199 # gateway: 192.168.1.1 # subnet: 255.255.255.0 pcf8574: - id: 'pcf8574_hub_out_1' # for output channel 1-8 address: 0x21 - id: 'pcf8574_hub_out_2' # for output channel 9-16 address: 0x25 - id: 'pcf8574_hub_in_1' # for input channel 1-8 address: 0x22 - id: 'pcf8574_hub_in_2' # for input channel 9-16 address: 0x24 button: - platform: template name: "Beep 1" icon: "mdi:volume-high" on_press: - script.execute: short_short_beeps - platform: template name: "Beep 2" icon: "mdi:volume-high" on_press: - script.execute: long_short_short_beeps # Individual outputs switch: - platform: gpio id: onboard_buzzer name: "Onboard Buzzer" internal: true restore_mode: ALWAYS_OFF pin: number: GPIO2 mode: OUTPUT inverted: false # HAv2 ADDR 10 - D1:D6 - id: hav2_10_d1 platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 10 bind_output: 6 name: "HAv2 #10 D1 Led" internal: true - id: hav2_10_d2 platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 10 bind_output: 5 name: "HAv2 #10 D2 Led" internal: true - id: hav2_10_d3 platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 10 bind_output: 4 name: "HAv2 #10 D3 Led" internal: true - id: hav2_10_d4 platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 10 bind_output: 3 name: "HAv2 #10 D4 Led" internal: true # HAv2 ADDR 11 - D1:D6 - id: hav2_11_d1 platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 11 bind_output: 12 name: "HAv2 #11 D1 Led" internal: true - id: hav2_11_d2 platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 11 bind_output: 11 name: "HAv2 #11 D2 Led" internal: true - id: hav2_11_d3 platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 11 bind_output: 10 name: "HAv2 #11 D3 Led" internal: true - id: hav2_11_d4 platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 11 bind_output: 9 name: "HAv2 #11 D4 Led" internal: true - id: hav2_11_d5 platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 11 bind_output: 8 name: "HAv2 #11 D4 Led" internal: true # HAv2 ADDR 12 - D1:D6 - id: hav2_12_d1 name: "HAv2 #12 D1 Led" platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 12 bind_output: 18 internal: true - id: hav2_12_d2 name: "HAv2 #12 D2 Led" platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 12 bind_output: 17 internal: true - id: hav2_12_d3 name: "HAv2 #12 D3 Led" platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 12 bind_output: 16 internal: true - id: hav2_12_d4 name: "HAv2 #12 D4 Led" platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 12 bind_output: 15 internal: true - id: hav2_12_d5 name: "HAv2 #12 D5 Led" platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 12 bind_output: 14 internal: true - id: hav2_12_d6 name: "HAv2 #12 D6 Led" platform: kc868_ha target_relay_controller_addr: 1 switch_adapter_addr: 12 bind_output: 13 internal: true # Physical relay outputs, internal output: - id: relay_output1 platform: gpio pin: pcf8574: pcf8574_hub_out_1 number: 0 mode: OUTPUT inverted: true - id: relay_output2 platform: gpio pin: pcf8574: pcf8574_hub_out_1 number: 1 mode: OUTPUT inverted: true - id: relay_output3 platform: gpio pin: pcf8574: pcf8574_hub_out_1 number: 2 mode: OUTPUT inverted: true - id: relay_output4 platform: gpio pin: pcf8574: pcf8574_hub_out_1 number: 3 mode: OUTPUT inverted: true - id: relay_output5 platform: gpio pin: pcf8574: pcf8574_hub_out_1 number: 4 mode: OUTPUT inverted: true - id: relay_output6 platform: gpio pin: pcf8574: pcf8574_hub_out_1 number: 5 mode: OUTPUT inverted: true - id: relay_output7 platform: gpio pin: pcf8574: pcf8574_hub_out_1 number: 6 mode: OUTPUT inverted: true - id: relay_output8 platform: gpio pin: pcf8574: pcf8574_hub_out_1 number: 7 mode: OUTPUT inverted: true - id: relay_output9 platform: gpio pin: pcf8574: pcf8574_hub_out_2 number: 0 mode: OUTPUT inverted: true - id: relay_output10 platform: gpio pin: pcf8574: pcf8574_hub_out_2 number: 1 mode: OUTPUT inverted: true - id: relay_output11 platform: gpio pin: pcf8574: pcf8574_hub_out_2 number: 2 mode: OUTPUT inverted: true - id: relay_output12 platform: gpio pin: pcf8574: pcf8574_hub_out_2 number: 3 mode: OUTPUT inverted: true - id: relay_output13 platform: gpio pin: pcf8574: pcf8574_hub_out_2 number: 4 mode: OUTPUT inverted: true - id: relay_output14 platform: gpio pin: pcf8574: pcf8574_hub_out_2 number: 5 mode: OUTPUT inverted: true - id: relay_output15 platform: gpio pin: pcf8574: pcf8574_hub_out_2 number: 6 mode: OUTPUT inverted: true - id: relay_output16 platform: gpio pin: pcf8574: pcf8574_hub_out_2 number: 7 mode: OUTPUT inverted: true light: - id: channel_01 name: "CH-01" platform: binary output: relay_output1 restore_mode: RESTORE_DEFAULT_OFF - id: channel_02 name: "CH-02" platform: binary output: relay_output2 restore_mode: RESTORE_DEFAULT_OFF - id: channel_03 name: "CH-03" platform: binary output: relay_output3 restore_mode: RESTORE_DEFAULT_OFF - id: channel_04 name: "CH-04" platform: binary output: relay_output4 restore_mode: RESTORE_DEFAULT_OFF - id: channel_05 name: "CH-05" platform: binary output: relay_output5 restore_mode: RESTORE_DEFAULT_OFF - id: channel_06 name: "CH-06" platform: binary output: relay_output6 restore_mode: RESTORE_DEFAULT_OFF - id: channel_07 name: "CH-07" platform: binary output: relay_output7 restore_mode: RESTORE_DEFAULT_OFF - id: channel_08 name: "CH-08" platform: binary output: relay_output8 restore_mode: RESTORE_DEFAULT_OFF - id: channel_09 name: "CH-09" platform: binary output: relay_output9 restore_mode: RESTORE_DEFAULT_OFF - id: channel_10 name: "CH-10" platform: binary output: relay_output10 restore_mode: RESTORE_DEFAULT_OFF - id: channel_11 name: "CH-11" platform: binary output: relay_output11 restore_mode: RESTORE_DEFAULT_OFF - id: channel_12 name: "CH-12" platform: binary output: relay_output12 restore_mode: RESTORE_DEFAULT_OFF - id: channel_13 name: "CH-13" platform: binary output: relay_output13 restore_mode: RESTORE_DEFAULT_OFF - id: channel_14 name: "CH-14" platform: binary output: relay_output14 restore_mode: RESTORE_DEFAULT_OFF - id: channel_15 name: "CH-15" platform: binary output: relay_output15 restore_mode: RESTORE_DEFAULT_OFF - id: channel_16 name: "CH-16" platform: binary output: relay_output16 restore_mode: RESTORE_DEFAULT_OFF #-----------INPUTS------------ binary_sensor: # HAv2 ADDR 10 - K1:K4 - id: hav2_10_k1 name: "HAv2 #10 K1" platform: kc868_ha internal: true target_relay_controller_addr: 1 switch_adapter_addr: 10 bind_output: 6 on_press: then: - light.toggle: channel_13 - id: hav2_10_k2 name: "HAv2 #10 K2" platform: kc868_ha internal: true target_relay_controller_addr: 1 switch_adapter_addr: 10 bind_output: 5 on_press: then: - light.toggle: channel_14 - id: hav2_10_k3 name: "HAv2 #10 K3" platform: kc868_ha internal: true target_relay_controller_addr: 1 switch_adapter_addr: 10 bind_output: 4 on_press: then: - light.toggle: channel_15 - id: hav2_10_k4 name: "HAv2 #10 K4" platform: kc868_ha internal: true target_relay_controller_addr: 1 switch_adapter_addr: 10 bind_output: 3 on_press: then: - light.toggle: channel_16 # HAv2 ADDR 11 - K1:K5 - id: hav2_11_k1 name: "HAv2 #11 K1" platform: kc868_ha internal: true target_relay_controller_addr: 1 switch_adapter_addr: 11 bind_output: 12 on_press: then: - light.toggle: channel_13 - id: hav2_11_k2 name: "HAv2 #11 K2" platform: kc868_ha internal: true target_relay_controller_addr: 1 switch_adapter_addr: 11 bind_output: 11 on_press: then: - light.toggle: channel_14 - id: hav2_11_k3 name: "HAv2 #11 K3" platform: kc868_ha internal: true target_relay_controller_addr: 1 switch_adapter_addr: 11 bind_output: 10 on_press: then: - light.toggle: channel_15 - id: hav2_11_k4 name: "HAv2 #11 K4" platform: kc868_ha internal: true target_relay_controller_addr: 1 switch_adapter_addr: 11 bind_output: 9 on_press: then: - light.toggle: channel_16 - id: hav2_11_k5 name: "HAv2 #11 K5" platform: kc868_ha internal: true target_relay_controller_addr: 1 switch_adapter_addr: 11 bind_output: 8 on_press: then: - light.toggle: channel_16 # HAv2 ADDR 12 - K1:K4 - id: hav2_12_k1 name: "HAv2 #12 K1" platform: kc868_ha internal: true target_relay_controller_addr: 1 switch_adapter_addr: 12 bind_output: 18 on_press: then: - light.toggle: channel_03 - id: hav2_12_k2 name: "HAv2 #12 K2" platform: kc868_ha internal: true target_relay_controller_addr: 1 switch_adapter_addr: 12 bind_output: 17 on_press: then: - light.toggle: channel_04 - id: hav2_12_k3 name: "HAv2 #12 K3" platform: kc868_ha internal: true target_relay_controller_addr: 1 switch_adapter_addr: 12 bind_output: 16 on_press: then: - light.toggle: channel_05 - id: hav2_12_k4 name: "HAv2 #12 K4" platform: kc868_ha internal: true target_relay_controller_addr: 1 switch_adapter_addr: 12 bind_output: 15 on_press: then: - light.toggle: channel_06 - id: hav2_12_k5 name: "HAv2 #12 K5" platform: kc868_ha internal: true target_relay_controller_addr: 1 switch_adapter_addr: 12 bind_output: 14 on_press: then: - light.toggle: channel_01 - id: hav2_12_k6 name: "HAv2 #12 K6" platform: kc868_ha internal: true target_relay_controller_addr: 1 switch_adapter_addr: 12 bind_output: 13 on_press: then: - light.toggle: channel_02 - platform: gpio name: "BTN-16" on_press: then: - light.toggle: channel_16 pin: pcf8574: pcf8574_hub_in_1 number: 0 mode: INPUT inverted: true - platform: gpio name: "BTN-15" on_press: then: - light.toggle: channel_15 pin: pcf8574: pcf8574_hub_in_1 number: 1 mode: INPUT inverted: true - platform: gpio name: "BTN-14" on_press: then: - light.toggle: channel_14 pin: pcf8574: pcf8574_hub_in_1 number: 2 mode: INPUT inverted: true - platform: gpio name: "BTN-13" on_press: then: - light.toggle: channel_13 pin: pcf8574: pcf8574_hub_in_1 number: 3 mode: INPUT inverted: true - platform: gpio name: "BTN-12" on_press: then: - light.toggle: channel_12 pin: pcf8574: pcf8574_hub_in_1 number: 4 mode: INPUT inverted: true - platform: gpio name: "BTN-11" on_press: then: - light.toggle: channel_11 pin: pcf8574: pcf8574_hub_in_1 number: 5 mode: INPUT inverted: true - platform: gpio name: "BTN-10" on_press: then: - light.toggle: channel_10 pin: pcf8574: pcf8574_hub_in_1 number: 6 mode: INPUT inverted: true - platform: gpio name: "BTN-09" on_press: then: - light.toggle: channel_09 pin: pcf8574: pcf8574_hub_in_1 number: 7 mode: INPUT inverted: true - platform: gpio name: "BTN-08" on_press: then: - light.toggle: channel_08 pin: pcf8574: pcf8574_hub_in_2 number: 0 mode: INPUT inverted: true - platform: gpio name: "BTN-07" on_press: then: - light.toggle: channel_07 pin: pcf8574: pcf8574_hub_in_2 number: 1 mode: INPUT inverted: true - platform: gpio name: "BTN-06" on_press: then: - light.toggle: channel_06 pin: pcf8574: pcf8574_hub_in_2 number: 2 mode: INPUT inverted: true - platform: gpio name: "BTN-05" on_press: then: - light.toggle: channel_05 pin: pcf8574: pcf8574_hub_in_2 number: 3 mode: INPUT inverted: true - platform: gpio name: "BTN-04" on_press: then: - light.toggle: channel_04 pin: pcf8574: pcf8574_hub_in_2 number: 4 mode: INPUT inverted: true - platform: gpio name: "BTN-03" on_press: then: - light.toggle: channel_03 pin: pcf8574: pcf8574_hub_in_2 number: 5 mode: INPUT inverted: true - platform: gpio name: "BTN-02" on_press: then: - light.toggle: channel_02 pin: pcf8574: pcf8574_hub_in_2 number: 6 mode: INPUT inverted: true - platform: gpio name: "BTN-01" on_press: then: - light.toggle: channel_01 pin: pcf8574: pcf8574_hub_in_2 number: 7 mode: INPUT inverted: true script: - id: short_short_beeps mode: restart then: - switch.turn_on: onboard_buzzer - delay: 120ms - switch.turn_off: onboard_buzzer - delay: 120ms - switch.turn_on: onboard_buzzer - delay: 120ms - switch.turn_off: onboard_buzzer - id: long_short_short_beeps mode: restart then: - switch.turn_on: onboard_buzzer - delay: 150ms - switch.turn_off: onboard_buzzer - delay: 120ms - switch.turn_on: onboard_buzzer - delay: 120ms - switch.turn_off: onboard_buzzer - delay: 120ms - switch.turn_on: onboard_buzzer - delay: 120ms - switch.turn_off: onboard_buzzer - id: wifi_offline_beep_loop mode: restart then: - delay: 1min - while: condition: not: wifi.connected: then: - script.execute: short_short_beeps - delay: 1min - id: api_offline_beep_loop mode: restart then: - delay: 1min - while: condition: and: - wifi.connected: - not: api.connected: state_subscription_only: true then: - script.execute: long_short_short_beeps - delay: 1min - id: update_wifi_alarm mode: restart then: - if: condition: not: wifi.connected: then: - if: condition: not: script.is_running: wifi_offline_beep_loop then: - script.execute: wifi_offline_beep_loop else: - script.stop: wifi_offline_beep_loop - switch.turn_off: onboard_buzzer - id: update_api_alarm mode: restart then: - if: condition: and: - wifi.connected: - not: api.connected: state_subscription_only: true then: - if: condition: not: script.is_running: api_offline_beep_loop then: - script.execute: api_offline_beep_loop else: - script.stop: api_offline_beep_loop - switch.turn_off: onboard_buzzer