Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
slarti123 opened this issue Oct 19, 2024 · 2 comments

Comments

@slarti123
Copy link

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:

  • Pressing Touchfield 1 should toggle Relay 1.
  • Each physical touch button should control its respective relay (Touchfield 1 for Relay 1, Touchfield 2 for Relay 2, etc.).

What Happens:

  • Each button press only triggers the vibration motor, and none of the relays toggle.

Additional Information:

  • When I toggle the relays via the Home Assistant GUI, they work as expected.
  • I have tried modifying the YAML to explicitly map the touch positions to the relays using binary_sensor definitions, but the relays are still not toggling when the touch fields are pressed.

Request:

  • Could you provide guidance on how to correctly map the touch fields to the relays?
  • Is there a way to prevent the vibration motor from triggering with each touch and prioritize the relay toggling instead?

Thank you in advance for your help!

@slarti123
Copy link
Author

slarti123 commented Oct 19, 2024

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:

  • Touch Relay Configuration: Updated the toggle_relay_*_on_touch substitutions to ensure that the correct relays are toggled when the buttons are pressed.

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

  • Touch Field Handler: The handle_release script was modified to correctly map touch positions to their respective relays.
- 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
  • Touchfield Definitions: Ensured that the binary sensors for each touch field are correctly defined to toggle the relays.

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

@Elkropac
Copy link

Elkropac commented Nov 5, 2024

Hi, i have done some changes regarding 4 relays support in PR #55 , could test it out please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants