Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CO16 ESPHome yaml for home assistant without tuya
#1
   
Code:
esphome:
  name: kincony-co16
  friendly_name: KinCony CO16
  name_add_mac_suffix: true
  min_version: 2026.5.3

esp32:
  variant: esp32s3
  flash_size: 16MB
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: y
      CONFIG_ESP32S3_DATA_CACHE_64KB: y
      CONFIG_ESP32S3_DATA_CACHE_LINE_64B: y
      CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y
      CONFIG_SPIRAM_RODATA: y

psram:
  mode: octal
  speed: 80MHz

logger:
  hardware_uart: USB_SERIAL_JTAG

api:

ota:
  - platform: esphome

# ESPHome does not support Ethernet and Wi-Fi at the same time. Remove this
# block before adding a wifi: configuration.
ethernet:
  type: W5500
  clk_pin: GPIO1
  mosi_pin: GPIO2
  miso_pin: GPIO41
  cs_pin: GPIO42
  interrupt_pin: GPIO43
  reset_pin: GPIO44
  clock_speed: 16MHz
  interface: spi2

web_server:
  port: 80
 
external_components:
  - source:
      type: git
      url: https://github.com/hzkincony/esphome-nx3l4051
      ref: c3b3d5fe6a23e43875dab20dce9ee517a67e95a1
    components:
      - nx3l4051
      - nx3l4051_max31865

i2c:
  sda: GPIO8
  scl: GPIO18
  frequency: 100kHz
  scan: true

pcf8574:
  - id: co16_relay_hub
    address: 0x22
    pcf8575: true

xl9535:
  - id: co16_input_hub
    address: 0x24

ads1115:
  - id: co16_adc_01_04
    address: 0x48
  - id: co16_adc_05_08
    address: 0x49
  - id: co16_adc_09_12
    address: 0x4B
  - id: co16_adc_13_16
    address: 0x4A

nx3l4051:
  - id: co16_pt100_mux
    pin_s1: GPIO7
    pin_s2: GPIO21
    pin_s3: LOW
    delay: 20ms

globals:
  - id: co16_pt100_channel
    type: uint8_t
    restore_value: false
    initial_value: "0"

switch:
  - platform: gpio
    name: "CO16 Output 01"
    id: co16_output_01
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 0
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: "CO16 Output 02"
    id: co16_output_02
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 1
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: "CO16 Output 03"
    id: co16_output_03
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 2
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: "CO16 Output 04"
    id: co16_output_04
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 3
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: "CO16 Output 05"
    id: co16_output_05
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 4
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: "CO16 Output 06"
    id: co16_output_06
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 5
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: "CO16 Output 07"
    id: co16_output_07
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 6
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: "CO16 Output 08"
    id: co16_output_08
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 7
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: "CO16 Output 09"
    id: co16_output_09
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 8
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: "CO16 Output 10"
    id: co16_output_10
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 9
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: "CO16 Output 11"
    id: co16_output_11
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 10
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: "CO16 Output 12"
    id: co16_output_12
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 11
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: "CO16 Output 13"
    id: co16_output_13
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 12
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: "CO16 Output 14"
    id: co16_output_14
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 13
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: "CO16 Output 15"
    id: co16_output_15
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 14
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: "CO16 Output 16"
    id: co16_output_16
    restore_mode: ALWAYS_OFF
    pin:
      pcf8574: co16_relay_hub
      number: 15
      mode: OUTPUT
      inverted: true

binary_sensor:
  - platform: gpio
    name: "CO16 Input 01"
    id: co16_input_01
    pin:
      xl9535: co16_input_hub
      number: 0
      mode: INPUT
      inverted: true
  - platform: gpio
    name: "CO16 Input 02"
    id: co16_input_02
    pin:
      xl9535: co16_input_hub
      number: 1
      mode: INPUT
      inverted: true
  - platform: gpio
    name: "CO16 Input 03"
    id: co16_input_03
    pin:
      xl9535: co16_input_hub
      number: 2
      mode: INPUT
      inverted: true
  - platform: gpio
    name: "CO16 Input 04"
    id: co16_input_04
    pin:
      xl9535: co16_input_hub
      number: 3
      mode: INPUT
      inverted: true
  - platform: gpio
    name: "CO16 Input 05"
    id: co16_input_05
    pin:
      xl9535: co16_input_hub
      number: 4
      mode: INPUT
      inverted: true
  - platform: gpio
    name: "CO16 Input 06"
    id: co16_input_06
    pin:
      xl9535: co16_input_hub
      number: 5
      mode: INPUT
      inverted: true
  - platform: gpio
    name: "CO16 Input 07"
    id: co16_input_07
    pin:
      xl9535: co16_input_hub
      number: 6
      mode: INPUT
      inverted: true
  - platform: gpio
    name: "CO16 Input 08"
    id: co16_input_08
    pin:
      xl9535: co16_input_hub
      number: 7
      mode: INPUT
      inverted: true
  - platform: gpio
    name: "CO16 Input 09"
    id: co16_input_09
    pin:
      xl9535: co16_input_hub
      number: 10
      mode: INPUT
      inverted: true
  - platform: gpio
    name: "CO16 Input 10"
    id: co16_input_10
    pin:
      xl9535: co16_input_hub
      number: 11
      mode: INPUT
      inverted: true
  - platform: gpio
    name: "CO16 Input 11"
    id: co16_input_11
    pin:
      xl9535: co16_input_hub
      number: 12
      mode: INPUT
      inverted: true
  - platform: gpio
    name: "CO16 Input 12"
    id: co16_input_12
    pin:
      xl9535: co16_input_hub
      number: 13
      mode: INPUT
      inverted: true
  - platform: gpio
    name: "CO16 Input 13"
    id: co16_input_13
    pin:
      xl9535: co16_input_hub
      number: 14
      mode: INPUT
      inverted: true
  - platform: gpio
    name: "CO16 Input 14"
    id: co16_input_14
    pin:
      xl9535: co16_input_hub
      number: 15
      mode: INPUT
      inverted: true
  - platform: gpio
    name: "CO16 Input 15"
    id: co16_input_15
    pin:
      xl9535: co16_input_hub
      number: 16
      mode: INPUT
      inverted: true
  - platform: gpio
    name: "CO16 Input 16"
    id: co16_input_16
    pin:
      xl9535: co16_input_hub
      number: 17
      mode: INPUT
      inverted: true

sensor:
  # The default filters expose the terminal measurements as 0-10 V.
  # For a 4-20 mA channel, replace its filters with: [{multiply: 10.0}]
  # and change the unit/device class to mA/current.
  - platform: ads1115
    ads1115_id: co16_adc_01_04
    multiplexer: A0_GND
    gain: 4.096
    name: "CO16 Analog Input 01"
    id: co16_analog_input_01
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0
  - platform: ads1115
    ads1115_id: co16_adc_01_04
    multiplexer: A1_GND
    gain: 4.096
    name: "CO16 Analog Input 02"
    id: co16_analog_input_02
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0
  - platform: ads1115
    ads1115_id: co16_adc_01_04
    multiplexer: A2_GND
    gain: 4.096
    name: "CO16 Analog Input 03"
    id: co16_analog_input_03
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0
  - platform: ads1115
    ads1115_id: co16_adc_01_04
    multiplexer: A3_GND
    gain: 4.096
    name: "CO16 Analog Input 04"
    id: co16_analog_input_04
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0
  - platform: ads1115
    ads1115_id: co16_adc_05_08
    multiplexer: A0_GND
    gain: 4.096
    name: "CO16 Analog Input 05"
    id: co16_analog_input_05
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0
  - platform: ads1115
    ads1115_id: co16_adc_05_08
    multiplexer: A1_GND
    gain: 4.096
    name: "CO16 Analog Input 06"
    id: co16_analog_input_06
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0
  - platform: ads1115
    ads1115_id: co16_adc_05_08
    multiplexer: A2_GND
    gain: 4.096
    name: "CO16 Analog Input 07"
    id: co16_analog_input_07
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0
  - platform: ads1115
    ads1115_id: co16_adc_05_08
    multiplexer: A3_GND
    gain: 4.096
    name: "CO16 Analog Input 08"
    id: co16_analog_input_08
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0
  - platform: ads1115
    ads1115_id: co16_adc_09_12
    multiplexer: A0_GND
    gain: 4.096
    name: "CO16 Analog Input 09"
    id: co16_analog_input_09
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0
  - platform: ads1115
    ads1115_id: co16_adc_09_12
    multiplexer: A1_GND
    gain: 4.096
    name: "CO16 Analog Input 10"
    id: co16_analog_input_10
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0
  - platform: ads1115
    ads1115_id: co16_adc_09_12
    multiplexer: A2_GND
    gain: 4.096
    name: "CO16 Analog Input 11"
    id: co16_analog_input_11
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0
  - platform: ads1115
    ads1115_id: co16_adc_09_12
    multiplexer: A3_GND
    gain: 4.096
    name: "CO16 Analog Input 12"
    id: co16_analog_input_12
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0
  - platform: ads1115
    ads1115_id: co16_adc_13_16
    multiplexer: A0_GND
    gain: 4.096
    name: "CO16 Analog Input 13"
    id: co16_analog_input_13
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0
  - platform: ads1115
    ads1115_id: co16_adc_13_16
    multiplexer: A1_GND
    gain: 4.096
    name: "CO16 Analog Input 14"
    id: co16_analog_input_14
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0
  - platform: ads1115
    ads1115_id: co16_adc_13_16
    multiplexer: A2_GND
    gain: 4.096
    name: "CO16 Analog Input 15"
    id: co16_analog_input_15
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0
  - platform: ads1115
    ads1115_id: co16_adc_13_16
    multiplexer: A3_GND
    gain: 4.096
    name: "CO16 Analog Input 16"
    id: co16_analog_input_16
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 2
    update_interval: 5s
    filters:
      - lambda: 'return x <= 0.0025f ? 0.0f : x;'
      - multiply: 5.16696
      - clamp:
          min_value: 0.0
          max_value: 10.0

  - platform: nx3l4051_max31865
    id: co16_pt100_reader
    mux_id: co16_pt100_mux
    internal: true
    clk_pin: GPIO11
    mosi_pin: GPIO10
    miso_pin: GPIO12
    cs_pin: GPIO14
    reference_resistance: 400 ohm
    rtd_nominal_resistance: 100 ohm
    rtd_wires: 3
    mains_filter: 50 Hz
    update_interval: never

  - platform: template
    name: "CO16 PT100 01"
    id: co16_pt100_01
    unit_of_measurement: "°C"
    device_class: temperature
    state_class: measurement
    accuracy_decimals: 2
    update_interval: never
  - platform: template
    name: "CO16 PT100 02"
    id: co16_pt100_02
    unit_of_measurement: "°C"
    device_class: temperature
    state_class: measurement
    accuracy_decimals: 2
    update_interval: never
  - platform: template
    name: "CO16 PT100 03"
    id: co16_pt100_03
    unit_of_measurement: "°C"
    device_class: temperature
    state_class: measurement
    accuracy_decimals: 2
    update_interval: never
  - platform: template
    name: "CO16 PT100 04"
    id: co16_pt100_04
    unit_of_measurement: "°C"
    device_class: temperature
    state_class: measurement
    accuracy_decimals: 2
    update_interval: never

interval:
  - interval: 10s
    then:
      - repeat:
          count: 4
          then:
            - nx3l4051.select:
                id: co16_pt100_mux
                channel: !lambda return id(co16_pt100_channel);
            - component.update: co16_pt100_reader
            - delay: 70ms
            - lambda: |-
                const float value = id(co16_pt100_reader).state;
                switch (id(co16_pt100_channel)) {
                  case 0:
                    id(co16_pt100_01).publish_state(value);
                    break;
                  case 1:
                    id(co16_pt100_02).publish_state(value);
                    break;
                  case 2:
                    id(co16_pt100_03).publish_state(value);
                    break;
                  default:
                    id(co16_pt100_04).publish_state(value);
                    break;
                }
                id(co16_pt100_channel) = (id(co16_pt100_channel) + 1) % 4;
esphome yaml file download:

.txt   CO16-HA-without-Tuya.txt (Size: 17.05 KB / Downloads: 11)
Reply


Forum Jump:


Users browsing this thread: