J'ai une erreur :
2017-02-16 20:07:00.209 Error: EventSystem: in Motion test: [string "time = os.date("*t") ..."]:19: attempt to index global 'devicechanged' (a nil value)
ligne 19 c'est
if (devicechanged['Xiaomi Door Sensor'] == 'Open' and (timeofday['Nighttime'] or otherdevices['Lux entrée'] == 'On') and absence > 600) then
mais je ne vois pas ce qui block, car j'ai bien remplacé le nom des module "case sensitive"
Code : Tout sélectionner
time = os.date("*t")
t1 = os.time()
s = otherdevices_lastupdate['Motion entrée']
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)
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
absence = (os.difftime (t1, t2))
commandArray = {}
-- si la porte s'ouvre la nuit ou s'il fait noir
-- et qu'aucun mouvement n'est détecté dans le salon depuis plus de 10 minutes,
-- on allume la lampe
if (devicechanged['Xiaomi Door Sensor'] == 'Open' and (timeofday['Nighttime'] or otherdevices['Lux entrée'] == 'On') and absence > 600) then
commandArray['Scene Détente'] = "On"
elseif (timeofday['Nighttime'] or otherdevices['Lux Salon'] == 'On') and absence > 600 then
commandArray['Scene Détente'] = "On"
end
return commandArray