SmartThingsEdgeDrivers icon indicating copy to clipboard operation
SmartThingsEdgeDrivers copied to clipboard

Error calling custom capabilities in test.lua

Open ronie-z-wave opened this issue 3 years ago • 1 comments

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?

ronie-z-wave avatar Apr 27 '22 13:04 ronie-z-wave

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

w35l3y avatar Jan 25 '23 15:01 w35l3y