[RELEASE] Tuya Scene Switch TS004F driver (w/ healthStatus)


Vote for the Linptech Human Presence Sensor with 24G mmWave Radar in the Product of the Year Elevated by Hubitat in 2023 !


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)
AliExpress: link (€ 9,73)

Review: (link)
Tuya ZigBee Smart Knob
image
AliExpress: (link)
Wallmart: (link)
Tuya Smart Button
image
The shape, look, and feel is like Aqara button!
Price: € 7,78
Model: TS0041
Manufacturer: _TZ3000_fa9mlvja

AliExpress:link
Tuya Multi-scene Switch Button
image
Model: TS004F
Manufacturer: _TZ3000_ja5osu5g

AliExpress: link
LoraTap 6 Button Gang Scene Switch image AliExpres: (link)
Loratap 4-Button Remote Control Scene Switch
image
Model:TS0044
Manufacturer: _TZ3000_b7bxojrg

AliExpress: link
Loratap 1-2-3-4 Portable Remote Control Scene Switch
image
Model: TS0041 TS0042 TS0043 TS0044
Manufacturer: _TZ3000_t8hzpgnd _TZ3000_ee8nrt2l _TZ3000_ufhtxr59

AliExpress: link
Tuya Zigbee Smart Switch Button
image
Model:
Manufacturer:
Battery: rechargable 3.7V, capacity: 450mAh

AliExpress: link
Tuya 4 Key Arm Disarm Home SOS Button
image
Model: TS0215
Manufacturers: _TYZB01_qm6djpta _TZ3000_fsiepnrh _TZ3000_p6ju8myv

AliExpress: link
Nedis Remote Control 4 Button
image
Model: TS0215A
Manufacturer: _TZ3000_fsiepnrh

Amazon. co. uk. link
Nedis. com link
Tuya ZigBee SOS Button
image
Model: TS0215A
Manufacturers: _TZ3000_ug1vtuzn _TZ3000_0zrccfgx _TZ3000_p6ju8myv _TZ3000_4fsgukof _TZ3000_wr2ucaj9 _TZ3000_zsh6uat3 _TZ3000_tj4pwzzm _TZ3000_2izubafb _TZ3000_pkfazisv

AliExpress: link
Tuya ZigBee SOS Button
image
Model:
Manufacturer:

AliExpress: link

NON_Tuya devices

Device Links
icasa Zigbee 3.0 wireless wall controller image amazon. co. uk : link
OSRAM Smart+ Mini Switch
image
Important: first pair the switch using Hubitat inbuilt driver!

Model: Lightify Switch Mini
Manufacturer: OSRAM

Amazon UK: link
Amazon DE : link
Tradfri Shortcut Button
image
Model: TRADFRI SHORTCUT Button E1812
Manufacturer: IKEA of Sweden

Ikea: link

Compatibility

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

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 configfuration
  • Info and Debug logging preferences
  • healthStatus attribute

11 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.
  • ver. 2.4.4 2022-10-22 - _TZ3000_vp6clf9d fingerprint correction; importURL changed to dev. branch; added _TZ3000_w8jwkczz and other TS0041, TS0042, TS0043, TS004 fingerprints
  • ver. 2.4.5 2022-10-27 - added icasa ICZB-KPD18S 8 button controller.
  • ver. 2.4.6 2022-11-20 - added TS004F _TZ3000_ja5osu5g - 1 button!; isTuya() bug fix
  • ver. 2.4.7 2022-12-22- (dev. branch) added TS004F _TZ3000_rco1yzb1 LIDL Smart Button SSBM A1; added _TZ3000_u3nv1jwk
  • ver. 2.5.0 2023-01-14 - bug fix: battery percentage remaining automatic reporting was not configured, now hardcoded to 8 hours; bug fix: 'released'event; debug info improvements; declared supportedButtonValues attribute
  • ver. 2.5.1 2023-01-20 - battery percentage remaining HomeKit compatibility
  • ver. 2.5.2 2023-01-28 - _TZ3000_vp6clf9d (TS0044) debouncing; added Loratap TS0046 (6 buttons);
  • ver. 2.6.0 2023-01-28 - added healthStatus; Initialize button is disabled;
  • ver. 2.6.1 2023-02-05 - added _TZ3000_mh9px7cq; isSmartKnob() typo fix; added capability 'Health Check'; added powerSource attribute 'battery'; added dummy ping() code;
  • ver. 2.6.2 2023-02-23 - added Konke button model: 3AFE280100510001 ; LoraTap _TZ3000_iszegwpd TS0046 buttons 5&6;
  • ver. 2.6.3 2023-02-25 - added TS0215 _TYZB01_qm6djpta _TZ3000_fsiepnrh _TZ3000_p6ju8myv
  • ver. 2.6.4 2023-04-27 - added Sonoff SNZB-01; added IKEA Tradfri Shortcut Button E1812; added AC0251600NJ/AC0251100NJ OSRAM Lightify Switch Mini; added TS0041 _TZ3000_fa9mlvja 1 button; TS0215A _TZ3000_2izubafb inClusters correction
  • ver. 2.6.5 2023-05-15 kkossev - TS0215A _TZ3000_pkfazisv iAlarm (Meian) SOS button fingerprint correction; number of buttons and supportedValues correction for SOS buttons; added _TZ3000_abrsvsou
  • ver. 2.6.6 2023-05-30 kkossev - reverseButton default value bug fix;
  • ver. 2.6.7 2023-10-02 louisparks - added TS0044 to debounce list
  • ver. 2.6.8 2023-10-03 kkossev - added debounce timer configuration (1000ms may be too low when repeaters are in use);
  • ver. 2.6.9 2023-10-14 kkossev - REVERTED BACK TO VERSION 2.6.6 timeStamp 2023/05/30 1:51 PM

TODO:

  • add new TS0043 fingerprint
  • add pictures and links to Tuya 1-button models
  • add pictures and links to Tuya 2-button models
  • add pictures and links to Tuya 3-button models
  • add pictures as links to KONKE 1-button model
  • populate the healthStatus attribute value automatically after driver version update
  • add rejoin counter state

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

3 Likes

Reserved: Scene Control vs Dimming functionality: TODO

The experimental driver w/ support for Zigbee Groups (on/off and dimming) code is here :
https://raw.githubusercontent.com/kkossev/Hubitat/development/Drivers/Zigbee%20Button%20Dimmer/Zigbee_Button_Dimmer_lib_included.groovy

Update: driver name changed to "Zigbee Button Dimmer".

1 Like

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.

4 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.