This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Rolling PIN Code
#1
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.
Reply
#2
Do you mean plan or object pincode?
Reply
#3
(10.06.2026, 08:00)admin Wrote: Do you mean plan or object pincode?

Both if possible
Reply
#4
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')
Reply
#5
(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)
Reply
#6
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
------------------------------
Ctrl+F5
Reply


Forum Jump: