Zigbee2MQTT - Tuya 4-button Scene Switch (TS0044) - rdeangel_mod

This is a blueprint for the Tuya 4-button Scene Switch

Supported actions for each button:

  1. Short press
  2. Double press
  3. Long press (5 seconds)

Get started

Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Or import this Blueprint using the forum topic URL:

blueprint:
  name: Zigbee2MQTT - Tuya 4-Button Scene Switch (rdeangel_mod)
  description: Automate your Tuya 4-Button Scene Switch via Zigbee2MQTT. (rdeangel_mod)
  domain: automation
  input:
    mode:
      name: Automation Modes
      description: https://www.home-assistant.io/docs/automation/modes/
      default: parallel
      selector:
        select:
          mode: dropdown
          options:
            - single
            - restart
            - queued
            - parallel
          multiple: false
          sort: false
          custom_value: false
    switch:
      name: Tuya 4-Button Scene Switch
      description: Tuya 4-Button Scene Switch to use
      selector:
        entity:
          integration: mqtt
          domain:
            - sensor
          multiple: false
    button_one_short_press:
      name: Single Press - Button 1
      description: Action to run on button 1 (lower-left) single press
      default: []
      selector:
        action: {}
    button_one_double_press:
      name: Double Press - Button 1
      description: Action to run on button 1 (lower-left) double press
      default: []
      selector:
        action: {}
    button_one_long_press:
      name: Long Press - Button 1
      description: Action to run on button 1 (lower-left) long press
      default: []
      selector:
        action: {}
    button_two_short_press:
      name: Single Press - Button 2
      description: Action to run on button 2 (lower-right) single press
      default: []
      selector:
        action: {}
    button_two_double_press:
      name: Double Press - Button 2
      description: Action to run on button 2 (lower-right) double press
      default: []
      selector:
        action: {}
    button_two_long_press:
      name: Long Press - Button 2
      description: Action to run on button 2 (lower-right) long press
      default: []
      selector:
        action: {}
    button_three_short_press:
      name: Single Press - Button 3
      description: Action to run on button 3 (upper-right) single press
      default: []
      selector:
        action: {}
    button_three_double_press:
      name: Double Press - Button 3
      description: Action to run on button 3 (upper-right) double press
      default: []
      selector:
        action: {}
    button_three_long_press:
      name: Long Press - Button 3
      description: Action to run on button 3 (upper-right) long press
      default: []
      selector:
        action: {}
    button_four_short_press:
      name: Single Press - Button 4
      description: Action to run on button 4 (upper-left) single press
      default: []
      selector:
        action: {}
    button_four_double_press:
      name: Double Press - Button 4
      description: Action to run on button 4 (upper-left) double press
      default: []
      selector:
        action: {}
    button_four_long_press:
      name: Long Press - Button 4
      description: Action to run on button 4 (upper-left) long press
      default: []
      selector:
        action: {}
  source_url: https://community.home-assistant.io/t/zigbee2mqtt-tuya-4-button-scene-switch-ts0044-rdeangel-mod/663302
mode: !input mode
max_exceeded: silent
trigger:
  - platform: state
    entity_id: !input switch
action:
  - variables:
      command: "{{ trigger.to_state.state }}"
  - choose:
      - conditions:
          - "{{ command == '1_single' }}"
        sequence: !input button_one_short_press
      - conditions:
          - "{{ command == '2_single' }}"
        sequence: !input button_two_short_press
      - conditions:
          - "{{ command == '3_single' }}"
        sequence: !input button_three_short_press
      - conditions:
          - "{{ command == '4_single' }}"
        sequence: !input button_four_short_press
      - conditions:
          - "{{ command == '1_double' }}"
        sequence: !input button_one_double_press
      - conditions:
          - "{{ command == '2_double' }}"
        sequence: !input button_two_double_press
      - conditions:
          - "{{ command == '3_double' }}"
        sequence: !input button_three_double_press
      - conditions:
          - "{{ command == '4_double' }}"
        sequence: !input button_four_double_press
      - conditions:
          - "{{ command == '1_hold' }}"
        sequence: !input button_one_long_press
      - conditions:
          - "{{ command == '2_hold' }}"
        sequence: !input button_two_long_press
      - conditions:
          - "{{ command == '3_hold' }}"
        sequence: !input button_three_long_press
      - conditions:
          - "{{ command == '4_hold' }}"
        sequence: !input button_four_long_press

Please note: This is not a new blueprint, it is just a fix to an existing one posted originally by @Stringer here. The fix I applied was brought up to my attention by @Daveee here in a similar blueprint.

Change Log:
30/12/2023

  1. added dropdown to choose Automation Mode type (default is “parallel”), see Automation modes - Home Assistant
5 Likes

This one fixed my long term hit and miss issues with the old blueprint. Many thanks!

1 Like

Works perfectly! Thank you :wink:

1 Like

I added this blueprint, and it says no matching entities found on the field to select the entity for the button.

The first blueprint you linked does work, but only for single presses. I’m not sure what is different here that would cause this.

1 Like

Which blueprint I linked works only for single presses?

I am seeing the same behavior. There is just nothing at all in the dropdown.

This blueprint will list any “sensor.” entities which are listed with this template:
{{ integration_entities(‘mqtt’) }}

image

If you don’t have any, it won’t list anything.

At least single presses seems to work for me - haven’t tested more. Nothing worked in the un-modded blueprint

Thanks a lot, found this just before I started to fork Stringers blueprint for a “mode: single”, but this is even better!