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

This is a blueprint for the Tuya 4-button Scene Switch (Last Updated 12/01/25)

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:
Zigbee2MQTT - Tuya 4-Button Switch (MQTT Device Trigger)
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.
Blueprint moved to github.
The blueprint filename has changed if you used a privious version of this blueprint see here how to avoid having to rewrite your automation manually after switching the blueprint.

Alternate Blueprint
Zigbee2MQTT - Tuya 4-Button Switch (MQTT Subscribe Any - Filters Multiple Devices)
Here is an alternate blueprint if you want to automate multiple devices (of the same type) in with the same actions maintaining a single automation.
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.
If the buttons are mostly doing the same thing but you want to introuduce minor variation you could do something like this.

Change Log:
11/01/2025

  1. New blueprint created using MQTT device triggers to avoid triggering unnecessarily the atuomation when any action is fired by mqtt devices.
  2. Added an alternate blueprint that handle multiple buttons allowing control of many buttons within the same automation. (Using the method where the automation triggers for any mqtt device action)

05/01/2025

  1. Changed blueprint to use MQTT Topic Triggers instead of the HA sensor entity which no longer exist. (Please reselect the Device Entity in your Automations after updating the blueprint)
  2. Corrected the orientation description of button 1 - 4 since it wasn’t correct to start with.

30/12/2023

  1. added dropdown to choose Automation Mode type (default is “parallel”), see Automation modes - Home Assistant
6 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!

After Zigbee2MQTT update to version 2.0.0 there are breaking changes regarding *_action entities.

All action sensors are now disabled by default (sensor.*_action entities). It’s recommended to use the MQTT device trigger instead.

https://github.com/Koenkk/zigbee2mqtt/discussions/24198

Are there any plans to update this blueprint to make it work again ?

Yes I’ve already changed a similar blueprint here to use MQQT topic triggers instead of devices sensors, which no longer exist. I’ll fix this in a few hours.

1 Like

Blueprint Updated.

Reimport and overwrite the blueprint from the top of the page or just press the below:
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

You’ll need to edit your automations and select your zigbee device instead of the previous device sensor entity.

3 Likes

Here is a version which does not rely on receiving MQTT messages directly but instead uses the new event triggers. The thing I dislike about the current version with MQTT messages is that the automation triggers on ANY ‘action’ message and only afterwards filters it via a condition.
The changes to the 2024 version of this blueprint are minimal:

For the switch input I set

          domain:
            - event

and for the command variable

  - variables:
      command: >
        {% if trigger.to_state.attributes.button is defined %}
        {{ trigger.to_state.attributes.button }}_{{trigger.to_state.attributes.event_type }}
        {% else %}
        {{ trigger.to_state.attributes.event_type }}
        {% endif %}

This is a bit more complicated than necessary because currently the event reporting from Z2M is inconsistent. Short and double presses are reported as event_type: 1_single while for long presses the payload is split into parts:

event_type: hold
button: '1'

I did not copy the button descriptions from the 2025 version, because they are wrong for my devices. Perhaps there are two versions with different button layouts.

blueprint:
  name: Zigbee2MQTT - Tuya 4-Button Scene Switch (rdeangel_mod, events)
  description: Automate your Tuya 4-Button Scene Switch via Zigbee2MQTT. This requires Settings -> Home Assistant integration -> Home Assistant experimental event entities to be enabled in Zigbee2MQTT.
  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:
            - event
          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: >
        {% if trigger.to_state.attributes.button is defined %}
        {{ trigger.to_state.attributes.button }}_{{trigger.to_state.attributes.event_type }}
        {% else %}
        {{ trigger.to_state.attributes.event_type }}
        {% endif %}
  - 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

Thank you, my automations based on this blueprint are now working again with the zigbee update

I did have to manually delete the old switch from the automation yaml to stop it coming up in my watchman report

@rdeangel : thanks for the update, it works again :+1:

Totally right, I was hesitant posting it to start with for this very same reason, but I thought let me get something out there for now.
I had to right my wrong so I’m posting a new one which follows the official way of doing things and it’s pretty much what Panopilian posted in the original post.

Zigbee2MQTT - Tuya 4-Button Switch (MQTT Device Trigger) - rdeangel
SROLL UP :point_up: TO IMPORT BLUEPRINT
I suggest anyone using my last automation to use this one instead
This one uses the MQTT device trigger instead and will only trigger for manually defined device mqtt actions, which is much better.
What I dislike about this one is the manual definition of all the triggers (very long) but there is no way around that (from what I can tell) as the triggers are loaded when the blueprints loads (not when the automation loads) so they need to be manually defined within the blueprint (at least for now).

What I still couldn’t resolve, is to efficiently allow for multiple devices of the same type to be controlled by a single automation.
For this purpose I’m reposting the same automation I originally posted before with multiple inputs (which again has the issue of getting triggered with any mqtt device actions). You can use it if you don’t mind the trigger happy behaviour.
PLEASE DON’T USE THIS ONE IF YOU JUST NEED THE AUTOMATION TO BE TRIGGERED BY A SINGLE DEVICE, USE THE ONE ABOVE:
Zigbee2MQTT - Tuya 4-Button Switch (MQTT Subscribe Any - Filters Multiple Devices)
SROLL UP :point_up:TO IMPORT BLUEPRINT

I’ll also update the links at the top of the post in a minute.

FYI, these new blueprints have a different filename, but instead of redifining your automations manually (which get wiped when you switch the blueprint in your automation) you can just import the blueprint, then go to your automation, click edit yaml at the top right and change:

use_blueprint:
  path: rdeangel/zigbee2mqtt-tuya-4-button-scene-switch-ts0044-rdeangel-mod.yaml

to

use_blueprint:
  path: rdeangel/zigbee2mqtt-tuya-4-button-switch-mqtt-device-trigger_rdeangel.yaml

and save.

1 Like

Thank you, thank you,
I was struggling the whole day already with this. You made my day.
I used it for a TS0042 - 2 button Tuya swirch

1 Like

Just to be sure before i Update Z2M to → 2.0.0

I now have 1.42.0-2 working and happy with your Blueprint! :white_heart:

I have 6 buttons all the same device “TS0044 / TS0044_1” which all use the same blueprint.

Can’t really seem to figure out which blueprint to use? :frowning:

“PLEASE DON’T USE THIS ONE IF YOU JUST NEED THE AUTOMATION TO BE TRIGGERED BY A SINGLE DEVICE, USE THE ONE ABOVE:”

Is this if I have one device which controls more than one device in an action?