diff options
author | Ted Trask <ttrask01@yahoo.com> | 2015-12-28 16:09:52 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2015-12-28 16:09:52 +0000 |
commit | 0e9d6d88d375f3ef9226ee053db819d671582e24 (patch) | |
tree | a88f0a2c567e148292b200e97343207e275db0e7 /provisioning-model.lua | |
parent | f91deac776293158454217d3437762576e30d3a7 (diff) | |
download | acf-provisioning-0e9d6d88d375f3ef9226ee053db819d671582e24.tar.bz2 acf-provisioning-0e9d6d88d375f3ef9226ee053db819d671582e24.tar.xz |
Modify update_device to also validate device params (this causes update_device_params.lua to be called before update_device.lua)
Diffstat (limited to 'provisioning-model.lua')
-rw-r--r-- | provisioning-model.lua | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/provisioning-model.lua b/provisioning-model.lua index 3c4dfe7..2c54619 100644 --- a/provisioning-model.lua +++ b/provisioning-model.lua @@ -1257,7 +1257,7 @@ mymodule.update_group = function(self, group, action, create) -- Update the devices after databasedisconnect so device failure doesn't rollback the change if success then - -- Notify the devices that their params might have changed + -- Notify the devices that their params might have changed (this will also validate) for i,d in ipairs(devices) do local r = set_device_params(get_device_params(d.device_id, false), false) if r.errtxt then self.logevent("Failed to update params for device "..d.device_id..": "..r.errtxt) end @@ -1442,7 +1442,7 @@ mymodule.update_param = function(self, param, action, create) -- Update the devices after databasedisconnect so device failure doesn't rollback the change if success then - -- Notify the devices that their params might have changed + -- Notify the devices that their params might have changed (this will also validate) for i,d in ipairs(devices) do local r = set_device_params(get_device_params(d.device_id, false), false) if r.errtxt then self.logevent("Failed to update params for device "..d.device_id..": "..r.errtxt) end @@ -1648,8 +1648,14 @@ mymodule.update_device = function(self, device, action, create) end end + -- Notify the device that its params might have changed (this will also validate) local s = saved_device_params[device.value.device_id.value] - callscript(updatedevicescriptfile, device, saved_devices[device.value.device_id.value], get_device_params(device.value.device_id.value), s) + local r = set_device_params(get_device_params(device.value.device_id.value, false), false) + if r.errtxt then + error(r:print_errtxt()) + end + + callscript(updatedevicescriptfile, device, saved_devices[device.value.device_id.value], r, s) saved_devices[device.value.device_id.value] = device end |