LogicMachine Forum
Rolling PIN Code - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Visu (https://forum.logicmachine.net/forumdisplay.php?fid=24)
+--- Thread: Rolling PIN Code (/showthread.php?tid=6459)



Rolling PIN Code - KoBra - 09.06.2026

Would it be possible to load the PIN code from an object instead of set it fixed?
I have a location (Sports Center) where they have a changing code for the door and want to use the same code for the locked screens in visu.


RE: Rolling PIN Code - admin - 10.06.2026

Do you mean plan or object pincode?


RE: Rolling PIN Code - KoBra - 10.06.2026

(10.06.2026, 08:00)admin Wrote: Do you mean plan or object pincode?

Both if possible


RE: Rolling PIN Code - admin - 10.06.2026

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')



RE: Rolling PIN Code - KoBra - 10.06.2026

(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)


RE: Rolling PIN Code - Daniel - 10.06.2026

Its a script, you can just do it like that
Code:
value = event.getvalue() if #value == 6 then   setplanpin(41, value) else   alert('wrong pin length: ' .. tostring(#value)) end