Where to start writing Custom driver for TS130F smart curtain switch (tuya clone)?

Tried to use this groovy DTH as a sample Window Covering - Unable to parse response - #3 by cookierookie44

and freaking thing doesn’t even react…

Nice! IMO is a great fingerprint source = ) and in my experience, with the proper manufacturer and model definition you can begin to integrate the device using the tutorials Nayely shared

1 Like

OK, some progress here… got it working with commands to close and set covering level. Open command is consistently ignored for sone reason, same as On and Off ones…
I.e.
zigbee.command(CLUSTER_WINDOW_COVERING, 0x01)
works fine, but
zigbee.command(CLUSTER_WINDOW_COVERING, 0x00)
doesn’t

ST UI says “network error”… what does it mean ? Is there a way to see Hub logs to figure out why command wasn’t sent or ignored ?

That’s using a DTH, right?
When you send the command from the mobile app and the Zigbee device receives the command correctly, it should send a report with the new value if the update was successful.
When the report is received in the parse() method, the value is sent to the capability.
In this case, if we see the network error, it means the command wasn’t successful because no event was received by the parse method.
Make sure you’re sending the correct parameters:

zigbee.command(clusterID, commandID, [optional payload])

For DTH, we cannot see the message exchange in the event log, but I’ve seen other Community members use a Zigbee sniffer for this purpose, so you could get one.

For Edge drivers, you can use the CLI logcat command to see the RX and TX messages between the Hub and the device.

After switching to Edge and using sample driver from @veonua as a template, it finally works

I’d like to iron it out a little bit adding calibration dialog in GUI, but that’s TBD. For now one needs to turn calibration mode manually, do it, and then turn it off…

Documentation for Edge libraries is terrible… some elements are not documented as all, ones that are documented - have no examples of use, types are a mess… so without working example it’s nearly impossible to create a driver :slight_smile:

2 Likes

Thank you for the feedback regarding the Edge documentation. Just to have a better reference, can you provide more details, please?

  • Which functions did you notice missing?
  • What do you consider wrong about the data types?

In addition to the Edge reference documentation, did you check the ST Lua Libraries included in this section?
In the last one, you can see the code of the default handlers, and other functions that would help you understand how they work.

Nayely,

here are couple cases which I stumbled upon:

  1. local cluster_base = require “st.zigbee.cluster_base”. That “cluster_base” is not documented at all. Do search in your Edge reference - nothing returns
  2. device:send_to_component(command.component, zcl_clusters.WindowCovering.server.commands.Stop(device)) . Where, where on earth is it documented in WindowCovering ? in Edge references, it’s described as “class st.zigbee.zcl.clusters.WindowCovering.Stop”. So that “.server.commands.” complements part I can only learn/pick from examples, not from the documentation
  3. device:send(cluster_base.write_attribute(device, data_types.ClusterId(zcl_clusters.WindowCovering.ID), attr, data_msg)) Again, why zcl_clusters.WindowCovering.ID property, which is Cluster ID, returns value with wrong data type ?! So I need to explicitly convert it to ClusterID type before I can use it ?

I guess it’s a lack of experience with Lua. Nayely’s link to the ST Lua Libraries is very useful.

local cluster_base = require “st.zigbee.cluster_base”

basically, you just load the external library made by ST team.

So I need to explicitly convert it to ClusterID type before I can use it?

this is how Lua works, it’s possible to handle other types there, but it will take much more effort. The Edge API is in Beta and it’s impossible to make everything perfect in such a short period of time.

2 Likes

Andrew,

my feedback is about documentation mostly. I understand what “require” statement does, however I
Unpacked API docs from that link - not a word about “cluster_base”. EVERY sample piece of code there loads st.zigbee.cluster_base, but where is documentation what this library does/implements ?

And yes, LUA is a strict types language, however I still find it strange that cluster number always needs to be used as ClusterID type in library functions, why same library class property returns it as uint16 ? Now, it’s just a little quirk, and perhaps too much grunt from my side, but just as an observation.

Yes, it’s beta so I’m not complaining, but rather provide feedback. Sooner or later it will be out of beta right ?
BTW, for how long has it been in beta ?

The open Beta was released in August 2021.

But there has been continuous development during that time, as you can tell from the release dates on the individual stock (created by Samsung) Edge Drivers.

August 2021

1 Like

Corrected, thanks! :sunglasses:

1 Like

Hello, Alexander

I’m trying to use your code as a Device Handler, but I can’t, as you can see in the attached image.

Can you tell me how can I use it?

Hello Alex,

I’ used your driver dor my curtain switch QS-Zigbee-CP03 and works great!

This is the fingerprint:

Data
application: 40
endpointId: 01
manufacturer: _TZ3000_zirycpws
model: TS130F
zigbeeNodeType: ROUTER
Raw Description 01 0104 0202 01 05 0004 0005 0006 0102 0000 02 0019 000A

Thanks for your work!

@v.porsio or @NonAlex
Can you please share your invite ? I want to use the same device with your driver
Thanks in advance…

+1. @v.porsio / @NonAlex please send invitation

1 Like

+1. @v.porsio / @NonAlex

Hello sorry for delay…

this is the link to my channel:

the driver works, but there is a problem with the state.
After 15min the switch seems to be in a freeze state and I lose the state of the curtain (go to closed). To resume the switch I have to press the “up” button first and then it’s possible to command it again.

I’m not a programmer or an it expert, I can’t solve this problem…

These TS130F models are added to my driver Zigbee Window Treatment Mc
@dotan_shai are tested some devices

  - id: "TS130F/_TZ3000_vd43bbfq"
    deviceLabel: Lonsonho QS-Zigbee-C01
    manufacturer: _TZ3000_vd43bbfq
    model: TS130F
    deviceProfileName: window-treatment-profile-calib
  - id: "TS130F/_TZ3000_fccpjz5z"
    deviceLabel: Lonsonho QS-Zigbee-C01
    manufacturer: _TZ3000_fccpjz5z
    model: TS130F
    deviceProfileName: window-treatment-profile-calib
  - id: "TS130F/_TZ3000_4uuaja4a"
    deviceLabel: Lonsonho QS-Zigbee-CP03
    manufacturer: _TZ3000_4uuaja4a
    model: TS130F
    deviceProfileName: window-treatment-profile-calib
  - id: "TS130F/_TZ3000_zirycpws"
    deviceLabel: Lonsonho QS-Zigbee-CP03
    manufacturer: _TZ3000_zirycpws
    model: TS130F
    deviceProfileName: window-treatment-profile-calib
  - id: "MS-108ZR/_TZ3000_1dd0d5yi"
    deviceLabel: MS-108ZR
    manufacturer: _TZ3000_1dd0d5yi
    model: TS130F
    deviceProfileName: window-treatment-profile-calib-2
1 Like