SmartHome-yourself / sonoff-tx-ultimate-for-esphome

ESPHome Custom Component for Sonoff TX Ultimate
https://smarthomeyourself.de/sonoff-tx-ultimate-mit-esphome-custom-component/
MIT License
102 stars 46 forks source link

T5-4C-86: Relays not toggling when pressing physical touch buttons (only vibration triggered) #59

Open slarti123 opened 1 week ago

slarti123 commented 1 week ago

Description: I am currently using a Sonoff TX Ultimate (T5-4C-86, with 4 relays) configured with ESPHome. When I press any of the physical touch buttons on the device, the relays are not toggling as expected. Instead, each press only activates the vibration motor, regardless of which button is pressed.

However, when I control the relays through the Home Assistant GUI (e.g., switch.tx_ultimate_5_tx_ultimate_51_l1), the relays toggle correctly.

Steps to Reproduce:

  1. Flash the Sonoff TX Ultimate device with the ESPHome configuration.
  2. Press any of the four physical touch buttons on the device.
  3. Observe that only the vibration motor is triggered, and the relays do not toggle.

Logs: Here is the ESPHome log output when I press each touch button from left to right:

[16:25:22][D][tx_ultimate_touch.on_press:477]: Touch Position: 1 / State: 2 [16:25:23][D][tx_ultimate_touch.on_release:487]: Release Position: 1 / State: 1 [16:25:24][D][tx_ultimate_touch.on_press:477]: Touch Position: 4 / State: 2 [16:25:24][D][tx_ultimate_touch.on_release:487]: Release Position: 4 / State: 1 [16:25:25][D][tx_ultimate_touch.on_press:477]: Touch Position: 6 / State: 2 [16:25:25][D][tx_ultimate_touch.on_release:487]: Release Position: 6 / State: 1 [16:25:26][D][tx_ultimate_touch.on_press:477]: Touch Position: 10 / State: 2 [16:25:26][D][tx_ultimate_touch.on_release:487]: Release Position: 10 / State: 1

The Home Assistant logbook shows the following:

TX Ultimate 51 Vibration switched on TX Ultimate 51 Vibration switched off

What I Expect:

What Happens:

Additional Information:

Request:

Thank you in advance for your help!

slarti123 commented 1 week ago

I guess I "solved" it myself. I'm far from an expert, so please let me know, if there are any mistakes.

To troubleshoot, I utilized the local configuration file and made adjustments to the YAML settings.

Changes Made YAML Configuration Updates:

substitutions: toggle_relay_1_on_touch: "true" # Enable Relay 1 on touch toggle_relay_2_on_touch: "false" # Disable Relay 2 on touch toggle_relay_3_on_touch: "false" # Disable Relay 3 on touch toggle_relay_4_on_touch: "false" # Disable Relay 4 on touch

- id: handle_release
    mode: restart
    parameters:
      pos: int
    then:
      - if:
          condition:
            lambda: "return ${relay_count}==4;" 
          then:
            - if:
                condition:
                  lambda: "return pos <= 2;"  # Touch Position 1 und 2
                then:
                  - binary_sensor.template.publish:
                      id: touchfield_1
                      state: ON
            - if:
                condition:
                  lambda: "return pos >= 3 && pos <= 4;"  # Touch Position 3 und 4
                then:
                  - binary_sensor.template.publish:
                      id: touchfield_2
                      state: ON
            - if:
                condition:
                  lambda: "return pos >= 6 && pos <= 7;"  # Touch Position 6 und 7
                then:
                  - binary_sensor.template.publish:
                      id: touchfield_3
                      state: ON
            - if:
                condition:
                  lambda: "return pos >= 9 && pos <= 10;"  # Touch Position 9 und 10
                then:
                  - binary_sensor.template.publish:
                      id: touchfield_4
                      state: ON

binary_sensor:

  • platform: template name: "Touchfield 1" id: touchfield_1 on_press:

    • if: condition: lambda: "return ${toggle_relay_1_on_touch};" then:
      • switch.toggle: relay_1
    • delay: ${button_on_time}
    • binary_sensor.template.publish: id: touchfield_1 state: OFF
    • script.execute: refresh_led_default
  • platform: template name: "Touchfield 2" id: touchfield_2 on_press:

    • if: condition: lambda: "return ${toggle_relay_2_on_touch};" then:
      • switch.toggle: relay_2
    • delay: ${button_on_time}
    • binary_sensor.template.publish: id: touchfield_2 state: OFF
    • script.execute: refresh_led_default

    Similar updates for Touchfield 3 and 4...

Hope, that helps