first commit
This commit is contained in:
89
lua/old/script_time_tele.old
Executable file
89
lua/old/script_time_tele.old
Executable file
@@ -0,0 +1,89 @@
|
||||
require "scripts/lua/functions"
|
||||
|
||||
--Initialise la commande de retour finale
|
||||
commandArray={}
|
||||
|
||||
|
||||
|
||||
--Prefixe pour les sorties de log
|
||||
prefixe="(PING) "
|
||||
|
||||
--recupere les minutes
|
||||
time=os.time()
|
||||
minutes=tonumber(os.date('%M',time))
|
||||
heures=tonumber(os.date('%H',time))
|
||||
|
||||
if (heures >= 22 and (minutes % 10 == 0)) then
|
||||
|
||||
-- ------------------------------
|
||||
--Tableau des périphérique"pinguer"
|
||||
-- Key = adresse ip pinguer
|
||||
-- Value = périphérique virtueswitcher
|
||||
-- ------------------------------
|
||||
local ping={}
|
||||
ping['192.168.0.17']='TeleChambre'
|
||||
ping['akhenaton']='Akhenaton'
|
||||
|
||||
AuMoinsUnPing=false
|
||||
-- ------------------------------
|
||||
--pour chaque entree du tableau
|
||||
-- ------------------------------
|
||||
for ip, switch in pairs(ping) do
|
||||
|
||||
--Le Ping ! : -c1 = Un seul ping , -w1 délai d'une seconde d'attente de réponse
|
||||
ping_success=os.execute('ping -c1 -w1 '..ip)
|
||||
|
||||
-- ------------------------------
|
||||
--Si le ping a répondu
|
||||
-- ------------------------------
|
||||
if ping_success then
|
||||
AuMoinsUnPing=true
|
||||
|
||||
debug(prefixe.."ping success "..switch)
|
||||
|
||||
-- ------------------------------
|
||||
--si le switch etait sur off on l'allume
|
||||
-- ------------------------------
|
||||
switchIfNeeded(switch, 'On')
|
||||
--if(otherdevices[switch]=='Off') then
|
||||
-- commandArray[switch]='On'
|
||||
--end
|
||||
else
|
||||
|
||||
-- ------------------------------
|
||||
--Si pas de réponse
|
||||
-- ------------------------------
|
||||
debug(prefixe.."ping sans reponse "..switch)
|
||||
-- ------------------------------
|
||||
--si le switch etait sur oN on l'eteint
|
||||
-- ------------------------------
|
||||
switchIfNeeded(switch, 'Off')
|
||||
--if(otherdevices[switch]=='On') then
|
||||
-- commandArray[switch]='Off'
|
||||
--end
|
||||
end
|
||||
end
|
||||
|
||||
if AuMoinsUnPing then
|
||||
else
|
||||
-- ------------------------------
|
||||
-- Extinction halogene
|
||||
-- ------------------------------
|
||||
debug("Tout le monde est couché")
|
||||
-- if(otherdevices["Salon_Halogene"]=='On')
|
||||
|
||||
switchIfNeeded("Salon_Halogene",'Off')
|
||||
switchIfNeeded("LumiereTele",'Off')
|
||||
switchIfNeeded("Lampe_Buffet",'Off')
|
||||
-- end
|
||||
if(otherdevices["Volet droit"]=='On') then
|
||||
debug("Attention le volet droit est ouvert")
|
||||
end
|
||||
if(otherdevices["Volet gauche"]=='On') then
|
||||
debug("Attention le volet gauche est ouvert")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
return commandArray
|
||||
|
||||
Reference in New Issue
Block a user