Zigbee2MQTT - Tuya 4-button Scene Switch (TS0044)

Turns out a complicated blueprint is not the answer. A simple automation is working just perfectly.

alias: Remote
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.remote_action
    to: 1_single
    id: 1s
  - platform: state
    entity_id:
      - sensor.remote_action
    to: 2_single
    id: 2s
  - platform: state
    entity_id:
      - sensor.remote_action
    to: 3_single
    id: 3s
  - platform: state
    entity_id:
      - sensor.remote_action
    to: 4_single
    id: 4s
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - 1s
        sequence:
          - action: light.toggle
            target:
              entity_id: light.room_light
            data: {}
      - conditions:
          - condition: trigger
            id:
              - 2s
        sequence:
          - action: light.toggle
            data: {}
            target:
              entity_id: light.bird_light
      - conditions:
          - condition: trigger
            id:
              - 3s
        sequence:
          - action: light.toggle
            data: {}
            target:
              entity_id: light.fish_light
      - conditions:
          - condition: trigger
            id:
              - 4s
        sequence:
          - action: fan.toggle
            data: {}
            target:
              entity_id: fan.roomfan
mode: single

1 Like

I will start by saying that I am fairly new to HA but coming along. I purchased a 4 button scene switch and have it connected and appears operational as per the logbook entries. My confusion is in triggering the automations as none of the blueprints or @Wheemer script is working for me. I am fairly certain that it is related to a simple missing link but I am not sure what I should be looking for. I appreciate any help.

Thank you, this one worked for me.

Moes ZigBee Wireless 12
model: TS0044
manufacturer: _TZ3000_wkai4ga5

Allthough there is a typo on line 71. lower-right should be upper-right. :stuck_out_tongue_winking_eye:

1 Like

Thank you. You just saved me few days work.
Working like a charm.

1 Like

Do you know if it is possible to have the light of the button stays on if an automation is for instance activated via that button and then the led button light is off if the automation si turned off? Or there is no way to control the LED of each single button?

Hello !
The Blue Print assume the button was add by Zigbee Mqtt, but my button was implemented like normal sensor in Configuration Yaml

  sensor:
  - name: Office_ZB_Switch_Wall
    unique_id: SwitchZB01  
    state_topic: "tele/tasmota_C044DC/SENSOR"
    value_template: "{{ value_json['ZbReceived']['0x7E35'] }}"
    availability_topic: "tele/tasmota_C044DC/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"
    qos: 0

and it return nice value as ststus::

    to_state:
      entity_id: sensor.office_zb_switch_wall
      state: >-
        {'Device': '0x7E35', '0006!FD': '00', 'LidlPower': 0, 'Endpoint': 4,
        'LinkQuality': 76}
      attributes:
        friendly_name: Office_ZB_Switch_Wall
      last_changed: "2024-10-04T12:24:06.234365+00:00"
      last_reported: "2024-10-04T12:24:06.234365+00:00"
      last_updated: "2024-10-04T12:24:06.234365+00:00"

This value

    command01: "{{ trigger.to_state.state }}"

geting the value : {‘Device’: ‘0x7E35’, ‘0006!FD’: ‘00’, ‘LidlPower’: 0, ‘Endpoint’: 4,
‘LinkQuality’: 76}

and all ok, but how to cut it in to 2 variablbes like:

command = "{{ trigger.to_state.state }}" get "LidlPower" value form json
swnumber = "{{ trigger.to_state.state }}" get "endpoint" value form json 

then modification of the rest will be easy
Szymon

Can confirm that removing the attribute: action line from the blueprint fixes the error
Error: UndefinedError: ‘dict object’ has no attribute ‘to_state’

I made two of my own blueprints for this device.

The two blueprints are for the same device, but with different functionality. The first blueprint provides a single layer of 4 buttons, each with a short press, double press, and long press event. The second blueprint provides 4 layers of 4 buttons, each with a short press and double press event, where the layer is selected by long pressing the respective button.

Single layer 4-button switch

This blueprint provides support as a standard single-layered 4-button switch. Each button has a short press, double press, and long press event. This provides up to 12 events per switch (short press, double press, long press for each of the 4 buttons).

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

Quad layer 4-button switch

This blueprint provides support as a 4-layered 4-button switch. Each button has a short press and a double press event. The switch has 4 layers, and the layer is selected by long pressing the respective button. Top-left is button 1, therefore layer 1; and so on. This provides up to 8 events per layer (short press and double press for each button) on 4 layers, resulting in 32 total events.

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

Hello,
Thanks for the blueprint.
When I an trying to use it under

Input Device
Select the Moes/Tuya 4-Button Scene Switch device

No devices re displayed, is there something I have to do before ?

Many thanx !!!

It works perfectly with my MOES remote control (runing on battery)

Thanks for sharing !

Cheers

1 Like

This blueprint stopped working after some breaking changes in Zigbee2MQTT 2.0.0 Zigbee2MQTT 2.0.0 breaking changes · Koenkk/zigbee2mqtt · Discussion #24198 · GitHub

Would be nice if there is a workaround.

3 Likes

Second vote for a fix for this blueprint post Z2MQTT 2.0.0 Change

try to add till the fix

legacy_action_sensor: true to your configuration.yaml file under homeassistant

the path is /homeassistant/zigbee2mqtt/configuration.yaml

homeassistant:
legacy_action_sensor: true

Not working for this Blueprint, the other Switches works now.

Yes, that did the trick. Don’t forget to restart the Zigbee2MQTT addon. Thank you.

Had the same, but needed to select the entity again in the automation and save it. My entity is called: “sensor.bar_switch_4_button_action”.

It’s the entity “Action” above “Battery”

Correct because after the update this entity was deleted.

I have move some of my switches to MQTT like this and it works. No need for blueprint any more

1 Like

Please explain! zigbee2mqtt/Vierfachschalter/action works but at all 4 switches, which is the command für single klick button 1?
zigbee2mqtt/Vierfachschalter/action/1_single dosn’t work.

I made a new blueprint, avoiding the legacy action entity and implementing the MQTT device trigger.

It takes the Device ID. In my case, I have the 4 button switch. So, adjust to 1,2, or 3 according to your device.

blueprint:
  name: Zigbee2MQTT 2.0 - Tuya 4-Button Scene Switch
  description: Automate your Tuya 4-Button Scene Switch via Zigbee2MQTT.
  domain: automation
  input:
    switch:
      name: Tuya 4-Button Scene Switch
      description: Select the Tuya 4-Button Scene Switch to use
      selector:
        device:
          integration: mqtt

    # Button 1 Actions
    button_one_short_press:
      name: Single Press - Button 1 (Lower-Left)
      description: Action to run on button 1 single press
      default: []
      selector:
        action: {}
    button_one_double_press:
      name: Double Press - Button 1 (Lower-Left)
      description: Action to run on button 1 double press
      default: []
      selector:
        action: {}
    button_one_long_press:
      name: Long Press - Button 1 (Lower-Left)
      description: Action to run on button 1 long press
      default: []
      selector:
        action: {}

    # Button 2 Actions
    button_two_short_press:
      name: Single Press - Button 2 (Lower-Right)
      description: Action to run on button 2 single press
      default: []
      selector:
        action: {}
    button_two_double_press:
      name: Double Press - Button 2 (Lower-Right)
      description: Action to run on button 2 double press
      default: []
      selector:
        action: {}
    button_two_long_press:
      name: Long Press - Button 2 (Lower-Right)
      description: Action to run on button 2 long press
      default: []
      selector:
        action: {}

    # Button 3 Actions
    button_three_short_press:
      name: Single Press - Button 3 (Upper-Right)
      description: Action to run on button 3 single press
      default: []
      selector:
        action: {}
    button_three_double_press:
      name: Double Press - Button 3 (Upper-Right)
      description: Action to run on button 3 double press
      default: []
      selector:
        action: {}
    button_three_long_press:
      name: Long Press - Button 3 (Upper-Right)
      description: Action to run on button 3 long press
      default: []
      selector:
        action: {}

    # Button 4 Actions
    button_four_short_press:
      name: Single Press - Button 4 (Upper-Left)
      description: Action to run on button 4 single press
      default: []
      selector:
        action: {}
    button_four_double_press:
      name: Double Press - Button 4 (Upper-Left)
      description: Action to run on button 4 double press
      default: []
      selector:
        action: {}
    button_four_long_press:
      name: Long Press - Button 4 (Upper-Left)
      description: Action to run on button 4 long press
      default: []
      selector:
        action: {}

trigger:
  # Button 1 Triggers
  - platform: device
    device_id: !input switch
    domain: mqtt
    type: action
    subtype: 1_single
  - platform: device
    device_id: !input switch
    domain: mqtt
    type: action
    subtype: 1_double
  - platform: device
    device_id: !input switch
    domain: mqtt
    type: action
    subtype: 1_hold

  # Button 2 Triggers
  - platform: device
    device_id: !input switch
    domain: mqtt
    type: action
    subtype: 2_single
  - platform: device
    device_id: !input switch
    domain: mqtt
    type: action
    subtype: 2_double
  - platform: device
    device_id: !input switch
    domain: mqtt
    type: action
    subtype: 2_hold

  # Button 3 Triggers
  - platform: device
    device_id: !input switch
    domain: mqtt
    type: action
    subtype: 3_single
  - platform: device
    device_id: !input switch
    domain: mqtt
    type: action
    subtype: 3_double
  - platform: device
    device_id: !input switch
    domain: mqtt
    type: action
    subtype: 3_hold

  # Button 4 Triggers
  - platform: device
    device_id: !input switch
    domain: mqtt
    type: action
    subtype: 4_single
  - platform: device
    device_id: !input switch
    domain: mqtt
    type: action
    subtype: 4_double
  - platform: device
    device_id: !input switch
    domain: mqtt
    type: action
    subtype: 4_hold

action:
  - variables:
      command: '{{ trigger.payload }}'
  - 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

mode: single
max_exceeded: silent
5 Likes

Thank you fixed it for me too