Author Topic: Scene Load vers Lua load  (Read 103 times)

Offline ZW-Tom

  • Jr. Member
  • **
  • Posts: 52
  • Karma: +4/-1
Scene Load vers Lua load
« on: May 25, 2018, 05:05:25 pm »
Has anyone else done this?

A scene in Vera does not get loaded into Vera until it is triggered or called. Without developing Lua files that load with startup, I have a few scenes the are loaded with the Lua startup. I do this because it reduces the number of scenes I have that do basically the same thing with different triggers.
In the Startup Lua I put the following with a delay to allow primary Lua to load first:
-- LUA STARTUP
--  LOAD MY SCENE IN 15 seconds
function int_ld() -- FUNCTION TO RUN SCENE
luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = 25}, 0)
end
-- INIT LUA LOAD
luup.call_delay('int_ld', 15) -- INIT IN 15 SECONDS
-- END LUA STARTUP CODE
-------------------------------------------------------------
I write LUUP code for a scene that looks like this:
SCENE NAME: Alarm Triggers / SCENE ID: 25
SCENE LUUP CODE:
-- LUUP START
function trigger_aa()
 -- do something
end
function trigger_bb()
 -- do something
end
function trigger_cc()
 -- do something
end
-- SETUP VARIABLE WATCH TRIGGERS:
luup.variable_watch("trigger_aa", MSID, "Tripped", 100) -- WINDOW-1 TRIGGER
luup.variable_watch("trigger_bb", MSID, "Tripped", 101) -- WINDOW-2 TRIGGER
luup.variable_watch("trigger_CC", MSID, "Tripped", 102) -- WINDOW-1 TRIGGER
-- LUUP END

Any comments?
Tom