Aller au contenu

Bouton Virtuel Action En Fonction De Plage Horaire


SimonT

Messages recommandés

Bonjour,

 

J'aimerai savoir si il est possible sur un bouton virtuel codé en LUA de le faire fonctionner en fonction de plage horaire

 

Exemple:

 

Entre 5H et 16H59

il lance la request HTTP 1

Entre 17H et 4H59

il lance la request HTTP 2

 

Merci

Lien vers le commentaire
Partager sur d’autres sites

Salut,

 

Comme ceci

local currentDate = os.date("*t")
 
if ((string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) >= "05:00") and (string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) <= "16:59")) then
requete HTTP1
elseif
requete HTTP2
end
Lien vers le commentaire
Partager sur d’autres sites

si je fais exactement ce bouton mais ca ne marche pas

local currentDate = os.date("*t")
if ((string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) >= "04:00") and (string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) <= "9:00")) then
HC2 = Net.FHttp("192.168.1.xx", yyyy);
HC2:GET("/api/rest/speech/tts?text=Toutes%20vos%20configurations%20du%20matin%20sont%20activ%C3%A9")
elseif
HC2 = Net.FHttp("192.168.1.xx", yyyy);
HC2:GET("/api/rest/speech/tts?text=Toutes%20vos%20configurations%20sont%20activ%C3%A9")
end

J'ai cette erreur dans le debug

[ERROR] 08:13:32: line 7:'then' expected near '='

Lien vers le commentaire
Partager sur d’autres sites

Je pense qu'il manque un bout de quelque chose.

A mon avis une instance d'authentification.

 

Mais je ne suis pas expert...

 

HC2 = Net.FHttp("192.168.1.xx")
HC2:setBasicAuthentication("admin","admin")

Quoi que non finalement je ne pense pas que ce soit ça...

Pour un bouton VD qui lance du tts...ça m'étonne...

 

Attends un expert qui passera par là  c'est mieux :lol:

Lien vers le commentaire
Partager sur d’autres sites

meme en m'inspirant de ca

 

http://www.lua.org/pil/4.3.1.html

 

ca ne marche pas cela prend que la première request http

local currentDate = os.date("*t")
if ((string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) >= "04:00") and (string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) <= "5:00")) then
HC2 = Net.FHttp("192.168.1.xx", yyyy);
HC2:GET("/api/rest/speech/tts?text=Alarme%20d%C3%A9sActiv%C3%A9%20%20%20bienvenue%20chez%20moi")

elseif ((string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) >= "16:00") and (string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) <= "18:00")) then
HC2 = Net.FHttp("192.168.1.xx", yyyy);
HC2:GET("/api/rest/speech/tts?text=Alarme%20d%C3%A9sActiv%C3%A9%20%20%20bienvenue%20chez%20toi")

else
HC2 = Net.FHttp("192.168.1.xx", yyyy);
HC2:GET("/api/rest/speech/tts?text=Alarme%20d%C3%A9sActiv%C3%A9%20%20%20bienvenue%20chez%20fukers")
end
Lien vers le commentaire
Partager sur d’autres sites

×
×
  • Créer...