seen somewhere at forum but not possible to find..
I need create possiblity change dimming level of different lamps by user and than save it like scenario.. Customer wants to have at least possibility to create by themselves at least 4 scenaries and save it for future selection.
big thanks for info, but I could't find script seen here before. With it customer can press somenthing like "learn" key at visu, select different light level for lightting devices and "save" all setting as scene 1. Save different light levels for scene 2...etc. And later just select scene name or number to switch on previously saved settings.
This is not like scene programming in our devices, this is with script I want find
big thanks for info, but I could't find script seen here before. With it customer can press somenthing like "learn" key at visu, select different light level for lightting devices and "save" all setting as scene 1. Save different light levels for scene 2...etc. And later just select scene name or number to switch on previously saved settings.
This is not like scene programming in our devices, this is with script I want find
Alex
If you're using KNX devices, than you can just send value 128 + N to scene group address, where N - is 0..64 scene number
Hi
You can make an interface where user can select values for a scene and then you can save it via such command scene.savelive(name)
Smart way it would be to save scene on long press of the scene button.
BR
functionscene_manager(event)
-- получаем имя переменной, она является именем сценария - receiving name of variable, it will be name of scenario name_scenario = grp.alias(event.dst)
-- определяемся находимся ли мы в режиме обучения - checking, is learning mode switched on or notis_learn_mode = grp.getvalue('learn_mode')
-- если переменная определена в системе - if this variable existing in systemif(is_learn_mode ~= nil) then-- включен режим обучения, записываем в память - and learning mode is on than saving to memoryif(is_learn_mode == true) then-- сохраняем массив в память под именем переменной сценария --saving array to memory under variable - scenario's name -- получаем все объекты системы с меткой 'light' -- receiving all objects with tag "light"lights = grp.tag('light')
-- сохраняем список объектов и --saving list of objects and it's statuses under scenario variable-- их состояния под именем переменной сценарияstorage.set(name_scenario, lights)
else-- иначе считываем массив из памяти -- or reading array from memorylights = storage.get(name_scenario, 'no data')
-- и устанавливаем в цикле значения по имени объекта -- and setting in cycle values by object's names-- для установки по групповому адресу нужно использовать -- for group addresses usage -- light.address вместо light.name -- use light.address instead light.nameiftype(lights) == 'string'thenalert('No data')
endlog (type(lights))
iftype(lights) == 'table'thenforindex, lightinipairs(lights) dolog(light.name, light.data)
grp.write(light.name, light.data)
endendendendendfullpagetranslatedbelow:
logicmachine.net.ruTechnicalsolutionsatLogicMachineUserEditableLightScenariosUserEditableLightScenariosPurpose: TocreatetheabilityfortheusertochangepredefinedlightscenesbyhimselfusingvisualizationonaniPadorcomputer.Hardwarerequirements : asolutioncanonlybeimplementedusingthefreelyprogrammableLogicMachinecontroller.Solution: Wedeterminethegroupaddressesthatwillparticipateinthescript.Forthemwedefinetags (tags) " light ". Wedeterminethegroupaddressesthatwillberesponsibleforthescripts.Itisimportanttogivemeaningfulnamestothevariablescorrespondingtotheseaddresses (Scene_1, Scene_2andsoon).
Toswitchthesystemfromthescriptlearningmodetothescriptdisplaymode, wedeterminethegroupaddressinwhichinformationaboutthesystemstatuswillbestored.Namethevariablelearn_mode.Itisimportantthatthevariabletypeisbinary (boolean).
Foreachgroupaddressselectedasabuttonhandler (Scene1, Scene2, etc.), createascriptinScripts -> Event-based (Scripts -> Event-based).
Weaddoneentrytoeachscript:
scene_manager (event)
Here, afunctioncommontoallscriptsiscalled, whichisusedtocreateorexecuteascript, whereastructurecontaininginformationabouttheeventsourceispassedthroughtheeventparameter.Next, intheScripts -> Generalfunctions (Scripts -> Commonfunctions) wewritethefollowingscript, wherewedefinethisfunction.Sourcefunctionscene_manager ( event )
- getthenameofthevariable, itisthenameofthescriptname_scenario = grp.alias ( event.dst )
- determinewhetherweareintrainingmodeis_learn_mode = grp.getvalue ( 'learn_mode' )
- ifthevariableisdefinedinthesystemif ( is_learn_mode ~ = nil ) then
- learningmodeison, writetomemoryif ( is_learn_mode == true ) then
- savethearrayinmemoryunderthenameofthescriptvariable
- wegetalltheobjectsofthesystemlabeled'light'lights = grp.tag ( 'light' )
- savethelistofobjectsand
- theirstateunderthenameofthescriptvariablestorage.set ( name_scenario, lights )
else
- otherwise, readthearrayfrommemorylights = storage.get ( name_scenario, 'no data' )
- andsetthevaluesintheloopbythenameoftheobject
- toinstallatagroupaddressyouneedtouse
- light.addressinsteadoflight.nameiftype ( lights ) == 'string'thenalert ( 'No data' )
endlog ( type ( lights ) )
iftype ( lights ) == 'table'thenforindex, lightinipairs ( lights ) dolog ( light.name, light.data )
grp.write ( light.name, light.data )
endendendendend
The principle of the script :
We get the script name from the function parameters - event.dst.
We determine the mode of operation of the system. If the learn_mode variable is 1, then the learning mode is on and writing to the script occurs, if the variable is 0, then the learning mode is off and scripts will be launched.
If the record, then we get all the objects of the system that have the tag (tag) "light" and save it under the name of the script.
If the launch, then by the name of the script load the list of objects, and send commands to the system according to the loaded list of objects.
Using the script: After all group addresses and scripts are installed, the display of objects participating in the scripts, the script call buttons and the learning mode enable button can be displayed in any visualization system, such as built-in EVIKA LogicMachine, as well as any other such as iRidium Mobile. Moreover, you can do without visualization at all by linking these addresses to really existing switches or touch panels.
To record scripts, the user turns on the 'learn_mode' object, and after that selects which fixtures should be turned on, which ones are turned off and clicks on the script button. Writes a sequence of objects to memory. After disables the object 'learn_mode'. Now when you click on the script button, the script starts.
(18.12.2019, 13:49)Daniel. Wrote: User can edit and save existing scene, he can't really make new one. We are adding such functionality to Mosaic right now.