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.

Scenes Process
#2
Here's a function you can use. Scene name which values you want to modify must be unique for it to work correctly.
Code:
function setscenevalues(name, values)
  local json = require('json')
  local sceneid = db:getone('SELECT id FROM scenes WHERE name=?', name)
  sceneid = tonumber(sceneid)

  if not sceneid then
    return nil, 'scene not found'
  end

  for addr, value in pairs(values) do
    local ga = buslib.encodega(addr)
    local update = { value = json.encode(value) }
    local where = { scene = sceneid, object = ga }
    db:update('scene_sequence', update, where)
  end

  scene.reload()

  return true
end

name = 'my scene name'
values = {
  ['32/1/1'] = 1,
  ['32/1/2'] = 2,
  ['32/1/3'] = 3,
}

res, err = setscenevalues(name, values)
log(res, err)
Reply


Messages In This Thread
Scenes Process - by sjfp - 01.04.2019, 15:33
RE: Scenes Process - by admin - 03.04.2019, 07:49
RE: Scenes Process - by sjfp - 04.04.2019, 12:38
RE: Scenes Process - by admin - 04.04.2019, 13:03
RE: Scenes Process - by sjfp - 05.04.2019, 09:33
RE: Scenes Process - by admin - 05.04.2019, 09:42
RE: Scenes Process - by sjfp - 08.04.2019, 09:26
RE: Scenes Process - by DGrandes - 27.05.2019, 14:45
RE: Scenes Process - by admin - 28.05.2019, 12:04
RE: Scenes Process - by ceddix - 10.08.2019, 13:57
RE: Scenes Process - by admin - 12.08.2019, 05:59

Forum Jump: