SmartThingsCommunity / SmartThingsEdgeDrivers

Apache License 2.0
260 stars 446 forks source link

Error calling custom capabilities in test.lua #55

Open ronie-z-wave opened 2 years ago

ronie-z-wave commented 2 years ago
Q:\lua\lua54.exe: ...popp-smart-thermostat\src\test\test_smart_thermostat.lua:400: Capability preparestream40760.heatMode version 1 definition not found
stack traceback:
        [C]: in function 'error'
        ...gs_edge_drivers\lua_libs-api_v0\st\capabilities\init.lua:103: in metamethod 'index'
        ...popp-smart-thermostat\src\test\test_smart_thermostat.lua:400: in main chunk
        [C]: in ?

test_smart_thermostat.lua:

-- caps
local capabilities = require "st.capabilities"
local WindowOpenDetectionCap = capabilities["preparestream40760.windowOpenDetection"]

... 
test.register_message_test(
    "setSetpointMode 'fast' should be handled",
    {
      {
        channel = "capability",
        direction = "receive",
        message = { mock_device.id, { capability = "preparestream40760.heatMode", component = "main", command = "setSetpointMode", args = { "fast" } } }
      },
      {
        channel = "zigbee",
        direction = "send",
        message = { mock_device.id, HeatingMode.setpointMode.fast() }
      }
    }
)

is there another reference missing on my side?

w35l3y commented 1 year ago

This is an example I have so far: https://github.com/w35l3y/EdgeDrivers/blob/beta/default-clusters/src/test/switch.lua

It is not complete, but it is working. At some point, you need to add your devices to the test. Before that, you will need to get the profile. You probably are missing the command test.load_all_caps_from_profile(profile) https://github.com/w35l3y/EdgeDrivers/blob/beta/default-clusters/src/test/switch.lua#L10