Hi all!!
Thank you all for this forum and all nice people that helping eachother out.
Now its my turn to ask a question regarding LUA scripting, a script that makes my system to stall within 24h
What the script basicaly does is that it checks if doors, windows, motionsencors etc is open or closed and then send it to a QA but also to a global value from a standard LUA scene.
I am running the QA on diffrent screens in my home to so i get a nice view of what´s going on. The global value i pick up then i am arming the house and sending it to a a TTS-script.
Always nice to hear a voice that tells me that a window is open etc... when i am leaving.
But i think something is draining resources, i have tried to only activate the script via Conditions and Triggers, but also via a loop with diffrent sleep times.
It does not say in Diagnostics that i am out of recourses
se my sample below short version (The script works fine but after aprox 24h HC3 stalls or not working as expected ).
How can i do it better ?
::BEGIN::
local var = {};
local debug = 1;
----------------WINDOWS------------
local Windows = "";
local WindowsAlarm = "";
local WindowsLiving = "";
local WindowsLivingAlarm = "";
local WLiving = fibaro.getValue(249, "value");
--...and 6 more sencors
----------------DOORS------------
local Doors = "";
local DoorsAlarm = "";
local Freezer = "" ;
local FreezerAlarm = "" ;
local DFreezer = fibaro.getValue(355, "value") ;
--...and 10 more sencors
----------------MOTION----------
local Motion = "";
local MotionAlarm = "";
local Kitchen = "";
local KitchenAlarm = "";
local MKitchen = fibaro.getValue(21, "value");
--...and 7 more sencors
----------------Switches 1st and 2nd floor----
--...About 30 switches
----------------TEMPS----------------------
--... collecting temps round house
----------------Secure--------------------
local SecureFrontdoor = " "
local Parm = " "
-- ...Checking if frontdoor is locked and if it is armed etc...
----------------Garage--------------------
-- ... same with garage
local Garage = "Garage : " ..IR ..Outlet ..Mainlight ..Port
----------------Setting Variable---------
if WLiving == true then WindowsLiving = "Livingroom" WindowsLivingAlarm = "Vardagsrums fönster, " end;
if DFreezer == true then Freezer= "Frys, " FreezerAlarm = "Frysdörr. " end ;
if MKitchen == true then Kitchen = "Köket, " KitchenAlarm = "Rörelse i köket, " end;
if fibaro.getValue(30, "value") == true then sink = fibaro.getName(30)..", " end;
-------------CONSOLIDATE ---------------
Windows = "Fönster: " ..WindowsLiving .." " .. Bathroom; -- for screens QA
var.WindowsAlarm = WindowsLivingAlarm ..BathroomAlarm;
Doors = "Dörrar: " ..Refrigerator .." "..StoreTrash ; -- for screens QA
var.DoorsAlarm = RefrigeratorAlarm ..StoreTrashAlarm ;
Motion = "Rörelse:" ..Kitchen .." "..Shower ; -- for screens QA
var.MotionAlarm = KitchenAlarm ..ShowerAlarm ;
-- .. and some more...
-------------SEND UPDATES----------------------------------------------------------------------
fibaro.call(103,"updateView","windows","text", Windows);
fibaro.call(103,"updateView","doors","text", Doors)
fibaro.call(103,"updateView","detectors","text", Motion);
fibaro.call(103,"updateView","avgtemp","text", avgtemp) ;
fibaro.call(103,"updateView","secure","text", SecureFrontdoor .." " ..Parm );
fibaro.call(103,"updateView","garage","text", Garage) ;
fibaro.call(103,"updateView","first","text",first) ;
fibaro.call(103,"updateView","second","text",second) ;
fibaro.setGlobalVariable('Status',json.encode(var))
-------------DEBUG--------------
------Loop Me ------------------
fibaro.sleep(5*1000);
goto BEGIN