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

Hi @kkossev, so far only the initial entry after pairing, no updates since then, but i will monitor that, since its less than 24hours

Now I see that the battery periodic reporting is not working with my devices also ... : (
Will notify you and push an update after the fix in the next few days.
Thank you for the report!

1 Like

My pleasure, Thx for the quick response too, ill keep an eye open for the update when it arrives

You can try the dev. branch version 2.5.0 (update manually from the link in the second post).
The battery reporting (percentage remaining and voltage) interval is hardcoded to 8 hours. I checked several different devices, and as may be expected from Tuya - they behave differently. Both the 4-keys TS004F and the rotary knob accepted the percentage and the voltage reporting configurations, so hopefully, this will work for your device too.

In order the battery reporting settings to be accepted, you need to click on the 'Configure' button, while the switch/knob is awake - press a physical button on the device at the same time.

1 Like

Do you mean the official HE Homkit integration? I can't find any of my TS004F buttons on the Home application : (

@kkossev

Hi Krassimir, yes i exposed the scene controller through the official HK app.
It shows up as a device

Adding a screenshot here:

It shows up in my HomeKit just fine and i am able to control devices and scenes with it from homekit.

On the Hubitat side i get a batt level update every 4 hours now. But is doesnt update on the Homekit side yet. This might be an integration glitch though, maybe @gopher.ny has an idea on that.

For now the driver * driverVersion : 2.5.0 2023/01/14 5:16 PM works fine although the device definately has its quirks trying to accept the new driver and configure it with it. The update works fine on the Hubitat side now so many thanks for that quick fix.

Edit: now that i am looking at it, i notice the temp 0 deg on top as well. This is a value of my doorsensor that also provides temperature (Fibaro). It seems that devices with multiple functions have some issues with the integration i presume.

1 Like

I'll double check.

2 Likes

@kkossev

Krassimer, next test; (thumbs up, driver works fine on HE 2.3.4.133)

  • modelGroup : TS0601_Tuya
  • lastRx : {"tempTime":1674057291773,"humiTime":1674057291987,"tempCfg":"-1,-1,-1","humiCfg":"-1,-1,-1"}
  • stats : {"rxCtr":29,"txCtr":0,"rejoins":1}
  • driverVersion : 1.2.0 2023/01/15 12:42 PM

Shows up after easy pairing in HE (i had to select the driver manually, so i took the hum / temp / illum)
afbeelding
afbeelding

After exposing it to homekit i get the following

Some strange things.

  1. Same driver as the scene controller, but the TS0601 does push the correct battery status to HK.

  2. The device exposes the lux value from the driver as 0 lux value to HK because the device doesnt have that functionality. In HE is shows up on the dashboard as “unknown” as per picture below. Actually the TS0601 has sensors for temp (you can switch between F and C) and humidity presented in % (RH).

Sensor refresh every 30 seconds.

Also there is a smiley on the LCD (2 states) depicting a sad face with humidity either under 39 or above 70%. 40-69% give a happy face.

#So…. Could there be something in the driver that pushes the battery level
# of the scene controller wrong to HK?

And… can you add support for the TS0601 (so without illuminnce) based in the current driver that apparently works besides the unknown / 0 lux message?

1 Like

Please reply in the other driver thread where I asked the question

I think that I may have found the reason for this ( HomeKit expects integer/numeric values for the battery level, while zigbee.getEvent() is returning a decimal value ( e.g. 100.0 ) for some Tuya devices...). Strangely, the same zigbee.getEvent() function returns an integer value for my Loratap switch.
image

Can you update to the dev. branch version 2.5.1 and confirm if the 'low battery' / 0% warning in Homekit will be fixed for your device too? You will have to wait for the next battery reporting time to come and overwrite the previous decimal value.

1 Like

@kkossev

Works!!! Properly exposed to HK now. Battery state 100% :ok_hand:

2 Likes
code
	def event = null
    try {
        event = zigbee.getEvent(description)
    }
    catch (e) {
        if (logEnable) {log.warn "${device.displayName} exception caught while procesing event $description"}
    }
	def result = []
    def buttonNumber = 0
    
	if (event) {
        if (logEnable) log.debug "${device.displayName} Event enter: $event"
        switch (event.name) {
            case 'battery' :
                event.value = event.value as int    // HomeKit
                event.unit = '%'
                break
            case 'batteryVoltage' :

This is the code change that fixed the battery reporting issue in HomeKit.
If Apple requires always numeric values, probably the conversion to integer could be done in the HE connector to HomeKit.

1 Like

unfortunatelly Mr Kossev my 4 scene zigbee button still sends out double pulses. So it switches on or off staight away. It Might be a faulty device. Is the any software soultion against double contacts?
Thank You

Hi @zsolt.toth.39 ,
I need to know which one of the different scene switches is your device. You have mentioned Model:TS0044 Manufacturer:_TZ3000_vp6clf9d in the post before 3 months, is the problem with this or with another device?

  • Please check the Data section of the device and confirm it is _TZ3000_vp6clf9d
  • Can you post a link to the site where it was purchased?
  • Does it send double (or triple) button events for each of the buttons, or only for buttons #2, 3 and 4?

same device. ebay 2 years ago . always acted intermittent.

  • endpointId: 01
  • application: 42
  • manufacturer: _TZ3000_vp6clf9d
  • model: TS0044
  • battery : 100
  • batteryVoltage : 3.0
  • numberOfButtons : 4
  • pushed : 4
  • supportedButtonValues : ["pushed","double","held"]
  • driverVersion : 2.5.1 2023/01/20 12:55 PM
  • lastButtonNumber : 4

the rest i posted before
thank you

1 Like

Please update to ver 2.5.2 ( dev. branch, use the Import button from within HE drivers code editor) and test again.
This is the second TS0044 device which needs debouncing, until recently this was a problem for TS004F devices only....

The price of the debouncing logic inside the driver is 1 second delay between two consecutive presses of the same key. Normally, it is not a practical problem. Let me know if this version fixes the issue.

Dear Kossev

Its seems this debouncing has solved the problem. I always new from your work that you are a great programmer.
Thank you very much again.

Zsolt

1 Like

Mr Kossiev
The only issue with this driver that most of the times it only acts at the second push.
But this is still better than when it doulbed.

Thank You

Hi @zsolt.toth.39 ,
I will need some debug logs which include a period when a key was pushed, but not registered in HE.
Is the device used close to HE hub, or at a good distance that assumes it communicates through one or more repeaters?

dev:15682023-01-26 21:54:43.152info4 button scene button 4 was pushed

dev:15682023-01-26 21:54:43.149debug4 button scene catchall descMap: [raw:catchall: 0104 0006 04 01 0040 00 5341 01 00 0000 FD 00 00, profileId:0104, clusterId:0006, clusterInt:6, sourceEndpoint:04, destinationEndpoint:01, options:0040, messageType:00, dni:5341, isClusterSpecific:true, isManufacturerSpecific:false, manufacturerId:0000, command:FD, direction:00, data:[00]]

dev:15682023-01-26 21:54:43.148debug4 button scene description is catchall: 0104 0006 04 01 0040 00 5341 01 00 0000 FD 00 00

dev:15682023-01-26 21:54:35.751debug4 button scene debouncing timer for button 4 expired.

dev:15682023-01-26 21:54:34.756debug4 button scene restarted debouncing timer 1000ms for button 4 (lastButtonNumber=4)

dev:15682023-01-26 21:54:34.725warn4 button scene ignored event for button 4 - still in the debouncing time period!

dev:15682023-01-26 21:54:34.723debug4 button scene catchall descMap: [raw:catchall: 0104 0006 04 01 0040 00 5341 01 00 0000 FD 00 00, profileId:0104, clusterId:0006, clusterInt:6, sourceEndpoint:04, destinationEndpoint:01, options:0040, messageType:00, dni:5341, isClusterSpecific:true, isManufacturerSpecific:false, manufacturerId:0000, command:FD, direction:00, data:[00]]

dev:15682023-01-26 21:54:34.721debug4 button scene description is catchall: 0104 0006 04 01 0040 00 5341 01 00 0000 FD 00 00

dev:15682023-01-26 21:54:22.069info4 button scene button 4 was pushed

dev:15682023-01-26 21:54:22.066debug4 button scene catchall descMap: [raw:catchall: 0104 0006 04 01 0040 00 5341 01 00 0000 FD 00 00, profileId:0104, clusterId:0006, clusterInt:6, sourceEndpoint:04, destinationEndpoint:01, options:0040, messageType:00, dni:5341, isClusterSpecific:true, isManufacturerSpecific:false, manufacturerId:0000, command:FD, direction:00, data:[00]]

dev:15682023-01-26 21:54:22.064debug4 button scene description is catchall: 0104 0006 04 01 0040 00 5341 01 00 0000 FD 00 00

dev:15682023-01-26 21:54:13.082debug4 button scene debouncing timer for button 4 expired.

dev:15682023-01-26 21:54:12.088debug4 button scene restarted debouncing timer 1000ms for button 4 (lastButtonNumber=4)

dev:15682023-01-26 21:54:12.062warn4 button scene ignored event for button 4 - still in the debouncing time period!

dev:15682023-01-26 21:54:12.059debug4 button scene catchall descMap: [raw:catchall: 0104 0006 04 01 0040 00 5341 01 00 0000 FD 00 00, profileId:0104, clusterId:0006, clusterInt:6, sourceEndpoint:04, destinationEndpoint:01, options:0040, messageType:00, dni:5341, isClusterSpecific:true, isManufacturerSpecific:false, manufacturerId:0000, command:FD, direction:00, data:[00]]

dev:15682023-01-26 21:54:12.058debug4 button scene description is catchall: 0104 0006 04 01 0040 00 5341 01 00 0000 FD 00 00

dev:15682023-01-26 21:52:06.589warn4 button scene DID NOT PARSE MESSAGE for description : read attr - raw: 53410100001CDFFF420A000000000C0000000011, dni: 5341, endpoint: 01, cluster: 0000, size: 1C, attrId: FFDF, encoding: 42, command: 0A, value: 0A000000000C0000000011

dev:15682023-01-26 21:52:06.587debug4 button scene raw: descMap: [raw:53410100001CDFFF420A000000000C0000000011, dni:5341, endpoint:01, cluster:0000, size:1C, attrId:FFDF, encoding:42, command:0A, value:, clusterInt:0, attrInt:65503]

dev:15682023-01-26 21:52:06.583debug4 button scene description is read attr - raw: 53410100001CDFFF420A000000000C0000000011, dni: 5341, endpoint: 01, cluster: 0000, size: 1C, attrId: FFDF, encoding: 42, command: 0A, value: 0A000000000C0000000011

dev:15682023-01-26 21:52:06.465debug4 button scene sendEvent [name:battery, value:100, unit:%, descriptionText:battery is 100 %, isStateChange:true, type:physical]

dev:15682023-01-26 21:52:06.463info4 button scene battery is 100 %

dev:15682023-01-26 21:52:06.462debug4 button scene Event enter: [name:battery, value:100.0]

dev:15682023-01-26 21:52:06.458debug4 button scene description is read attr - raw: 534101000110210020C82000201E, dni: 5341, endpoint: 01, cluster: 0001, size: 10, attrId: 0021, encoding: 20, command: 0A, value: C82000201E

dev:15682023-01-26 21:52:06.355warn4 button scene DID NOT PARSE MESSAGE for description : read attr - raw: 53410100001001002042E2FF201C, dni: 5341, endpoint: 01, cluster: 0000, size: 10, attrId: 0001, encoding: 20, command: 0A, value: 42E2FF201C

dev:15682023-01-26 21:52:06.353debug4 button scene raw: descMap: [raw:53410100001001002042E2FF201C, dni:5341, endpoint:01, cluster:0000, size:10, attrId:0001, encoding:20, command:0A, value:42, clusterInt:0, attrInt:1, additionalAttrs:[[value:1C, encoding:20, attrId:FFE2, consumedBytes:4, attrInt:65506]]]

dev:15682023-01-26 21:52:06.348debug4 button scene description is read attr - raw: 53410100001001002042E2FF201C, dni: 5341, endpoint: 01, cluster: 0000, size: 10, attrId: 0001, encoding: 20, command: 0A, value: 42E2FF201C

dev:15682023-01-26 21:52:06.223warn4 button scene DID NOT PARSE MESSAGE for description : read attr - raw: 534101000010010020FFE2FF201C, dni: 5341, endpoint: 01, cluster: 0000, size: 10, attrId: 0001, encoding: 20, command: 0A, value: FFE2FF201C

dev:15682023-01-26 21:52:06.221debug4 button scene raw: descMap: [raw:534101000010010020FFE2FF201C, dni:5341, endpoint:01, cluster:0000, size:10, attrId:0001, encoding:20, command:0A, value:FF, clusterInt:0, attrInt:1, additionalAttrs:[[value:1C, encoding:20, attrId:FFE2, consumedBytes:4, attrInt:65506]]]

dev:15682023-01-26 21:52:06.215debug4 button scene description is read attr - raw: 534101000010010020FFE2FF201C, dni: 5341, endpoint: 01, cluster: 0000, size: 10, attrId: 0001, encoding: 20, command: 0A, value: FFE2FF201C

dev:15682023-01-26 21:52:00.999debug4 button scene received device announcement, Device network ID: 5341

dev:15682023-01-26 21:52:00.995debug4 button scene catchall descMap: [raw:catchall: 0000 0013 00 00 0040 00 5341 00 00 0000 00 00 814153266CA1FEFF72025C80, profileId:0000, clusterId:0013, clusterInt:19, sourceEndpoint:00, destinationEndpoint:00, options:0040, messageType:00, dni:5341, isClusterSpecific:false, isManufacturerSpecific:false, manufacturerId:0000, command:00, direction:00, data:[81, 41, 53, 26, 6C, A1, FE, FF, 72, 02, 5C, 80]]

dev:15682023-01-26 21:52:00.992debug4 button scene description is catchall: 0000 0013 00 00 0040 00 5341 00 00 0000 00 00 814153266CA1FEFF72025C80

1 Like