commandArray = {} --Fonction trouvée sur http://easydomoticz.com/forum/viewtopic.php?f=10&t=7147 function getDevNameByIdx(devIdx) for i, v in pairs(otherdevices_idx) do if v == devIdx then return i end end return 0 end function logMessage (TheMessage) year = tonumber(os.date("%Y")); month = tonumber(os.date("%m")); day = tonumber(os.date("%d")); hour = tonumber(os.date("%H")); minutes = tonumber(os.date("%M")); seconds = tonumber(os.date("%S")); if (string.len(month) == 1) then month = "0" .. month end if (string.len(day) == 1) then day = "0" .. day end if (string.len(hour) == 1) then hour = "0" .. hour end if (string.len(minutes) == 1) then minutes = "0" .. minutes end if (string.len(seconds) == 1) then seconds = "0" .. seconds end --logtime = year .. " " .. month .. " " .. day .. " " .. hour .. " " .. minutes .. " " .. seconds logtime = year .. month .. day .. " " .. hour .. minutes .. seconds file = io.open("mylog.txt", "a") file:write(logtime .. " " .. TheMessage.."\n") file:close() end varDetecteurChambre = getDevNameByIdx(188) varIDXChauffageChambre = getDevNameByIdx(174) if (devicechanged[varIDXChauffageChambre] == 'On' ) then logMessage("Allumage du chauffage de la chambre") if otherdevices[varDetecteurChambre] == 'Open' then logMessage("Allumage du chauffage de la chambre alors que la fenêtre était ouverte. On éteint") commandArray[varIDXChauffageChambre]='Off' end end return commandArray