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

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

2 Likes

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

https://api.smartthings.com/invitation-web/accept?id=6b68563b-1905-4654-8d2b-e677a2997424

1 Like

Hello Mariano, you are my hero…

Your driver seem to be the same behavior about the status, after 15/17 goes to 0% (closed).

But now i don’t need to press up button to resume the switch. Now it is immediately avalaible for up and down directions.

Hi @v.porsio

This device has profile with calibration option in preferences
Are you performed a device calibration procedure?

Calibration option unfortunately is not availabe in the settings. Only preset position srttings is available.

Hi @mhertis

Calibration functions is only available in those models

   { mfr = "_TZ3000_vd43bbfq", model = "TS130F" },
    { mfr = "_TZ3000_fccpjz5z", model = "TS130F" },
    { mfr = "_TZ3000_4uuaja4a", model = "TS130F" },
    { mfr = "_TZ3000_zirycpws", model = "TS130F" },
    { mfr = "_TZ3000_1dd0d5yi", model = "TS130F" },
    { mfr = "_TZ3000_qqdbccb3", model = "TS130F" }

Mariano_Colmenarejo

Regarding this driver as it pertains to the SmartWings Roller Shade/Blind:

  • id: “SmartWings/WM25/L-Z”
    deviceLabel: SmartWings Window Treatment
    manufacturer: SmartWings
    model: WM25/L-Z

The SmartThings tile reports the Blind as ‘Closed’ when the blind in open and visa versa. Can the coding specific to SmartWings be updated to correct this issue? There are no settings within the device settings to reverse the state of the blind.