Error initializing generated capabilities during a test run
ronie-z-wave opened this issue · comments
If I start a test with capabilities I get the following error message:
PS Q:\repos\smartthings_edge_drivers> lua54 "Q:\repos\SmartThingsEdgeDrivers\drivers\SmartThings\zigbee-contact\src\test\test_zigbee_contact_battery.lua"
Q:\lua\lua54.exe: ...epos\smartthings_edge_drivers\lua_libs-api_v0\dkjson.lua:397: bad argument #3 to 'strfind' (number expected, got string)
stack traceback:
[C]: in function 'string.find'
...epos\smartthings_edge_drivers\lua_libs-api_v0\dkjson.lua:397: in upvalue 'scanwhite'
...epos\smartthings_edge_drivers\lua_libs-api_v0\dkjson.lua:553: in function <...epos\smartthings_edge_drivers\lua_libs-api_v0\dkjson.lua:551>
(...tail calls...)
...gs_edge_drivers\lua_libs-api_v0\st\capabilities\init.lua:42: in upvalue 'inline_type_schema'
...gs_edge_drivers\lua_libs-api_v0\st\capabilities\init.lua:61: in function 'st.capabilities.build_cap_from_json_string'
...gs_edge_drivers\lua_libs-api_v0\st\capabilities\init.lua:114: in metamethod 'index'
...\zigbee-contact\src\test\test_zigbee_contact_battery.lua:117: in main chunk
[C]: in ?
PS Q:\repos\smartthings_edge_drivers>
it's a test from the public zigbee contact drivers.
Same error I got, running my own driver tests ...
seem it's happening during calling st.capabilities.[CAPABILITY_NAME] ...
I've changed capabilities/init.lua inline_type_schema(schema)
to this:
inline_type_schema = function(schema)
if schema["$ref"] ~= nil then
local type_name = schema["$ref"]
if type_name == "color-map" then
type_name = "COLOR_MAP"
end
local cap_type_ref = require(string.format("st.capabilities.generated.types.%s", type_name))
-- TODO: Should this be a separate RPC call or inlined upstream (rust?, cloud?)
return inline_type_schema(json.decode(cap_type_ref))
end
local out_schema = {}
for k,v in pairs(schema) do
if type(v) == "table" then
out_schema[k] = inline_type_schema(v)
else
out_schema[k] = v
end
end
return out_schema
end
seems to work ...
This is typically caused by running with lua 5.4, all SmartThings drivers run and expect lua 5.3