[RELEASE] Tuya Scene Switch TS004F driver

The recommended way to install the driver is Hubitat Package Manager (HPM). Search for "Tuya Scene Switch TS004F" or by tag "Zigbee".
Driver code is availabe in Github: https://raw.githubusercontent.com/kkossev/Hubitat/main/Drivers/Tuya%20TS004F/TS004F.groovy

Important: Due to the Tuya specific initialization that these devices require, these scene switches must be obligatory re-paired to HE hub in order to work properly.


Supported models

Device Links
Tuya Scene/Dimmer Switch TS004F
image
Brands: Zemismart, Yagusmart, Moes and many others.
Moes: (link)
Amazon.com: (link)
Amazon.de: (link)
Amazon.co.uk: (link)
Wallmart: (link)
AliExpress: (link)

Review: (link)
Tuya Remote Control TS004F
image
Amazon.com: link
Amazon.de: (link) (model TS0044)

Review: (link)
Tuya ZigBee Smart Knob
image
AliExpress: (link)
Wallmart: (link)
LoraTap 6 Button Gang Scene Switch image AliExpres: (link)

Compatibility

  • TS004F models (Scene Switches and Smart Knobs)
  • TS0044 models (Moes Remote)
  • TS0601 Tuya cluster EF00 Scene Switches
  • TS0041 models (it is recommended to use the HE inbuilt drivers)
  • TS0044 models (it is recommended to use the HE inbuilt 'Tuya Scene Switch' driver)

Note: due to non-standard Tuya implementation of the dimming functinality that is incompatible with HE, only the 'Scene Control' mode is supported in Hubitat!


Features

  • Single, Double, Hold keypress events
  • Reverse Buttons ordering option
  • Battery reporting
  • Info and Debug logging preferencies

3 Likes

REVISIONS HISTORY:

  • ver. 1.0.0 2021-05-08 - SmartThings version
  • ver. 2.0.0 2021-10-03 - First version for Hubitat in 'Scene Control'mode - AFTER PAIRING FIRST to Tuya Zigbee gateway!
  • ver. 2.1.0 2021-10-20 - typos fixed; button wrong event names bug fixed; extended debug logging; added experimental switchToDimmerMode command
  • ver. 2.1.1 2021-10-20 - numberOfButtons event bug fix;
  • ver. 2.2.0 2021-10-20 - First succesfuly working version with HE!
  • ver. 2.2.1 2021-10-23 - added "Reverse button order" preference option
  • ver. 2.2.2 2021-11-17 - added battery reporting capability; added buttons handlers for use in Hubutat Dashboards; code cleanup
  • ver. 2.2.3 2021-12-01 - added fingerprint for Tuya Remote _TZ3000_pcqjmcud
  • ver. 2.2.4 2021-12-05 - added support for 'YSR-MINI-Z Remote TS004F'
  • ver. 2.3.0 2022-02-13 - added support for 'Tuya Smart Knob TS004F'
  • ver. 2.4.0 2022-03-31 - added support for 'MOES remote TS0044', singleThreaded: true; bug fix: debouncing timer was not started for TS0044
  • ver. 2.4.1 2022-04-23 - improved tracing of debouncing logic code; option [overwrite: true] is set explicitely on debouncing timer restart; debounce timer increased to 1000ms
  • ver. 2.4.2 2022-05-06 - added LoraTap 6 button Scene Controller
  • ver. 2.4.3 2022-09-18 - added TS0042 Tuya Zigbee 2 Gang Wireless Smart Switch; removed 'release' event for TS0044 switches (not supported by hardware); 'release' digital event bug fix.

The development branch version that contains the latest additions and bug fixes can be manually downloaded from here: https://raw.githubusercontent.com/kkossev/Hubitat/development/Drivers/Tuya%20TS004F/TS004F.groovy

2 Likes

Reserved: Scene Control vs Dimming functionality: TODO

I couldn’t find any reference to how one resets and pairs these, but was able to get there from various breadcrumbs. I put what worked for me in Reddit because it was specific to the switch not the hub.

I’ll happily delete this post if someone provides a more definitive source of truth.

@03bf911806a38b066c01
The procedure that has worked successfully for you is more or less correct, although I think that the initial Reddit post was for a 4-button wall switch (mains powered), while your device is a battery-powered scene switch. And steps 2 and 3 are not needed, at least for my TS004F devices.

TS004F is a dual function device, as with the Tuya hub it may work as either a dimmer ( on, off, or dynamically ramp up/down the brightness level) or as a 'scene switch', where single/double press or hold of each of the 4 buttons is usually used to switch to a pre-defined 'scene' or pre-set brightness/color or white color temperature settings of a single bulb or a group of bulbs. In Hubitat we can use only the 'Scene Switch' mode.

  • Removing the batteries for 10 or more seconds will ensure that the device will load its default settings, potentially clearing any misconfiguration from the previous pairing attempts.
    The above also means that when changing the battery, the replacement must be done quickly, otherwise the switch will revert back to its default factory setting which is Dimmer and will require pairing again to work with HE.
  • The pairing procedure starts by presing the bottom left button for more than 8-9seconds, until all the 4 LEDs start blinking, You must release the button at this time. Different TS004F models manufacturers will refer to this bottom left button as either #3 or #1. That's why the driver has a 'Reverse Button Order' option.
  • When the pairing procedure starts the LED on the same button will start to flicker quickly. The pairing process will end when the LED stops flickering.

These devices are one of the most weird and most difficult to pair to any Zigbee coordinator (hub) different than Tuya. The reason for this is because Tuya hub recognizes the TS004F model at an very early stage of the pairing process and sends the needed initialization commands on time. All other hubs will first perform the standard 'device interview' procedure, and will pass the control to the device specific driver later. TS004F devices require the specific initialization commands to be sent in a short time period (probably 6-7 seconds) from the start of the pairing process. If this time is exceeded, the initialization will not be accepted and the device will work only in Dimmer mode. As strange it may sound, this is something like a 'friend of foe' identification system.

So for successful pairing to HE it helps if the pairing is performed close to the hub, thus minimizing the possibility for commands retries and exceeding the successful pairing time window.

Note, that there are different manufacturers of this Tuya scene switch and the pairing procedures may differ. As example, you can look at this video (pairing to SmartThings) where the author advises to also press the right two buttons, which is not needed for my TS004F device. But obviously works for other manufacturers models.

1 Like

Thanks for the detailed breakdown. I edited my Reddit post based on it.

I realized it wasn’t the same device, but figured it may help someone like myself who couldn’t find definitive reset and pairing instructions.

1 Like

I have two devices on the top.
Now I'm glad to know that it's available in HE.
Thank you.

1 Like

Krassimir- Your skill is quite incredible. I have just paired a Zemismart Device using your driver. All six buttons work great for single press and hold, but not double tap. I did pair initially and the hub used native "Device" driver, even tho I had your driver (https://raw.githubusercontent.com/kkossev/Hubitat/main/Drivers/Tuya%20TS004F/TS004F.groovy) loaded already on the hub before pairing. I re-paired the device again, without removing from hub, to try to get the initialization you mentioned above, after I had switched device to use your driver.

Data section below, clusters look similar to other Tuya devices

Summary
  • endpointId: 01
  • application: 44
  • inClusters: 0000,0004,0005,EF00
  • manufacturer: _TZE200_zqtiam4u
  • model: TS0601
  • outClusters: 0019,000A
  • softwareBuild:

These are the zigbee logs, when a double press of each button 1-6 was performed. The 1st press is button 1, then 2, etc.

Summary

Zemismart Button2022-09-06 16:57:13.561 profileId:0x0, clusterId:0x13, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-57

Zemismart Button2022-09-06 16:57:09.534 profileId:0x0, clusterId:0x13, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-52

Zemismart Button2022-09-06 16:57:05.707 profileId:0x0, clusterId:0x13, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:254, lastHopRssi:-52

Zemismart Button2022-09-06 16:56:59.261 profileId:0x0, clusterId:0x13, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-53

Zemismart Button2022-09-06 16:56:53.522 profileId:0x0, clusterId:0x13, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-57

Zemismart Button2022-09-06 16:56:41.167 profileId:0x0, clusterId:0x13, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-57

Here's the fairly tiny button:

I've sent you my driver but I can't remember if double tap worked. Could try it

@kkossev,

Thank you for this driver.

I have purchased a couple of these 4 button scene switch controllers from Amazon UK and AliExpress.
3 out of 4 features seem to work with both the system driver “Tuya Zigbee Scene Switch” and “Tuya Scene Switch TS004F” driver.


image

The “held” function works with your driver, but not “released”
The “released” function works with system driver but not “held”.

Error received after inputting a value under released:

Is it possible to get both held and released to work together?

Many thanks

With the inbuilt driver, Mike decided not to implement Held as it's an unusually long wait. I seem to remember experimenting a bit and deciding that Held didn't get sent till it was released anyway. But I could be confusing that with some other device I was testing.

Yeah it is these, just tried again.

2 Likes

That's correct, these switches are not very convenient to be used for dimming control ( ramp up / ramp down the level). Probably one day, when and if the Zigbee groups inbound messages are enabled in HE platform the situation may change,

I have tested TS004F in 'Dimmer mode' with the Tuya hub and the dimming control is amazingly fast.

3 Likes

Hi @kkossev Your driver is the only driver, working with this device: Tuya Zigbee 3 Gang Wireless Smart Switch Battery Power Scene Switch Control DIY | eBay
The Push and Double Tap works OK, but Hold and Release didn't. It looks like that is kind of new zigbee 3.0 release of Tuya hardware:
image
Carton box mentioned this model: IH-L400-P4
Please check your driver functionality with this hardware, if you have such ability. I'm ready to help somehow.

1 Like

Hi @IgorV ,
I couldn't find any information for this new manufacturer code _TZ3000_tzvbimpq, so we may need to experiment a bit.

Please update the driver from the development branch version 2.4.3. (the link on the second post). Then pair the device again, very close to HE hub. Turn on the 'Enable debug logging' option and click on the Save button.

I will need the debug logs when you singe press, double press and hold a button.

Hi @kkossev here is the debug log:
dev:6592022-09-19 08:38:31.670 info2nd Floor Master Bedroom Left Light Switch button 1 was held
dev:6592022-09-19 08:38:31.665 debug2nd Floor Master Bedroom Left Light Switch catchall descMap: [raw:catchall: 0104 0006 01 01 0040 00 93F3 01 00 0000 FD 00 02, profileId:0104, clusterId:0006, clusterInt:6, sourceEndpoint:01, destinationEndpoint:01, options:0040, messageType:00, dni:93F3, isClusterSpecific:true, isManufacturerSpecific:false, manufacturerId:0000, command:FD, direction:00, data:[02]]
dev:6592022-09-19 08:38:25.957 info2nd Floor Master Bedroom Left Light Switch button 1 was pushed
dev:6592022-09-19 08:38:25.954 debug2nd Floor Master Bedroom Left Light Switch catchall descMap: [raw:catchall: 0104 0006 01 01 0040 00 93F3 01 00 0000 FD 00 00, profileId:0104, clusterId:0006, clusterInt:6, sourceEndpoint:01, destinationEndpoint:01, options:0040, messageType:00, dni:93F3, isClusterSpecific:true, isManufacturerSpecific:false, manufacturerId:0000, command:FD, direction:00, data:[00]]
dev:6592022-09-19 08:38:19.861 info2nd Floor Master Bedroom Left Light Switch button 1 was pushed
dev:6592022-09-19 08:38:19.857 debug2nd Floor Master Bedroom Left Light Switch catchall descMap: [raw:catchall: 0104 0006 01 01 0040 00 93F3 01 00 0000 FD 00 00, profileId:0104, clusterId:0006, clusterInt:6, sourceEndpoint:01, destinationEndpoint:01, options:0040, messageType:00, dni:93F3, isClusterSpecific:true, isManufacturerSpecific:false, manufacturerId:0000, command:FD, direction:00, data:[00]]
dev:6592022-09-19 08:36:29.715 info2nd Floor Master Bedroom Left Light Switch button 2 was held
dev:6592022-09-19 08:36:29.711 debug2nd Floor Master Bedroom Left Light Switch catchall descMap: [raw:catchall: 0104 0006 02 01 0040 00 93F3 01 00 0000 FD 00 02, profileId:0104, clusterId:0006, clusterInt:6, sourceEndpoint:02, destinationEndpoint:01, options:0040, messageType:00, dni:93F3, isClusterSpecific:true, isManufacturerSpecific:false, manufacturerId:0000, command:FD, direction:00, data:[02]]
dev:6592022-09-19 08:36:23.658 info2nd Floor Master Bedroom Left Light Switch button 2 was doubleTapped
dev:6592022-09-19 08:36:23.653 debug2nd Floor Master Bedroom Left Light Switch catchall descMap: [raw:catchall: 0104 0006 02 01 0040 00 93F3 01 00 0000 FD 00 01, profileId:0104, clusterId:0006, clusterInt:6, sourceEndpoint:02, destinationEndpoint:01, options:0040, messageType:00, dni:93F3, isClusterSpecific:true, isManufacturerSpecific:false, manufacturerId:0000, command:FD, direction:00, data:[01]]
dev:6592022-09-19 08:36:19.966 info2nd Floor Master Bedroom Left Light Switch button 2 was pushed
dev:6592022-09-19 08:36:19.961 debug2nd Floor Master Bedroom Left Light Switch catchall descMap: [raw:catchall: 0104 0006 02 01 0040 00 93F3 01 00 0000 FD 00 00, profileId:0104, clusterId:0006, clusterInt:6, sourceEndpoint:02, destinationEndpoint:01, options:0040, messageType:00, dni:93F3, isClusterSpecific:true, isManufacturerSpecific:false, manufacturerId:0000, command:FD, direction:00, data:[00]]
dev:6592022-09-19 08:36:13.444 info2nd Floor Master Bedroom Left Light Switch button 1 was held
dev:6592022-09-19 08:36:13.440 debug2nd Floor Master Bedroom Left Light Switch catchall descMap: [raw:catchall: 0104 0006 01 01 0040 00 93F3 01 00 0000 FD 00 02, profileId:0104, clusterId:0006, clusterInt:6, sourceEndpoint:01, destinationEndpoint:01, options:0040, messageType:00, dni:93F3, isClusterSpecific:true, isManufacturerSpecific:false, manufacturerId:0000, command:FD, direction:00, data:[02]]
dev:6592022-09-19 08:36:06.651 info2nd Floor Master Bedroom Left Light Switch button 1 was doubleTapped
dev:6592022-09-19 08:36:06.646 debug2nd Floor Master Bedroom Left Light Switch catchall descMap: [raw:catchall: 0104 0006 01 01 0040 00 93F3 01 00 0000 FD 00 01, profileId:0104, clusterId:0006, clusterInt:6, sourceEndpoint:01, destinationEndpoint:01, options:0040, messageType:00, dni:93F3, isClusterSpecific:true, isManufacturerSpecific:false, manufacturerId:0000, command:FD, direction:00, data:[01]]
dev:6592022-09-19 08:36:01.407 info2nd Floor Master Bedroom Left Light Switch button 1 was pushed
dev:6592022-09-19 08:36:01.401 debug2nd Floor Master Bedroom Left Light Switch catchall descMap: [raw:catchall: 0104 0006 01 01 0040 00 93F3 01 00 0000 FD 00 00, profileId:0104, clusterId:0006, clusterInt:6, sourceEndpoint:01, destinationEndpoint:01, options:0040, messageType:00, dni:93F3, isClusterSpecific:true, isManufacturerSpecific:false, manufacturerId:0000, command:FD, direction:00, data:[00]]
dev:6592022-09-19 08:34:46.058 trace2nd Floor Master Bedroom Left Light Switch sendZigbeeCommands(cmd=[raw 0x0000 {10 00 00 04 00 00 00 01 00 05 00 07 00 FE FF}, send 0x93F3 1 255, delay 200, he raw 0x93F3 1 0x01 0x0006 {10 00 00 04 80}, delay 50, he raw 0x93F3 1 0x01 0xE001 {10 00 00 11 D0}, delay 50, he raw 0x93F3 1 0x01 0x0001 {10 00 00 20 00 21 00}, delay 50, he wattr 0x93F3 0x01 0x0006 0x8004 0x30 {01} {}, delay 50, he raw 0x93F3 1 0x01 0x0006 {10 00 00 04 80}, delay 50])
dev:6592022-09-19 08:34:39.211 debug2nd Floor Master Bedroom Left Light Switch updated()
dev:6592022-09-19 08:33:21.662 info2nd Floor Master Bedroom Left Light Switch InitializeVars()... fullInit = false
dev:6592022-09-19 08:33:21.654 debug2nd Floor Master Bedroom Left Light Switch updating the settings from the current driver version 2.4.2 2022/05/07 6:03 PM to the new version 2.4.3 2022/09/18 9:16 AM

I did not see any "Release", just "Hold", what does it means, release is not supported?

1 Like

Thank you for the logs, @IgorV

Yes, this device features only single, double and 'long press' events, which in this driver is registered as 'hold' event.

See the screenshot from the native Tuya app :
image

That is explain everything, thank you!

Please excuse my ignorance, but how do I switch to 'Dimmer' mode? I do not have this as a selectable field on the device page.

Thanks, Ian

I think that's only available when when you have it paired to an actual Tuya hub. Hubitat doesn't offer the required protocols.

1 Like

That's correct.

Download the Hubitat app