Posts: 165
Threads: 82
Joined: Jul 2015
Reputation:
1
Hi ,
I need to add to the scene sequence or to remove from the scene sequence via script like this.
value = event.getvalue()
if value == true then
-- add object '1/1/1' to scene 'homeenter'
else
-- remove object '1/1/1' to scene 'homeenter'
end
Thx,
Posts: 4660
Threads: 24
Joined: Aug 2017
Reputation:
212
Might be simpler to create two scenes with and without the object and just enable/disable them based on the condition above.
------------------------------
Ctrl+F5
Posts: 7773
Threads: 42
Joined: Jun 2015
Reputation:
447
Another solution is to use a virtual object with AND gate via an event script:
Code: value = event.getvalue()
gate = '1/1/1'
output = '1/1/2'
if grp.getvalue(gate) then
grp.write(output, value)
end
Posts: 165
Threads: 82
Joined: Jul 2015
Reputation:
1
08.03.2024, 09:29
(This post was last modified: 08.03.2024, 09:49 by savaskorkmaz.)
Unfortunately, neither solution works for me. My goal is for the customer to change the scenarios 100% by himself, on a screen.
I have a design like the attached picture.
Theoretically, I can create a virtual output poinst and virtual selection points for all group addresses and gate them with the event script. However, we are doing this demo not for our own project, but for our dealers, and creating hundreds of additional points and creating hundreds of additional scripts is not a sustainable business and partners eventually mix up the scripts and the job becomes impossible.
For this reason, my only way is to add and remove objects with a simple script. I need your help on this matter.
Note : i can' upload picture to the post.
here is the link of screen.
https://ibb.co/qxStbzC
Posts: 4660
Threads: 24
Joined: Aug 2017
Reputation:
212
Do you know this?
------------------------------
Ctrl+F5
Posts: 165
Threads: 82
Joined: Jul 2015
Reputation:
1
08.03.2024, 09:34
(This post was last modified: 08.03.2024, 09:39 by savaskorkmaz.)
I need a solution for visualation page. Not for mosaic beta
(08.03.2024, 09:29)savaskorkmaz Wrote: Unfortunately, neither solution works for me. My goal is for the customer to change the scenarios 100% by himself, on a screen.
I have a design like the attached picture.
Theoretically, I can create a virtual output poinst and virtual selection points for all group addresses and gate them with the event script. However, we are doing this demo not for our own project, but for our dealers, and creating hundreds of additional points and creating hundreds of additional scripts is not a sustainable business and partners eventually mix up the scripts and the job becomes impossible.
For this reason, my only way is to add and remove objects with a simple script. I need your help on this matter.
Note : i can' upload picture to the post.
here is the link of screen.
https://ibb.co/qxStbzC
Posts: 7773
Threads: 42
Joined: Jun 2015
Reputation:
447
Add to Common functions:
Code: function getscenebyname(name)
local id = db:getone('SELECT id FROM scenes WHERE name=?', name)
assert(id, 'scene not found: ' .. name)
return id
end
function getsequenceid(sceneid, object)
local query = 'SELECT id FROM scene_sequence WHERE scene=? AND object=?'
return db:getone(query, sceneid, object)
end
function getdata(name, addr)
local scene = getscenebyname(name)
local object = buslib.encodega(addr)
local sequenceid = getsequenceid(scene, object)
return scene, object, sequenceid
end
function addtoscene(name, addr)
local scene, object, sequenceid = getdata(name, addr)
local res, err
if sequenceid then
err = 'object already added'
else
res, err = require('webrequest')('scenes', 'sequence-save', {
data = {
scene = scene,
object = object,
bus_write = true,
}
})
end
return res, err
end
function removefromscene(name, addr)
local scene, object, sequenceid = getdata(name, addr)
local res, err
if sequenceid then
res, err = require('webrequest')('scenes', 'sequence-delete', {
data = {
id = sequenceid
}
})
if not err then
res = true
end
else
err = 'object not found in scene'
end
return res, err
end
Usage example:
Code: scenename = 'test'
address = '0/0/1'
res, err = addtoscene(scenename, address)
log(res, err)
res, err = removefromscene(scenename, address)
log(res, err)
Scene name must be unique. Each object can be in the scene only once.
Posts: 165
Threads: 82
Joined: Jul 2015
Reputation:
1
Worked wery well. Thx a lot.
|