Logic Machine Forum
Log / Unlog Objects via script - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Log / Unlog Objects via script (/showthread.php?tid=4187)



Log / Unlog Objects via script - Fahd - 11.08.2022

Hi,  

Please, is there any way to turn on the log function of some objects via a tag and scheduled script? 

I want to log some presence between 00:00 and 07:00, one of them is detecting a wrong motion at that time, and I don't want to log all  the presences  the whole day because I will get a lot of unnecessary data


RE: Log / Unlog Objects via script - admin - 11.08.2022

Create two scheduled scripts that run at 0:00 and 7:00. Change group address as needed.

Code:
grp.create({ address = '0/0/1', log = true })

Code:
grp.create({ address = '0/0/1', log = false })



RE: Log / Unlog Objects via script - Fahd - 11.08.2022

(11.08.2022, 06:27)admin Wrote: Create two scheduled scripts that run at 0:00 and 7:00. Change group address as needed.

Code:
grp.create({ address = '0/0/1', log = true })

Code:
grp.create({ address = '0/0/1', log = false })
Thank you


RE: Log / Unlog Objects via script - F.Braun - 05.05.2023

Code:
y = grp.getvalue('32/1/7')
x = grp.tag('Aufzeichnung')

m = #(x)
test = x[1].address
t = '32/1/8' -- TEST
log(m,y,test,t)

if y == true then
  u = 99 -- if log 99 then if was successfull
    for i = 1,m,1 do
    z = x[1].address --
    grp.create({ address = '32/1/6', log = true })--works
    grp.create({ address = z, log = true })--doesnt work
    log(z,u)
  end
else
  u = 77 -- if log 77 then if wasnt successfull
      for i = 0,m,1 do
      grp.create({ address = x[i].address, log = false })
    end
end
One quick question. Why does the first line of grp.create work and the second doesnt? Do i need to Convert the variable z to something else then string?

I want to change alot of Objects that all got the same tags. 

-- F.Braun


RE: Log / Unlog Objects via script - admin - 05.05.2023

Use an event script instead of resident:
Code:
enabled = event.getvalue()

objs = grp.tag('Aufzeichnung')
for _, obj in ipairs(objs) do
  grp.create({
    address = obj.address,
    log = enabled
  })
end



RE: Log / Unlog Objects via script - F.Braun - 05.05.2023

Thank you!

-- F.Braun