Help adding a variation of Tuya TS0044, TS004F to ZHA

I had the opportunity to sell my switch without losses and since I need a working 12 way switch anyways I sold it.

I’ll try to answer your questions anyways.

Without any custom quirks, there was one switch which was switched by the top-left and bottom-left buttons.

With the latest custom quirk this also worked.

At last I have tried the switch with a zigbee2mqtt setup. There I got an action entity with 6 options like in your screenshot. I have not seen this with the zha integration, but I might have missed it. But also with zigbee2mqtt there were only 6 actions.

Hello

I have added custom path for custom quirks .

zha:
  custom_quirks_path: /config/custom_zha_quirks/

After that I have created a file in side custom_zha_quirks folder named ts004f.py

But after the HA restart Zigbee integration will not load.

Here is the log

Logger: homeassistant.config_entries
Source: custom_zha_quirks/ts004f.py:63
First occurred: 4:10:01 PM (1 occurrences)
Last logged: 4:10:01 PM

Error setting up entry socket://192.168.0.105:8888 for zha
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 293, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 99, in async_setup_entry
    setup_quirks(config)
  File "/usr/local/lib/python3.8/site-packages/zhaquirks/__init__.py", line 403, in setup
    importer.find_module(modname).load_module(modname)
  File "<frozen importlib._bootstrap_external>", line 462, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 962, in load_module
  File "<frozen importlib._bootstrap_external>", line 787, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 702, in _load
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_zha_quirks/ts004f.py", line 33, in <module>
    class Tuya4NewButtonTriggers:
  File "/config/custom_zha_quirks/ts004f.py", line 63, in Tuya4NewButtonTriggers
    (LONG_RELEASE, BUTTON_4): {COMMAND: COMMAND_STOP, ENDPOINT_ID: 1},
NameError: name 'LONG_RELEASE' is not defined

I’ve updated the post.
I also created a gist: TS004F custom quirk · GitHub

@koying Thanks for the quick response

I got the HA to load the custom quirk by installing the custom deps addon , after that added the ts004f.py in /usr/local/lib/python3.9/site-packages/zhaquirks/tuya reloaded the pycache

2021-07-17 15:14:58 DEBUG (MainThread) [zigpy.quirks.registry] Checking quirks for _TZ3000_xabckq1v TS004F (60:a4:23:ff:fe:95:22:d7)
2021-07-17 15:14:58 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.tuya.ts004f.TuyaSmartRemote004F'>
2021-07-17 15:14:58 DEBUG (MainThread) [zigpy.quirks.registry] Found custom device replacement for 60:a4:23:ff:fe:95:22:d7: <class 'zhaquirks.tuya.ts004f.TuyaSmartRemote004F'>

it also showing up in device page now

but zha_event still not able to see any event by any button press.

A dedicated PR has been created for those willing to help getting this right

3 Likes

To pull all the information together and make sure there is something for new users to directly follow, I’ve added the post:

To this thread.

Thanks all or the help
Too bad all the functions advertised are not available, damn tuya…

Hi Chris and others with a TS004F,

I have 4 of the Tuya 4 button switch TS004F. They come from a vendor claiming they were model TS0044 (12 scene switch), however they were TS004F and behave the same as I can read on all the posts here.
I called the vendor, and they tell me the TS004F is a 12 scene switch if it is configured to be. This is done using the Tuya gateway and their app. On first discovery of the device, the app will ask asked about the “mode”, and set it on the switch. I have looked into this and it seem correct. Even mentioned on the description-paper slips.
I have looked around and this problem is well known on different platforms, and the solution seems quite straight forward.
On initial setup the switch need to be configured, by setting a switch to “1”. Like in this example from another platform
cmd += zigbee.writeAttribute(0x0006, 0x8004, 0x30, 0x01, dummy, delay=50)
Look in this link: https://raw.githubusercontent.com/kkossev/Hubitat/main/Drivers/Tuya%20TS004F/TS004F.groovy
where the 0x01 initiates a “12 buttom switch mode”

It is also mentioned on this link TS004F (instead of TS0044) buttons has only single tap · Discussion #7158 · Koenkk/zigbee2mqtt · GitHub. Search for “Enum8 = 1” and you will find the right article.

I do not have any clue how to use this information. How to send the “mode setting” to the switch during setup.

Anyone knows?

If someone needs a switch for testing, I will send you one. Your welcome to keep it if successful). I will be happy to help testing also.

3 Likes

I too thought I was getting a TS0044 but turned out to be a TS004F. So, I’m trying to get it to work with ZHA. In my research today, I see that the Zigbee2MQTT folks made some progress just today on it. As @khvej8 mentioned above, there’s a way to switch it to the 12 scene switch mode. I’m too new to any of this to know how that could be done in the quirks. Or if it even can. Maybe someone more knowledgeable could take a look her and see if it makes sense to them?

Found more info on how to change the switch mode.

image

https://www.zigbee2mqtt.io/devices/TS004F.html#device-modes

5 Likes

Can anyone confirm this is working?

1 Like

EL_Duderino, I can not make it work using ZHA. It shows up as a the dimmer version, not the 12scene.

Holding button 2+4 will make button 3 flash 3 times, as described. However adding the button to ZHA afterwards will ends with the dimmer version.

I’m using ZHA and not Z2M. When I put the switch in switch mode 2 by holding buttons 2+4, light 3 flashes once as described. After this I no longer receive any ZHA events at all. The same procedure puts the switch back into mode 1

1 Like

Agree, after holding button 2+4 the events will stop. I beleive it is because it changes to a “new device”. I tried to add it to ZHA again, it adds as a dimmer version. Can not make it add as a 12 scene button.

Yup, can confirm it. device doesn’t work in ZHA as the 12 scene button. ZHA quirk needs to be updated I guess. Z2M works with both device modes.

My device for some reason, now have this entity button.tz3000_xabckq1v_ts004f_5194fcfe_identify and it’s the only one that have an action. There is a PRESS text next to it so I can make a automation based on it, but only by the UI. No button works at all on the physical switch, no zha_event, not even repairing, pressing 2+4 buttons, etc. Should I return this device or it might work one day?

Should I return this device or it might work one day?

It sounds like it is technically possible to get these devices working, so maybe in another 6 months they will work without a ton of hacking. I’m probably going to return mine, and maybe re-order one later in the year if there is better support.

So, after reading through all the posts it seems that there is no easy way of getting the TS004F working with ZHA. Zigbee2MQTT seems to be the better solution, but can we run ZHA and Zigbee2MQTT together using one dongle. I don’t feel like adding all my ZHA devices to Zigbee2MQTT now.

Unfortunately not on one dongle. You can have 2 dongles (coordinators), one for ZHA and one for Zigbee2mqtt. They run fine on the same box/server.

2 Likes

So, it’s impossible to add to zha, considering migrate to z2m

What a pity, zha was so easy…