TS004F - Blueprint for Z2M version >= 1.22.1 (All buttons single/double/hold) - 12 actions

Feel free to test and use it :slight_smile:

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

blueprint:
  name: Zigbee2MQTT - TS004F
  description: Scene Switch TS004F via Zigbee2MQTT.
  domain: automation
  input:
    switch:
      name: Tuya 4-Button Scene Switch TS004F
      description: Tuya 4-Button Scene Switch to use
      selector:
        entity:
          integration: mqtt
          domain: sensor
    button_one_single:
      name: Single Press - Button 1
      description: Action to run on button 1 (top-left) single press
      default: []
      selector:
        action: {}
    button_two_single:
      name: Single Press - Button 2
      description: Action to run on button 2 (top-right) single press
      default: []
      selector:
        action: {}
    button_three_single:
      name: Single Press - Button 3
      description: Action to run on button 3 (bottom-left) single press
      default: []
      selector:
        action: {}
    button_four_single:
      name: Single Press - Button 4
      description: Action to run on button 4 (bottom-left) single press
      default: []
      selector:
        action: {}
    button_one_double:
      name: Double Press - Button 1
      description: Action to run on button 1 (top-left) double press
      default: []
      selector:
        action: {}
    button_two_double:
      name: Double Press - Button 2
      description: Action to run on button 2 (top-right) double press
      default: []
      selector:
        action: {}
    button_three_double:
      name: Double Press - Button 3
      description: Action to run on button 3 (bottom-left) double press
      default: []
      selector:
        action: {}
    button_four_double:
      name: Double Press - Button 4
      description: Action to run on button 4 (bottom-right) double press
      default: []
      selector:
        action: {}        
    button_one_hold:
      name: Hold Press - Button 1
      description: Action to run on button 1 (top-left) hold press
      default: []
      selector:
        action: {}
    button_two_hold:
      name: Hold Press - Button 2
      description: Action to run on button 2 (top-right) hold press
      default: []
      selector:
        action: {}
    button_three_hold:
      name: Hold Press - Button 3
      description: Action to run on button 3 (bottom-left) hold press
      default: []
      selector:
        action: {}
    button_four_hold:
      name: Hold Press - Button 4
      description: Action to run on button 4 (bottom-right) hold press
      default: []
      selector:
        action: {}              
mode: queued
max_exceeded: silent
trigger:
- platform: state
  entity_id: !input 'switch'
  attribute: action
action:
- variables:
    command: '{{ trigger.to_state.state }}'
- choose:
  - conditions:
    - '{{ command == ''1_single'' }}'
    sequence: !input 'button_one_single'
  - conditions:
    - '{{ command == ''2_single'' }}'
    sequence: !input 'button_two_single'
  - conditions:
    - '{{ command == ''3_single'' }}'
    sequence: !input 'button_three_single'
  - conditions:
    - '{{ command == ''4_single'' }}'
    sequence: !input 'button_four_single'
  - conditions:
    - '{{ command == ''1_double'' }}'
    sequence: !input 'button_one_double'
  - conditions:
    - '{{ command == ''2_double'' }}'
    sequence: !input 'button_two_double'
  - conditions:
    - '{{ command == ''3_double'' }}'
    sequence: !input 'button_three_double'
  - conditions:
    - '{{ command == ''4_double'' }}'
    sequence: !input 'button_four_double'    
  - conditions:
    - '{{ command == ''1_hold'' }}'
    sequence: !input 'button_one_hold'
  - conditions:
    - '{{ command == ''2_hold'' }}'
    sequence: !input 'button_two_hold'
  - conditions:
    - '{{ command == ''3_hold'' }}'
    sequence: !input 'button_three_hold'
  - conditions:
    - '{{ command == ''4_hold'' }}'
    sequence: !input 'button_four_hold'          
2 Likes

Works for me :+1: :grinning:

For anyone running into problems:

  1. Make sure your TS004F is set to Switch mode instead of the default Dimmer mode. Information about these modes has recently been added to the device page.

  2. The double click is a quick double click. Take a fraction of a second too long and it will register as a normal click twice in a row.

  3. The hold press is a long hold press. Anything shorter than 3 seconds seems to be registered as a normal single press.

1 Like

Oh my god!!! this really works.!!!
thank you so much!!!

So heads up this stopped working for me and was causing the action specified to happen twice in rapid succession. I ended up switching to this one which does not seem to have the same problem.

1 Like