Tuya TS004F: 4 Button Wireless Switch - Zigbee2MQTT (2023)

Fixed. Please check.

1 Like

I’m getting an unknown error when trying to import the blueprint.

Using the original blueprint for the time being.

Tried to import the blueprint and got “unknown error” message from the HA ui.

Dug through the logs and found the following:

raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url=URL('https://api.github.com/gists/5f19317ea530687a768ed2c34218cbc4')

Hence copied the blueprint to a github gist and tried to import again. It worked. The url to the gist is ts004F.yaml · GitHub .

happy automating :slight_smile:

Guys, Not working. Please help!
What does this error means? How to resolve it? @Sagar @Tzitzian

Error: In template condition undefined error: list object has no element 1

What does this error means? How to resolve it?

I think the newest zigbee2mqtt update broke it. Watchtower updated it overnight, and when I woke up the automation was already broken…

Looks like the name split messes up the condition. I made a script from scratch where I’m simply ignoring that and it works pretty well. The template in the current state is broken, leaving this note FYI in case someone else finds this and is frustrated because it doesn’t work.

Hi, I found this blueprint did not working using later versions of Zigbee2MQTT. I updated the blueprint in the following ways and now it works for me:

  • Use Zigbee2MQTT device name to listen for MQTT topic
  • Fixed misnamed buttons
  • removed held buttons
blueprint:
  name: Tuya 4-Button Scene Switch (TS004) [Z2M]
  description: Tuya 4-Button Scene Switch via Zigbee2MQTT
  domain: automation
  #Input declarations
  input:
    controller:
      name: Zigbee2MQTT Controller Name
      description: Exact name as shown in Zigbee2MQTT (beware trailing space)
      default: ''
    base_topic:
      name: (Zigbee2MQTT) Base mqtt topic
      description: The base topic as configured in z2m (keep unless Z2M non-default configuation)
      default: zigbee2mqtt
    #Button 1
    button_one_short_press:
      name: Single Press - Button 1
      description: Action to run on button 1 (upper-left) single press
      default: []
      selector:
        action: {}
    button_one_double_press:
      name: Double Press - Button 1
      description: Action to run on button 1 (upper-left) double press
      default: []
      selector:
        action: {}
    button_one_long_press:
      name: Long Press - Button 1
      description: Action to run on button 1 (upper-left) long press
      default: []
      selector:
        action: {}
    #Button 2
    button_two_short_press:
      name: Single Press - Button 2
      description: Action to run on button 2 (upper-right) single press
      default: []
      selector:
        action: {}
    button_two_double_press:
      name: Double Press - Button 2
      description: Action to run on button 2 (upper-right) double press
      default: []
      selector:
        action: {}
    button_two_long_press:
      name: Long Press - Button 2
      description: Action to run on button 2 (upper-right) long press
      default: []
      selector:
        action: {}
    #Button 3
    button_three_short_press:
      name: Single Press - Button 3
      description: Action to run on button 3 (lower-left) single press
      default: []
      selector:
        action: {}
    button_three_double_press:
      name: Double Press - Button 3
      description: Action to run on button 3 (lower-left) double press
      default: []
      selector:
        action: {}
    button_three_long_press:
      name: Long Press - Button 3
      description: Action to run on button 3 (lower-left) long press
      default: []
      selector:
        action: {}
    button_four_short_press:
      name: Single Press - Button 4
      description: Action to run on button 4 (lower-right) single press
      default: []
      selector:
        action: {}
    button_four_double_press:
      name: Double Press - Button 4
      description: Action to run on button 4 (lower-right) double press
      default: []
      selector:
        action: {}
    button_four_long_press:
      name: Long Press - Button 4
      description: Action to run on button 4 (lower-right) long press
      default: []
      selector:
        action: {}
  
mode: parallel
max_exceeded: silent
trigger_variables:
  base_topic: !input base_topic
  controller: !input controller
trigger:
- platform: mqtt
  topic: '{{ base_topic ~ ''/'' ~ controller }}'
action:
- variables:
    command: '{{ trigger.payload_json.action }}'
- 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
2 Likes

Mate,

here is my debug log from Z2M for Tuya 4 gang switch.

 2023-07-12 18:37:27Received Zigbee message from 'Przycisk4', type 'commandOn', cluster 'genOnOff', data '{}' from endpoint 1 with groupID 0
Debug 2023-07-12 18:37:27No converter available for 'TS004F' with cluster 'genOnOff' and type 'commandOn' and data '{}'
Debug 2023-07-12 18:37:31Received Zigbee message from 'Przycisk4', type 'commandStep', cluster 'genLevelCtrl', data '{"stepmode":0,"stepsize":51,"transtime":10}' from endpoint 1 with groupID 0
Debug 2023-07-12 18:37:31No converter available for 'TS004F' with cluster 'genLevelCtrl' and type 'commandStep' and data '{"stepmode":0,"stepsize":51,"transtime":10}'
Debug 2023-07-12 18:37:35Received Zigbee message from 'Przycisk4', type 'commandOff', cluster 'genOnOff', data '{}' from endpoint 1 with groupID 0
Debug 2023-07-12 18:37:35No converter available for 'TS004F' with cluster 'genOnOff' and type 'commandOff' and data '{}'
Debug 2023-07-12 18:37:41Received Zigbee message from 'Przycisk4', type 'commandStep', cluster 'genLevelCtrl', data '{"stepmode":1,"stepsize":51,"transtime":10}' from endpoint 1 with groupID 0
Debug 2023-07-12 18:37:41No converter available for 'TS004F' with cluster 'genLevelCtrl' and type 'commandStep' and data '{"stepmode":1,"stepsize":51,"transtime":10}'

I have no entities discovered. When I should add them (in Z2M section or in Blueprint)?

Cant add it in blueprint? Unknown error.

1 Like

hey @Tzitzian this suddenly stopped working after updating to 2023.9.0

are you seeing similar behaviour?

Edit: appears to be latest zigbee2mqtt that’s broken the blueprint.

1 Like

same problem here, it suddenly stopped working after upgrade to 2023.9.2,

check which version of zigbee2mqtt you have. Restoring 1.32.2 got this working again.

Looks like it’s because of the friendly names getting renamed. You can get this blueprint to work again by manually changing the friendly name of your remote’s action sensor back to “Device Name action” (action must be lower case and device name must be added, the new version defaults to just “Action”).

2 Likes

does not work for me

this works well for me, thank you!

Sometimes button presses where not performed by the blueprint. I changed the mode from restart tot parallel and it works much better now

Wow, thanks that does work much better. I will update the other post.

Hi Sagar, I get an error when trying to import the blueprint, is it removed?

Hi there,

I have read the entire conversation history, but I haven’t found a solution to my problem. I have already replaced the blueprint as well. Z2M receives signals, but I cannot control any automation with it, or the automation is not triggered at all. Can someone help me?

Info 2023-11-17 09:09:14MQTT publish: topic 'zigbee2mqtt/WM Bett', payload '{"action":"1_single","battery":96,"linkquality":69,"operation_mode":"event","voltage":2900}'
Info 2023-11-17 09:09:14MQTT publish: topic 'zigbee2mqtt/WM Bett', payload '{"action":"","battery":96,"linkquality":69,"operation_mode":"event","voltage":2900}'
Info 2023-11-17 09:09:14MQTT publish: topic 'zigbee2mqtt/WM Bett/action', payload '1_single'

Greets
Maryjam