I’m writing an Edge driver for integration of an alarm system (Vanderbilt SPC). The driver creates automatically ST-devices for the Panel, all Alarm Areas (partitions) and all Alarm Zones. The data from the alarm system lacks information about the specific zone type (Contact sensor or Motion detector). Therefore it up to user to configure the type for each ‘imported’ zone. Only chance to change the type (profile) on an already created device, I think, would be to remove the device and create it again with a new profile.
I use the function try_create_device() for creation but can’t find any function for deletion of a existing device. How can I do that?
PS. From UX perspective, the best should be to be able to change the capability of the device from device itself (eg from contactSensor to motionSensor), but I can’t see that that is possible.
@erickv
Actually, I have tried to replace the profile, using the try_update_metadata, without any success.
But if you are sure it should work I can give it another try.
Just for reference, I tested the implementation, and it works as expected. What I did was to implement the API in response to a simple device command, i.e.:
...
local function handle_cmd(_, device, command)
if command.component == 'main' then
local success, msg = pcall(
device.try_update_metadata,
device,
{profile='any-other-profile', vendor_provided_label='erickv'}) -- profile reference
end
end
Note: notice that the profile referred must be pre-packaged.
@erickv
Thank you very much for your help. I really appreciate your support. Probably I have used the function incorrectly. Just wondering… the parameter “vendor” you have in your example, shouldn’t be “vendor_provided_label”?