Need help with configuring 8 channel relay module HS-58S v1.2 with ESP32 in HA with TTP223 touch switch

Hi! Someone might have same post as this but can't find to get a yaml code to solve the issues I've encountered. It seems working but the issue is the relay is not responding despite status is already open in HA when touch switch is in on-state. Can anyone help me find out what's missing in my code? Any help is well appreciated.

switch:
  - platform: gpio
    pin: GPIO17
    name: Relay C1
    id: relay_c1
    inverted: true
  - platform: gpio
    pin: GPIO18
    name: Relay C2
    id: relay_c2
    inverted: true
  - platform: gpio
    pin: GPIO19
    name: Relay C3
    id: relay_c3
    inverted: true  
  - platform: gpio
    pin: GPIO21
    name: Relay C4
    id: relay_c4
    inverted: true
  - platform: gpio
    pin: GPIO22
    name: Relay C5
    id: relay_c5
    inverted: true
  - platform: gpio
    pin: GPIO23
    name: Relay C6
    id: relay_c6
    inverted: true
  - platform: gpio
    pin: GPIO25
    name: Relay C7
    id: relay_c7
    inverted: true
  - platform: gpio
    pin: GPIO26
    name: Relay C8
    id: relay_c8
    inverted: true

binary_sensor:
  - platform: gpio
    pin:
      number: 2
      ignore_strapping_warning: true
      mode:
        input: true
        pullup: true
    internal: true
    name: C1 TSwitch
    id: c1_tswitch
    filters:
      - delayed_on: 50ms
      - delayed_off: 50ms
    on_state:
      then:
        - if:
            condition:
              lambda: return x;
            then:
              - switch.turn_on: relay_c1
            else: 
              - switch.turn_off: relay_c1
  - platform: gpio
    pin: GPIO4
    name: C2 TSwitch
    id: c2_tswitch
    filters:
      - delayed_on: 50ms
      - delayed_off: 50ms
    on_state:
      then:
        - if:
            condition:
              lambda: return x;
            then:
              - switch.turn_on: relay_c2
            else: 
              - switch.turn_off: relay_c2
  - platform: gpio
    pin:
      number: 12
      ignore_strapping_warning: true
    name: C3 TSwitch
    id: c3_tswitch
    filters:
      - delayed_on: 50ms
      - delayed_off: 50ms
    on_state:
      then:
        - if:
            condition:
              lambda: return x;
            then:
              - switch.turn_on: relay_c3
            else: 
              - switch.turn_off: relay_c3
  - platform: gpio
    pin: GPIO13
    name: C4 TSwitch
    id: c4_tswitch
    filters:
      - delayed_on: 50ms
      - delayed_off: 50ms
    on_state:
      then:
        - if:
            condition:
              lambda: return x;
            then:
              - switch.turn_on: relay_c4
            else: 
              - switch.turn_off: relay_c4
  - platform: gpio
    pin: GPIO14
    name: C5 TSwitch
    id: c5_tswitch
    filters:
      - delayed_on: 50ms
      - delayed_off: 50ms
    on_state:
      then:
        - if:
            condition:
              lambda: return x;
            then:
              - switch.turn_on: relay_c5
            else: 
              - switch.turn_off: relay_c5
  - platform: gpio
    pin: GPIO27
    name: C6 TSwitch
    id: c6_tswitch
    filters:
      - delayed_on: 50ms
      - delayed_off: 50ms
    on_state:
      then:
        - if:
            condition:
              lambda: return x;
            then:
              - switch.turn_on: relay_c6
            else: 
              - switch.turn_off: relay_c6
  - platform: gpio
    pin: GPIO32
    name: C7 TSwitch
    id: c7_tswitch
    filters:
      - delayed_on: 50ms
      - delayed_off: 50ms
    on_state:
      then:
        - if:
            condition:
              lambda: return x;
            then:
              - switch.turn_on: relay_c7
            else: 
              - switch.turn_off: relay_c7
  - platform: gpio
    pin: GPIO33
    name: C8 TSwitch
    id: c8_tswitch
    filters:
      - delayed_on: 50ms
      - delayed_off: 50ms
    on_state:
      then:
        - if:
            condition:
              lambda: return x;
            then:
              - switch.turn_on: relay_c8
            else: 
              - switch.turn_off: relay_c8`

Welcome to the forums. Before we can assist, can you please include your yaml inside code tags? Accessed by the </> button on the posting toolbar, or by using backtick symbols.

It should look like this:

binary_sensor:
  - platform: gpio
    id: button
    pin:
      number: GPIO4
      inverted: true
      mode:
        input: true
        pullup: true

Apologies, first time posting in here...

I don't know your device and logic it uses, but if button has pullup, it is triggered by LOW signal. In that case you need to set inverted: true.

Other pins don't have pin configuration on your code.

I do have pin configuration prior to the binary sensor code:

switch:
  - platform: gpio
    pin: GPIO17
    name: Relay C1
    id: relay_c1
    inverted: true
  - platform: gpio
    pin: GPIO18
    name: Relay C2
    id: relay_c2
    inverted: true
  - platform: gpio
    pin: GPIO19
    name: Relay C3
    id: relay_c3
    inverted: true

You do have for the output, relay, which might be correct (or not).

What about the input, binary sensors? What's your logic? How did you configure your touch module? Why first pin has pullup and others dont?

...apology since I'm just new in yaml coding and trying to figure things out which is already confusing me...

Argument is more about the hardware than yaml. Those touch buttons have usually many options for logic output.

The TTP223 will act as touch switch with jumper B and open A. Basically it should trigger the relay on touch and remains in on-state until it will be touched again to turn off the relay...

TTP223 has 8 different output options. Perhaps you want to send photo of your module...


how I wired 1 pin relay with 1 ttp223 capacitive touch sensor. I have 8 ttp223 for individual relays

First remove power from your relay module, it's not correctly set up and can damage esp. Post a link to that specific module or good photo where pins and jumper are present.

I can only guess that your TTP223 module uses pad Q (push-pull) on it's pins. In that case remove the pullup from your sensor config and verify from your esphome logs that every button press changes the state of your binary sensor and state of the switch (just on logs, relay board unpowered).