10.06.2026, 15:53
(10.06.2026, 08:43)admin Wrote: Use the following functions to set plan/widget pin code. For widget you need specify both plan ID that contains the widget and the widget ID. Plan ID / widget ID can be found in the window title when editing.
Important: pin code value must be a string. New pin code must have the same length as the previous.
Code:function setplanpin(planid, pincode) local json = require('json') local structure = storage.exec('hget', 'app:visu:main', 'structure') local function setpin(items) for _, item in ipairs(items) do if item.id == planid then item.pincode = pincode return end if type(item.children) == 'table' then setpin(item.children) end end end structure = json.decode(structure) setpin(structure) local data = json.encode(structure) storage.exec('hset', 'app:visu:main', 'structure', data) end setplanpin(41, '123456')
Code:function setwidgetpin(planid, widgetid, pincode) local json = require('json') local key = 'widgets:' .. planid local widgets = storage.exec('hget', 'app:visu:main', key) widgets = json.decode(widgets) for _, widget in ipairs(widgets) do if widget.id == widgetid then widget.pincode = pincode break end end local data = json.encode(widgets) storage.exec('hset', 'app:visu:main', key, data) end setwidgetpin(41, 42, '123456')
Could i load the PIN from a 250byte string object?
In this way i could write the PIN to the datapoint when i load it from the PIN Generator at the tennis federation (in this case)