Aller au contenu

Valeur Alarme Active


Fredric

Recommended Posts

fibaro:debug(ButtonPressed)   le 1 sort bien,

fibaro:debug(statut)   j'ai l'erreur:   line :debug (arg 2), expected 'string const &' got 'function'

 

 

 il ne faut pas que tu te prenne la tête Shad, après tu oseras plus aider quelqu'un de peur que ce soit un truc de fou.

ce code est trop avancé pour mes compétence en Lua, â€‹même si je vois très bien la logique de ton code, je ne connais pas les syntaxes, il est donc très difficile pour moi de faire des corrections.

mais, je compte bien faire un code tout seul un jour!!   

Lien vers le commentaire
Partager sur d’autres sites

je n'arrive à  rien avec ton code, je le mets de coté en attendent que j'ai progressé en Lua,  et j'ai fait le code suivant pour ma scène, ça fonctionne exactement comme je le souhaite mais c'est sur que j'aimerai arriver à  faire fonctionner ton code.

--[[ 
 %% properties 
24 sceneActivation 
 %% globals 
--]] 

 local ButtonPressed = fibaro:getValue(24, "sceneActivation")
 local windowscontrolrelay = {14, 47, 32, 124, 97, 111, 114, 115, 116}; 
 
 if ( tonumber(ButtonPressed) == 1) then
  for i =1, #windowscontrolrelay do
        if (tonumber(fibaro:getValue(windowscontrolrelay[i], "value")) == 0) then
            fibaro:call(windowscontrolrelay[i], "setArmed", "1");
        end
    end
  if ((tonumber(fibaro:getValue(14, 'value'))) == 1) then
	 fibaro:call(149, "pressButton", "1"); 
	 fibaro:call(53, "sendPush", "Le capteur de mouvement est en alerte");
	
    elseif ((tonumber(fibaro:getValue(47, 'value'))) == 1) then
	 fibaro:call(149, "pressButton", "1"); 
	 fibaro:call(53, "sendPush", "La fenêtre le la chambre bleu est ouverte");
		
	elseif((tonumber(fibaro:getValue(32, 'value'))) == 1) then
	 fibaro:call(149, "pressButton", "1"); 
	 fibaro:call(53, "sendPush", "La porte d entrée est ouverte");
	
	elseif ((tonumber(fibaro:getValue(124, 'value'))) == 1) then
	 fibaro:call(149, "pressButton", "1"); 
	 fibaro:call(53, "sendPush", "La fenêtre le la chambre de Marion est ouverte");
	
	elseif ((tonumber(fibaro:getValue(97, 'value'))) == 1) then
	 fibaro:call(149, "pressButton", "1"); 
	 fibaro:call(53, "sendPush", "La fenêtre le la chambre des parents est ouverte");
	
	elseif ((tonumber(fibaro:getValue(111, 'value'))) == 1) then
    fibaro:call(149, "pressButton", "1");      
    fibaro:call(53, "sendPush", "La fenêtre du bureau est ouverte");
	
	elseif ((tonumber(fibaro:getValue(114, 'value'))) == 1) then
	 fibaro:call(149, "pressButton", "1"); 
	 fibaro:call(53, "sendPush", "La fenêtre du salon est ouverte");
	
	elseif ((tonumber(fibaro:getValue(115, 'value'))) == 1) then
	 fibaro:call(149, "pressButton", "1"); 
	 fibaro:call(53, "sendPush", "La porte vitée du salon est ouverte");
	
	elseif ((tonumber(fibaro:getValue(116, 'value'))) == 1) then
	 fibaro:call(149, "pressButton", "1"); 
	 fibaro:call(53, "sendPush", "La porte du garage est ouverte");

	
    elseif ((tonumber(fibaro:getValue(14, 'value'))) == 0) and ((tonumber(fibaro:getValue(47, 'value'))) == 0) and ((tonumber(fibaro:getValue(32, 'value'))) == 0) and ((tonumber(fibaro:getValue(124, 'value'))) == 0) and ((tonumber(fibaro:getValue(97, 'value'))) == 0) and ((tonumber(fibaro:getValue(111, 'value'))) == 0) and ((tonumber(fibaro:getValue(114, 'value'))) == 0) and ((tonumber(fibaro:getValue(115, 'value'))) == 0) and ((tonumber(fibaro:getValue(116, 'value'))) == 0) then
         fibaro:call(53, "sendDefinedPushNotification", "4"); 
         fibaro:call(58, "sendDefinedPushNotification", "4");
        if tonumber(fibaro:getValue(70, "value")) > 0 then
         fibaro:call(70, "turnOff")
         
     end 
         fibaro:debug("button 1 pressed Alarme Activé") 
         fibaro:sleep(3000);
    end
elseif ( tonumber(ButtonPressed) == 2) then
 	fibaro:call(149, "pressButton", "1"); 
    fibaro:call(100, "turnOff");
  
  fibaro:call(53, "sendDefinedPushNotification", "5");
  fibaro:call(58, "sendDefinedPushNotification", "5");  
  fibaro:debug("button 2 Pressed Alarme Désactivé")
  fibaro:sleep(3000);  

 elseif ( tonumber(ButtonPressed) == 3) then 
 fibaro:debug("MiniMote button 3 pressed")
 fibaro:call(57, "open");
 fibaro:call(65, "open");
 fibaro:sleep(3000);   
 elseif ( tonumber(ButtonPressed) == 4) then 
 fibaro:debug("MiniMote button 4 pressed")
 fibaro:call(57, "close");
 fibaro:call(65, "close");
 fibaro:sleep(3000);    
 elseif ( tonumber(ButtonPressed) == 5) then 
 fibaro:call(100, "turnOff") 
 fibaro:debug("MiniMote button 5 pressed / Sirene OFF") 
 fibaro:sleep(3000); 
 elseif ( tonumber(ButtonPressed) == 6) then 
 fibaro:call(100, "turnOn"); 
 fibaro:debug("MiniMote button 6 pressed / Sirene ON") 
 fibaro:sleep(3000); 
 elseif ( tonumber(ButtonPressed) == 7) then 
 fibaro:call(107, "turnOn");
 fibaro:debug("MiniMote button 7 pressed")
 fibaro:sleep(3000);   
 elseif ( tonumber(ButtonPressed) == 8) then 
 fibaro:call(107, "turnOff");
 fibaro:debug("MiniMote button 8 pressed")
 fibaro:sleep(3000);   
 else 
 fibaro:debug("No response") 
 end

Lien vers le commentaire
Partager sur d’autres sites

Bon sa y est je t'ai optimisé une grosse partie de ton plus le tout fonctionnel.

--[[
%% properties
%% globals
--]]

local windowSensor = {14, 47, 32, 124, 111, 114, 115, 116};
local placeSensor = {"salon","Chambre Bleu","Entrée","Chambre de Marion","bureau","Salon","Salon","Garage"};
local startSource = fibaro:getSourceTrigger();

function statutWindows ()
  local statut = "close";
    for i=1, #windowSensor do
      if (tonumber(fibaro:getValue(windowSensor[i], "value")) > 0) then
        statut = "open";
      end
    end
  return statut;
end
     
function alertWindows ()
  local place = nil;
  for i=1, #windowSensor do
    if (tonumber(fibaro:getValue(windowSensor[i], "value")) > 0) then
      if (place == nil) then
        place = placeSensor[i];
      elseif (place ~= nil) then
        place = place .. ", " .. placeSensor[i];
      end
    end
  end
  fibaro:debug("Fenetre(s) ouverte(s): " .. place);
  fibaro:call(53, "sendPush", "Fenetre(s) ouverte(s): " .. place);
end
     
function armedSensor (value)
  for i=1, #windowSensor do
    fibaro:call(windowSensor[i], "setArmed", value);
  end
end  
 
if ( tonumber(ButtonPressed) == 1) then
  statut = statutWindows();
  if (statut == "close") then
    armedSensor(1);
    fibaro:debug("button 1 pressed Alarme Activé");
  elseif (statut == "open") then
    alertWindows();
  end

elseif ( tonumber(ButtonPressed) == 2) then
  armedSensor(0);
  fibaro:call(100, "turnOff");
  fibaro:call(53, "sendDefinedPushNotification", "5");
  fibaro:call(58, "sendDefinedPushNotification", "5");
  fibaro:debug("button 2 Pressed Alarme Désactivé");
   
elseif ( tonumber(ButtonPressed) == 3) then
  fibaro:debug("MiniMote button 3 pressed");
  fibaro:call(57, "open");
  fibaro:call(57, "setValue2", "1");
  fibaro:call(65, "open");
  fibaro:call(65, "setValue2", "1");

elseif ( tonumber(ButtonPressed) == 4) then
  fibaro:debug("MiniMote button 4 pressed");
  fibaro:call(57, "close");
  fibaro:call(57, "setValue2", "0");
  fibaro:call(65, "close");
  fibaro:call(65, "setValue2", "0");

elseif ( tonumber(ButtonPressed) == 5) then
  fibaro:call(100, "turnOff")
  fibaro:debug("MiniMote button 5 pressed / Sirene OFF");
 
elseif ( tonumber(ButtonPressed) == 6) then
  fibaro:call(100, "turnOn");
  fibaro:debug("MiniMote button 6 pressed / Sirene ON");

elseif ( tonumber(ButtonPressed) == 7) then
  fibaro:call(107, "turnOn");
  fibaro:debug("MiniMote button 7 pressed");

elseif ( tonumber(ButtonPressed) == 8) then
  fibaro:call(107, "turnOff");
  fibaro:debug("MiniMote button 8 pressed");

else
  fibaro:debug("No response");
end
fibaro:sleep(60*1000);

Quand j'aurais 5 min je pense que je vais un grand "tuto" pour montrer les possibilité avec la minimote.

  • Upvote 1
Lien vers le commentaire
Partager sur d’autres sites

super Shad :60: , j'ai plus qu'a le personnaliser à  m'a sauce, mais c'est vraiment plus beau que mon code  ;)

ça marche parfaitement, je posterai une fois mis des annotations avec mes paramétrage. 

Lien vers le commentaire
Partager sur d’autres sites

Je me suis permis de reprendre ce code et de le mettre dans les tuto pour la gestion des minimotes.

J'ai également mis un script pour gérer plusieurs ambiances

Lien vers le commentaire
Partager sur d’autres sites

Voila, j'ai pas rajouté grand chose, c'est parfait, j'ai mis mes messages personnalisé.  :D

--[[ 
 %% properties 
24 sceneActivation 
 %% globals 
--]] 

local ButtonPressed = fibaro:getValue(24, "sceneActivation")
local windowSensor = {14, 47, 32, 124, 97, 111, 114, 115, 116};--il suffit de rajouter l'ID d'un module à  la suite
local placeSensor = {"salon est en alerte","La fenêtre le la chambre est ouverte","La porte d entrée est ouverte","La fenêtre le la chambre est ouverte","La fenêtre est ouverte","La fenêtre du bureau est ouverte","salon est ouverte","La porte est ouverte","garage est ouverte"}; --le premier message correspond à  la première ID, le second message à  la seconde ID etc..
local startSource = fibaro:getSourceTrigger();
 
function statutWindows ()
  local statut = "close";
    for i=1, #windowSensor do
      if (tonumber(fibaro:getValue(windowSensor[i], "value")) > 0) then
        statut = "open";
      end
    end
  return statut;
end
     
function alertWindows ()
  local place = nil;
  for i=1, #windowSensor do
    if (tonumber(fibaro:getValue(windowSensor[i], "value")) > 0) then
      if (place == nil) then
        place = placeSensor[i];
      elseif (place ~= nil) then
        place = place .. ", " .. placeSensor[i];
      end
    end
  end
  fibaro:debug("élément ouvert ou en alerte: " .. place);
  fibaro:call(53, "sendPush", "Attention: " .. place);
  fibaro:call(58, "sendPush", "Attention: " .. place);
end
     
function armedSensor (value)
  for i=1, #windowSensor do
    fibaro:call(windowSensor[i], "setArmed", value);
  end
end  
 
if ( tonumber(ButtonPressed) == 1) then
  statut = statutWindows();
  if (statut == "close") then
    armedSensor(1);
    fibaro:call(53, "sendDefinedPushNotification", "4"); 
    fibaro:call(58, "sendDefinedPushNotification", "4");
    fibaro:debug("button 1 pressed Alarme Activé");
  elseif (statut == "open") then
    alertWindows();
  end
 
elseif ( tonumber(ButtonPressed) == 2) then
  armedSensor(0);
  fibaro:call(100, "turnOff");
  fibaro:call(53, "sendDefinedPushNotification", "5");
  fibaro:call(58, "sendDefinedPushNotification", "5");
  fibaro:debug("button 2 Pressed Alarme Désactivé");
   
elseif ( tonumber(ButtonPressed) == 3) then
  fibaro:debug("MiniMote button 3 pressed");
  fibaro:call(57, "open");
  fibaro:call(65, "open");
   
elseif ( tonumber(ButtonPressed) == 4) then
  fibaro:debug("MiniMote button 4 pressed");
  fibaro:call(57, "close");
  fibaro:call(65, "close");
  
elseif ( tonumber(ButtonPressed) == 5) then
  fibaro:call(100, "turnOff")
  fibaro:debug("MiniMote button 5 pressed / Sirene OFF");
 
elseif ( tonumber(ButtonPressed) == 6) then
  fibaro:call(100, "turnOn");
  fibaro:debug("MiniMote button 6 pressed / Sirene ON");
 
elseif ( tonumber(ButtonPressed) == 7) then
  fibaro:call(107, "turnOn");
  fibaro:debug("MiniMote button 7 pressed");
 
elseif ( tonumber(ButtonPressed) == 8) then
  fibaro:call(107, "turnOff");
  fibaro:debug("MiniMote button 8 pressed");
 
else
  fibaro:debug("No response");
end
fibaro:sleep(60*1000);
Lien vers le commentaire
Partager sur d’autres sites

Oui, tout simplement prend ce code

elseif ( tonumber(ButtonPressed) == 7) then
fibaro:call(107, "turnOn");
fibaro:debug("MiniMote button 7 pressed");

 

Rajoute une condition pour sa voir si c'est allumé l'état, et si allumé on éteint sinon on allume.

Et la tu récupère 3 boutons pour autre chose, bon après faut pas t'y perdre dans le nombre de touche XD

Lien vers le commentaire
Partager sur d’autres sites

×
×
  • Créer...