J'ai donc fait ceci :
Code : Tout sélectionner
-- chargement des modules
package.path = package.path..";/home/nico/domoticz/scripts/lua/?.lua"
require "modules"
--recuperation de luminositée exter
Lux = otherdevices_svalues['Luminosite Exterieur']:match("([^;]+)")
Lux = tonumber(Lux)
--depuis combien de temps l'alarme est eteinte
t1 = os.time()
s = otherdevices_lastupdate['Alarme']
-- returns a date time like 2013-07-11 17:23:12
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
commandArray = {}
--time difference
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = (os.difftime (t1, t2))
--print('anneee : '..year)
--print('month : '..month)
--print('day : '..day)
--print('hour : '..hour)
--print('minutes : '..minutes)
--print('seconds : '..seconds)
--print('t1 : '..t1)
--print('t2 : '..t2)
--print('s : '..s)
--print('difference : '..difference)
if ((otherdevices['Alarme'] == 'Off' and difference > 5 and difference < 600) and (devicechanged['Porte escalier etage'] and Lux <= 300)) then
--allumage
switchOn('Appliques',95)
switchOn('Eclairage Cuisine')
switchOn('Lumiere Salon')
end
return commandArray