Zigbee2MQTT - Tuya 4-button Scene Switch (TS004F)

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

For now, in order to have TS004F connected successfully with your ZigBee network, you need to own the original Tuya ZigBee Gateway, just initially.

1. Pair with Tuya Gateway with the original app (I use Smart Life), hold lower left button until all lights flash
2. After connecting in Smart Life, choose scene switcher when asked, not dimmer (not sure if that matters, it’s the choice I made)
3. Allow new devices in Zigbee2MQTT
4. Remove device in the app (Delete and wipe)

Device should immidiately interview successfully with Z2M. You will know if it was successful if the battery level is reported correctly, push some buttons to refresh the data. If your device doesn’t report battery level, then it didn’t interview correctly and I have no more hints for you, try again.

EDIT: You might actually have to hold the lower left button until the device goes into pairing mode as the last step, it might not actually connect with Z2M on its own. I am afraid to test it all again, you have to try it yourself. The device NAS-AB02B0 needs exactly the same procedure to work with Z2M correctly and it doesn’t need to be forced into pairing mode in the end, this one may have to.

Then and ONLY THEN will this blueprint work. Unfortunately as it stands right now, I was unable to get any double click or button hold actions, only single clicks. This tremendously sucks, but at least you get 4 actions that actually work.

Code below is based entirely off of Stringer’s blueprint, all credit goes to him.

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

blueprint:
  name: Zigbee2MQTT - Tuya 4-Button Scene Switch TS004F
  description: Automate your Tuya 4-Button 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_short_press:
      name: Single Press - Button 1
      description: Action to run on button 1 (lower-left) single 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_three_short_press:
      name: Single Press - Button 3
      description: Action to run on button 3 (upper-right) single 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: {}
mode: restart
max_exceeded: silent
trigger:
- platform: state
  entity_id: !input 'switch'
  attribute: action
action:
- variables:
    command: '{{ trigger.to_state.state }}'
- choose:
  - conditions:
    - '{{ command == ''off'' }}'
    sequence: !input 'button_one_short_press'
  - conditions:
    - '{{ command == ''brightness_step_down'' }}'
    sequence: !input 'button_two_short_press'
  - conditions:
    - '{{ command == ''brightness_step_up'' }}'
    sequence: !input 'button_three_short_press'
  - conditions:
    - '{{ command == ''on'' }}'
    sequence: !input 'button_four_short_press'
1 Like

Hey, thanks for this! Works like a charm, and without a tuya hub :v:

Are you working on the long and douple presses?

This seems to be the only blueprint to work for me for some reason, so hoping you are.

1 Like

FWIW, the rigamarole with the original Tuya hub is not needed anymore with the latest Z2M versions.

No I’m not working on more functionality @Unitardia, as you might have realized :wink: