Aller au contenu
Rem's

Problème Scène

Recommended Posts

Bonjour à tous,

Je m'en sors pas avec cette scène !! C'est la porte d'entrée, avec la journée découpée en variable.

J'ai beau bidouiller, je n'ai que des erreurs :

 

[DEBUG] 23:28:48: 2020-02-11 23:28:48.363989 [ fatal] Unknown exception: /opt/fibaro/scenes/100.lua:51: expected near 'elseif'

 

Voici ma scène, si quelqu'un aurait la gentillesse de la corriger ... D'avance merci du coup de main.

--[[
%% properties
772 value
Jour-Nuit
%% globals
--]]
 
-- Ce scénario sera executé uniquement à l'ouverture / fermeture
-- du décteur de porte ID 750 (porte d'entrée)

local door = 772
local light = 459 -- Spots hall
-- local startSource = fibaro:getSourceTrigger();

local heure = os.date("%R");
date = os.date("%d/%m/%Y");
local Message = string.format("Lancement du %s a %s", date, heure)
    fibaro:debug(Message)

-- local heure = string.format(os.date("%H"), "%2d")..string.format(os.date("%M"), "%2d")
-- local heureValable = heure >= "1830" or heure < "2115"
local enAlerte = (tonumber(fibaro:getValue(door, "value")) > 0)
local heureValable = fibaro:getGlobalValue("Jour-Nuit")== ("Jour")
local heureValable1 = fibaro:getGlobalValue("Jour-Nuit")== ("Matin")
local heureValable2 = fibaro:getGlobalValue("Jour-Nuit")== ("Midi")
local heureValable3 = fibaro:getGlobalValue("Jour-Nuit")== ("Après-midi")
local heureValable4 = fibaro:getGlobalValue("Jour-Nuit")== ("Soir")
local heureValable5 = fibaro:getGlobalValue("Jour-Nuit")== ("Soirée")
local heureValable6 = fibaro:getGlobalValue("Jour-Nuit")== ("Nuit")

if enAlerte and heureValable -- Jour --
then
  fibaro:startScene(370);
     fibaro:call(659, "turnOn") -- Lampe boule
       fibaro:sleep(15*1000);
     fibaro:call(659, "turnOff")
  fibaro:call(592, "turnOff") -- Plante 1
  fibaro:call(593, "turnOff") -- Plante 2
  
if fibaro:getGlobalValue("TV")== ("On")
    then
    fibaro:call(56, "pressButton", "1")
      fibaro:debug("TV extinction")
    else
    fibaro:debug("TV déjà éteinte")
    
  fibaro:debug("Porte ouverte Jour")
    end
  end

  elseif enAlerte and heureValable1 -- Matin --
  then
  fibaro:call(401, "pressButton", "8") -- Annonce Petula
  fibaro:call(light, "turnOn"); -- Spots Hall
     fibaro:debug("Porte ouverte matin")
  else
  fibaro:call(light, "turnOff"); -- Spot Hall
  
  elseif enAlerte and heureValable2 -- Midi --
then
     fibaro:debug("Porte ouverte à midi")

  elseif enAlerte and heureValable3 -- Après-midi --
then
     -- fibaro:call(401, "pressButton", "8") -- Annonce Petula
       fibaro:debug("Porte ouverte à Après-midi")

  elseif enAlerte and heureValable4 -- Soir --
then
     fibaro:debug("Porte ouverte le soir")

  elseif enAlerte and heureValable5 -- Soirée
then
     fibaro:debug("Porte ouverte en soirée")

  elseif enAlerte and heureValable6 -- Nuit --
then
fibaro:call(659, "turnOn") -- Lampe boule
else
fibaro:sleep(15*1000);
fibaro:call(659, "turnOff") -- Lampe boule
fibaro:debug("Porte fermée")

     fibaro:debug("Porte ouverte la nuit") -- Nuit --
  
else
    -- porte fermée
    -- fibaro:call(light, "turnOff");
     fibaro:debug("Porte fermée")
   end
end

Partager ce message


Lien à poster
Partager sur d’autres sites

il faut que tu fasses mieux tes indentations...

Je l’ai fait et y a des heures qui ressortent si tu regardes bien.

Tes boucles IF THEN ELSE ne sont juste, d’où le bug...

 

y a un ELSEIF qui se promène tous seul, un ELSEIF qui suit un ELSE, 2 ELSE qui se suivent, et à la fin 2 END... on en perd le nord :) 

if enAlerte and heureValable then
    fibaro:startScene(370);
    fibaro:call(659, "turnOn") -- Lampe boule
    fibaro:sleep(15*1000);
    fibaro:call(659, "turnOff")
    fibaro:call(592, "turnOff") -- Plante 1
    fibaro:call(593, "turnOff") -- Plante 2
  
    if fibaro:getGlobalValue("TV")== ("On") then
        fibaro:call(56, "pressButton", "1")
        fibaro:debug("TV extinction")
    else
        fibaro:debug("TV déjà éteinte")
        fibaro:debug("Porte ouverte Jour")
    end
end

elseif enAlerte and heureValable1 then
    fibaro:call(401, "pressButton", "8") -- Annonce Petula
    fibaro:call(light, "turnOn"); -- Spots Hall
    fibaro:debug("Porte ouverte matin")
else
    fibaro:call(light, "turnOff"); -- Spot Hall
    elseif enAlerte and heureValable2 -- Midi --
then
    fibaro:debug("Porte ouverte à midi")
elseif enAlerte and heureValable3 then
    -- fibaro:call(401, "pressButton", "8") -- Annonce Petula
    fibaro:debug("Porte ouverte à Après-midi")
elseif enAlerte and heureValable4 then
    fibaro:debug("Porte ouverte le soir")
elseif enAlerte and heureValable5 then
    fibaro:debug("Porte ouverte en soirée")
elseif enAlerte and heureValable6 then
    fibaro:call(659, "turnOn") -- Lampe boule
else
    fibaro:sleep(15*1000);
    fibaro:call(659, "turnOff") -- Lampe boule
    fibaro:debug("Porte fermée")
    fibaro:debug("Porte ouverte la nuit") -- Nuit --
else
    -- porte fermée
    -- fibaro:call(light, "turnOff");
     fibaro:debug("Porte fermée")
end
end

 

Modifié par jjacques68

Partager ce message


Lien à poster
Partager sur d’autres sites

Je suis arrivé à la refaire tourner, je fais un peu de ménage et je reviens vers toi ... si tu veux bien me corriger !!

 

Merci du coup de main

Partager ce message


Lien à poster
Partager sur d’autres sites

×