Guest User

Untitled

a guest
Sep 5th, 2026
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 14.66 KB | None | 0 0
  1. esphome:
  2.   name: "kincony-e16s-red"
  3.   friendly_name: Kincony-E16S-Red
  4.  
  5. esp32: 
  6.   board: esp32dev
  7.   framework:
  8.     type: arduino
  9.  
  10. # Example configuration entry for ESP32
  11. i2c:
  12.   sda: 16
  13.   scl: 15
  14.   scan: true
  15.   id: bus_a
  16.  
  17. external_components:
  18.   - source:
  19.       type: git
  20.       url: https://github.com/hzkincony/esphome-kc868-ha
  21.       ref: v3.0.3
  22.  
  23.  
  24. uart:
  25.   - id: rs485
  26.     tx_pin: 32
  27.     rx_pin: 13 
  28.     baud_rate: 9600
  29.  
  30. kc868_ha:
  31.   uart_id: rs485
  32.  
  33. # Enable logging
  34. logger:
  35.   baud_rate: 0
  36.  
  37. # Enable Home Assistant API
  38. api:
  39.   reboot_timeout: 0s
  40.   encryption:
  41.     key: "REDACTED"
  42.  
  43.   on_client_disconnected:
  44.     then:
  45.       - delay: 1s
  46.       - script.execute: update_api_alarm
  47.  
  48.   on_client_connected:
  49.     then:
  50.       - delay: 1s
  51.       - script.execute: update_api_alarm
  52.  
  53. ota:
  54.   - platform: esphome
  55.     password: "REDACTED"
  56.  
  57. wifi:
  58.   ssid: !secret wifi_ssid
  59.   password: !secret wifi_password
  60.   reboot_timeout: 0s
  61.  
  62.   on_connect:
  63.     then:
  64.       - script.stop: update_wifi_alarm
  65.  
  66.   on_disconnect:
  67.     then:
  68.       - script.execute: update_wifi_alarm
  69.  
  70. # Example configuration entry
  71. #ethernet:
  72. #  type: LAN8720
  73. #  mdc_pin: GPIO23
  74. #  mdio_pin: GPIO18
  75. #  clk_mode: GPIO17_OUT
  76. #  phy_addr: 0
  77.  
  78.   # Optional manual IP
  79. #   manual_ip:
  80. #    static_ip: 192.168.1.199
  81. #    gateway: 192.168.1.1
  82. #    subnet: 255.255.255.0 
  83.  
  84.  
  85. # Example configuration entry
  86. pcf8574:
  87.   - id: 'pcf8574_hub_out_1' # for output channel 1-8
  88.     address: 0x21
  89.  
  90.   - id: 'pcf8574_hub_out_2' # for output channel 9-16
  91.     address: 0x25
  92.  
  93.   - id: 'pcf8574_hub_in_1' # for input channel 1-8
  94.     address: 0x22
  95.  
  96.   - id: 'pcf8574_hub_in_2' # for input channel 9-16
  97.     address: 0x24
  98.  
  99. button:
  100.   - platform: template
  101.     name: "Beep 1"
  102.     icon: "mdi:volume-high"
  103.     on_press:
  104.       - script.execute: short_short_beeps
  105.  
  106.   - platform: template
  107.     name: "Beep 2"
  108.     icon: "mdi:volume-high"
  109.     on_press:
  110.       - script.execute: long_short_short_beeps
  111.  
  112. # Individual outputs
  113. switch:
  114.   - platform: gpio
  115.     id: onboard_buzzer
  116.     name: "Onboard Buzzer"
  117.     internal: true
  118.     restore_mode: ALWAYS_OFF
  119.     pin:
  120.       number: GPIO2
  121.       mode: OUTPUT
  122.       inverted: false
  123.   - platform: kc868_ha
  124.     target_relay_controller_addr: 1
  125.     switch_adapter_addr: 10
  126.     bind_output: 1
  127.     name: "RS 485 Serial Switch 6"
  128.   - platform: kc868_ha
  129.     target_relay_controller_addr: 1
  130.     switch_adapter_addr: 10
  131.     bind_output: 2
  132.     name: "RS 485 Serial Switch 5"
  133.   - platform: kc868_ha
  134.     target_relay_controller_addr: 1
  135.     switch_adapter_addr: 10
  136.     bind_output: 3
  137.     name: "RS 485 Serial Switch 4"
  138.   - platform: kc868_ha
  139.     target_relay_controller_addr: 1
  140.     switch_adapter_addr: 10
  141.     bind_output: 4
  142.     name: "RS 485 Serial Switch 3"
  143.   - platform: kc868_ha
  144.     target_relay_controller_addr: 1
  145.     switch_adapter_addr: 10
  146.     bind_output: 5
  147.     name: "RS 485 Serial Switch 2"
  148.   - platform: kc868_ha
  149.     target_relay_controller_addr: 1
  150.     switch_adapter_addr: 10
  151.     bind_output: 6
  152.     name: "RS 485 Serial Switch 1"
  153.  
  154.   - platform: gpio
  155.     name: "e16s-output1"
  156.     restore_mode: RESTORE_DEFAULT_OFF
  157.     pin:
  158.       pcf8574: pcf8574_hub_out_1
  159.       number: 0
  160.       mode: OUTPUT
  161.       inverted: true
  162.     id: output1
  163.  
  164.   - platform: gpio
  165.     name: "e16s-output2"
  166.     restore_mode: RESTORE_DEFAULT_OFF
  167.     pin:
  168.       pcf8574: pcf8574_hub_out_1
  169.       number: 1
  170.       mode: OUTPUT
  171.       inverted: true
  172.     id: output2
  173.  
  174.   - platform: gpio
  175.     name: "e16s-output3"
  176.     restore_mode: RESTORE_DEFAULT_OFF
  177.     pin:
  178.       pcf8574: pcf8574_hub_out_1
  179.       number: 2
  180.       mode: OUTPUT
  181.       inverted: true
  182.     id: output3
  183.  
  184.   - platform: gpio
  185.     name: "e16s-output4"
  186.     restore_mode: RESTORE_DEFAULT_OFF
  187.     pin:
  188.       pcf8574: pcf8574_hub_out_1
  189.       number: 3
  190.       mode: OUTPUT
  191.       inverted: true
  192.     id: output4
  193.  
  194.   - platform: gpio
  195.     name: "e16s-output5"
  196.     restore_mode: RESTORE_DEFAULT_OFF
  197.     pin:
  198.       pcf8574: pcf8574_hub_out_1
  199.       number: 4
  200.       mode: OUTPUT
  201.       inverted: true
  202.     id: output5
  203.  
  204.   - platform: gpio
  205.     name: "e16s-output6"
  206.     restore_mode: RESTORE_DEFAULT_OFF
  207.     pin:
  208.       pcf8574: pcf8574_hub_out_1
  209.       number: 5
  210.       mode: OUTPUT
  211.       inverted: true
  212.     id: output6
  213.  
  214.   - platform: gpio
  215.     name: "e16s-output7"
  216.     restore_mode: RESTORE_DEFAULT_OFF
  217.     pin:
  218.       pcf8574: pcf8574_hub_out_1
  219.       number: 6
  220.       mode: OUTPUT
  221.       inverted: true
  222.     id: output7
  223.  
  224.   - platform: gpio
  225.     name: "e16s-output8"
  226.     restore_mode: RESTORE_DEFAULT_OFF
  227.     pin:
  228.       pcf8574: pcf8574_hub_out_1
  229.       number: 7
  230.       mode: OUTPUT
  231.       inverted: true
  232.     id: output8
  233.  
  234.   - platform: gpio
  235.     name: "e16s-output9"
  236.     restore_mode: RESTORE_DEFAULT_OFF
  237.     pin:
  238.       pcf8574: pcf8574_hub_out_2
  239.       number: 0
  240.       mode: OUTPUT
  241.       inverted: true
  242.     id: output9
  243.  
  244.   - platform: gpio
  245.     name: "e16s-output10"
  246.     restore_mode: RESTORE_DEFAULT_OFF
  247.     pin:
  248.       pcf8574: pcf8574_hub_out_2
  249.       number: 1
  250.       mode: OUTPUT
  251.       inverted: true
  252.     id: output10
  253.  
  254.   - platform: gpio
  255.     name: "e16s-output11"
  256.     restore_mode: RESTORE_DEFAULT_OFF
  257.     pin:
  258.       pcf8574: pcf8574_hub_out_2
  259.       number: 2
  260.       mode: OUTPUT
  261.       inverted: true
  262.     id: output11
  263.  
  264.   - platform: gpio
  265.     name: "e16s-output12"
  266.     restore_mode: RESTORE_DEFAULT_OFF
  267.     pin:
  268.       pcf8574: pcf8574_hub_out_2
  269.       number: 3
  270.       mode: OUTPUT
  271.       inverted: true
  272.     id: output12
  273.  
  274.   - platform: gpio
  275.     name: "e16s-output13"
  276.     restore_mode: RESTORE_DEFAULT_OFF
  277.     pin:
  278.       pcf8574: pcf8574_hub_out_2
  279.       number: 4
  280.       mode: OUTPUT
  281.       inverted: true
  282.     id: output13
  283.  
  284.   - platform: gpio
  285.     name: "e16s-output14"
  286.     restore_mode: RESTORE_DEFAULT_OFF
  287.     pin:
  288.       pcf8574: pcf8574_hub_out_2
  289.       number: 5
  290.       mode: OUTPUT
  291.       inverted: true
  292.     id: output14
  293.  
  294.   - platform: gpio
  295.     name: "e16s-output15"
  296.     restore_mode: RESTORE_DEFAULT_OFF
  297.     pin:
  298.       pcf8574: pcf8574_hub_out_2
  299.       number: 6
  300.       mode: OUTPUT
  301.       inverted: true
  302.     id: output15
  303.  
  304.   - platform: gpio
  305.     name: "e16s-output16"
  306.     restore_mode: RESTORE_DEFAULT_OFF
  307.     pin:
  308.       pcf8574: pcf8574_hub_out_2
  309.       number: 7
  310.       mode: OUTPUT
  311.       inverted: true
  312.     id: output16
  313.  
  314. #-----------INPUTS------------
  315.  
  316. binary_sensor:
  317.   - platform: kc868_ha
  318.     name: "RS 485 Serial Input 1"
  319.     target_relay_controller_addr: 1
  320.     switch_adapter_addr: 10
  321.     bind_output: 1
  322.     on_press:
  323.       then:
  324.         - switch.toggle: output1
  325.   - platform: kc868_ha
  326.     name: "RS 485 Serial Input 2"
  327.     target_relay_controller_addr: 1
  328.     switch_adapter_addr: 10
  329.     bind_output: 2
  330.     on_press:
  331.       then:
  332.         - switch.toggle: output2
  333.   - platform: kc868_ha
  334.     name: "RS 485 Serial Input 3"
  335.     target_relay_controller_addr: 1
  336.     switch_adapter_addr: 10
  337.     bind_output: 3
  338.     on_press:
  339.       then:
  340.         - switch.toggle: output3
  341.   - platform: kc868_ha
  342.     name: "RS 485 Serial Input 4"
  343.     target_relay_controller_addr: 1
  344.     switch_adapter_addr: 10
  345.     bind_output: 4
  346.     on_press:
  347.       then:
  348.         - switch.toggle: output4
  349.   - platform: kc868_ha
  350.     name: "RS 485 Serial Input 5"
  351.     target_relay_controller_addr: 1
  352.     switch_adapter_addr: 10
  353.     bind_output: 5
  354.     on_press:
  355.       then:
  356.         - switch.toggle: output5
  357.   - platform: kc868_ha
  358.     name: "RS 485 Serial Input 6"
  359.     target_relay_controller_addr: 1
  360.     switch_adapter_addr: 10
  361.     bind_output: 6
  362.     on_press:
  363.       then:
  364.         - switch.toggle: output6
  365.  
  366.   - platform: gpio
  367.     name: "e16s-input16"
  368.     on_press:
  369.       then:
  370.         - switch.toggle: output16
  371.     pin:
  372.       pcf8574: pcf8574_hub_in_1
  373.       number: 0
  374.       mode: INPUT
  375.       inverted: true
  376.  
  377.   - platform: gpio
  378.     name: "e16s-input15"
  379.     on_press:
  380.       then:
  381.         - switch.toggle: output15
  382.     pin:
  383.       pcf8574: pcf8574_hub_in_1
  384.       number: 1
  385.       mode: INPUT
  386.       inverted: true
  387.  
  388.   - platform: gpio
  389.     name: "e16s-input14"
  390.     on_press:
  391.       then:
  392.         - switch.toggle: output14
  393.     pin:
  394.       pcf8574: pcf8574_hub_in_1
  395.       number: 2
  396.       mode: INPUT
  397.       inverted: true
  398.  
  399.   - platform: gpio
  400.     name: "e16s-input13"
  401.     on_press:
  402.       then:
  403.         - switch.toggle: output13
  404.     pin:
  405.       pcf8574: pcf8574_hub_in_1
  406.       number: 3
  407.       mode: INPUT
  408.       inverted: true
  409.  
  410.   - platform: gpio
  411.     name: "e16s-input12"
  412.     on_press:
  413.       then:
  414.         - switch.toggle: output12
  415.     pin:
  416.       pcf8574: pcf8574_hub_in_1
  417.       number: 4
  418.       mode: INPUT
  419.       inverted: true
  420.  
  421.   - platform: gpio
  422.     name: "e16s-input11"
  423.     on_press:
  424.       then:
  425.         - switch.toggle: output11
  426.     pin:
  427.       pcf8574: pcf8574_hub_in_1
  428.       number: 5
  429.       mode: INPUT
  430.       inverted: true
  431.  
  432.   - platform: gpio
  433.     name: "e16s-input10"
  434.     on_press:
  435.       then:
  436.         - switch.toggle: output10
  437.     pin:
  438.       pcf8574: pcf8574_hub_in_1
  439.       number: 6
  440.       mode: INPUT
  441.       inverted: true
  442.  
  443.   - platform: gpio
  444.     name: "e16s-input9"
  445.     on_press:
  446.       then:
  447.         - switch.toggle: output9
  448.     pin:
  449.       pcf8574: pcf8574_hub_in_1
  450.       number: 7
  451.       mode: INPUT
  452.       inverted: true
  453.  
  454.   - platform: gpio
  455.     name: "e16s-input8"
  456.     on_press:
  457.       then:
  458.         - switch.toggle: output8
  459.     pin:
  460.       pcf8574: pcf8574_hub_in_2
  461.       number: 0
  462.       mode: INPUT
  463.       inverted: true
  464.  
  465.   - platform: gpio
  466.     name: "e16s-input7"
  467.     on_press:
  468.       then:
  469.         - switch.toggle: output7
  470.     pin:
  471.       pcf8574: pcf8574_hub_in_2
  472.       number: 1
  473.       mode: INPUT
  474.       inverted: true
  475.  
  476.   - platform: gpio
  477.     name: "e16s-input6"
  478.     on_press:
  479.       then:
  480.         - switch.toggle: output6
  481.     pin:
  482.       pcf8574: pcf8574_hub_in_2
  483.       number: 2
  484.       mode: INPUT
  485.       inverted: true
  486.  
  487.   - platform: gpio
  488.     name: "e16s-input5"
  489.     on_press:
  490.       then:
  491.         - switch.toggle: output5
  492.     pin:
  493.       pcf8574: pcf8574_hub_in_2
  494.       number: 3
  495.       mode: INPUT
  496.       inverted: true
  497.  
  498.   - platform: gpio
  499.     name: "e16s-input4"
  500.     on_press:
  501.       then:
  502.         - switch.toggle: output4
  503.     pin:
  504.       pcf8574: pcf8574_hub_in_2
  505.       number: 4
  506.       mode: INPUT
  507.       inverted: true
  508.  
  509.   - platform: gpio
  510.     name: "e16s-input3"
  511.     on_press:
  512.       then:
  513.         - switch.toggle: output3
  514.     pin:
  515.       pcf8574: pcf8574_hub_in_2
  516.       number: 5
  517.       mode: INPUT
  518.       inverted: true
  519.  
  520.   - platform: gpio
  521.     name: "e16s-input2"
  522.     on_press:
  523.       then:
  524.         - switch.toggle: output2
  525.     pin:
  526.       pcf8574: pcf8574_hub_in_2
  527.       number: 6
  528.       mode: INPUT
  529.       inverted: true
  530.  
  531.   - platform: gpio
  532.     name: "e16s-input1"
  533.     on_press:
  534.       then:
  535.         - switch.toggle: output1
  536.     pin:
  537.       pcf8574: pcf8574_hub_in_2
  538.       number: 7
  539.       mode: INPUT
  540.       inverted: true
  541.  
  542. script:
  543.   - id: short_short_beeps
  544.     mode: restart
  545.     then:
  546.       - switch.turn_on: onboard_buzzer
  547.       - delay: 120ms
  548.       - switch.turn_off: onboard_buzzer
  549.       - delay: 120ms
  550.       - switch.turn_on: onboard_buzzer
  551.       - delay: 120ms
  552.       - switch.turn_off: onboard_buzzer
  553.  
  554.   - id: long_short_short_beeps
  555.     mode: restart
  556.     then:
  557.       - switch.turn_on: onboard_buzzer
  558.       - delay: 150ms
  559.       - switch.turn_off: onboard_buzzer
  560.       - delay: 120ms
  561.       - switch.turn_on: onboard_buzzer
  562.       - delay: 120ms
  563.       - switch.turn_off: onboard_buzzer
  564.       - delay: 120ms
  565.       - switch.turn_on: onboard_buzzer
  566.       - delay: 120ms
  567.       - switch.turn_off: onboard_buzzer
  568.  
  569.   - id: wifi_offline_beep_loop
  570.     mode: restart
  571.     then:
  572.       - delay: 1min
  573.       - while:
  574.           condition:
  575.             not:
  576.               wifi.connected: 
  577.           then:
  578.             - script.execute: short_short_beeps
  579.             - delay: 1min
  580.  
  581.   - id: api_offline_beep_loop
  582.     mode: restart
  583.     then:
  584.       - delay: 1min
  585.       - while:
  586.           condition:
  587.             and:
  588.               - wifi.connected:
  589.               - not:
  590.                   api.connected:
  591.                     state_subscription_only: true
  592.           then:
  593.             - script.execute: long_short_short_beeps
  594.             - delay: 1min
  595.  
  596.   - id: update_wifi_alarm
  597.     mode: restart
  598.     then:
  599.       - if:
  600.           condition:
  601.             not:
  602.               wifi.connected:
  603.           then:
  604.             - if:
  605.                 condition:
  606.                   not:
  607.                     script.is_running: wifi_offline_beep_loop
  608.                 then:
  609.                   - script.execute: wifi_offline_beep_loop
  610.           else:
  611.             - script.stop: wifi_offline_beep_loop
  612.             - switch.turn_off: onboard_buzzer
  613.  
  614.   - id: update_api_alarm
  615.     mode: restart
  616.     then:
  617.       - if:
  618.           condition:
  619.             and:
  620.               - wifi.connected:
  621.               - not:
  622.                   api.connected:
  623.                     state_subscription_only: true
  624.           then:
  625.             - if:
  626.                 condition:
  627.                   not:
  628.                     script.is_running: api_offline_beep_loop
  629.                 then:
  630.                   - script.execute: api_offline_beep_loop
  631.           else:
  632.             - script.stop: api_offline_beep_loop
  633.             - switch.turn_off: onboard_buzzer
Advertisement
Add Comment
Please, Sign In to add comment