[ST Edge] How to create Zigbee TX message?

Hi,
I’m looking at ZCL Clusters — SmartThings Edge Device Drivers documentation

The provided example explains how to import On/Off Cluster commands:

local OnOffCluster = require "st.zigbee.generated.zcl_clusters.OnOffCluster"

When I try to follow this example, I get the following error:

Lua: runtime error: [string "init.lua"]:6: Module 'st.zigbee.generated.zcl_clusters.OnOffCluster' not found
stack traceback:
        [C]: in function 'error'
        [string "env builder"]:63: in global 'require'
        [string "init.lua"]:6: in main chunk

I assume I miss st.zigbee.generated.zcl_clusters library, but I couldn’t find it anywhere.

I was trying to see whether the On (or Off) command can be aquired from
st.zigbee.zcl.clusters (not from st.zigbee.generated), something like
zcl_clusters.OnOff.client.commands.On, but without any success.

Thank you very much for your help

Hi,
Where
st.zigbee.generated.zcl_clusters
library could be downloaded from?
I’m trying to create On command and get an error.
Lua: runtime error: [string “init.lua”]:6: Module ‘st.zigbee.generated.zcl_clusters.OnOffCluster’ not found

Thanks

Hello, @ygerlovin!
You could try with this reference:

st.zigbee.generated.zcl_clusters.OnOff

You can see this path in the ST Lua Libraries downloaded here.
If you go to the lua_libs-api_v0 directory then st > zigbee > generated > zcl_clusters you’ll find the OnOff directory which the import makes reference to.

Note: I’ll share this feedback to the documentation team.

Hi @nayelyz ,
Thank you for your reply.

If I try to change to

local OnOffCluster = require "st.zigbee.generated.zcl_clusters.OnOff"
...
local command = OnOffCluster.commands.client.On(device)

I get the following error:

2021-08-27T21:11:40.172850419+00:00 ERROR Aqara Zigbee switch Edge driver Aqara Dual Switch LLKZMK11LM Edge thread encountered error: [string "st.zigbee.generated.zcl_clusters.OnOff.client..."]:24: Module 'st.zigbee.generated.zcl_clusters.OnOff.client.commands.On' not found

ok, just to clarify, if you’re only trying to configure your Driver to use the Switch capability for your device, you only need to register it for the default handlers, they will manage all the TX and RX messages automatically so you don’t have to create/parse each message.
To do so, you only need:

local defaults = require "st.zigbee.defaults"


local driver_template = {
    supported_capabilities = {
        capabilities.switch
    },
    lifecycle_handlers = {
        --if needed
    }
}

defaults.register_for_default_handlers(driver_template, driver_template.supported_capabilities)

You can also override the defaults by adding the zigbee_handlers property.
Look at the sample for the ST Multipurpose sensor (Zigbee):

The reference to OnOffCluster.commands.client.On is no longer correct, it should be OnOffCluster.server.commands.On instead.
You can see in the libraries directory that the command On is not included in client, only in server:

...\lua_libs-api_v0\st\zigbee\generated\zcl_clusters\OnOff\server\commands

Replace ... for your local directory name where you stored the libraries and docs of the ST Lua libraries.

3 Likes

Changing to
OnOffCluster.server.commands.On
did the trick.
Thanks

2 Likes