Aller au contenu

Recommended Posts

Voici un script de rafal.m repris sur le forum officiel.

 

Ce script permet de basé l'éclairage automatique d'une salle de bain, toilette ... Sur l'ouverture d'une porte pour un fgk-101.

Je n'ai pas retesté ce script depuis les modifications de l'alarme, je l'ai modifier pour utiliser une variable globale.

-- NOTICE TO CHANGE DEVICES ID's:
--[[
%% properties
7 value
17 value
%% globals
--]]

-- BATHROOM SCENE FUNCTIONALITY:
-- No extra Global variables needed!
-- Automatic light depending of opening and closing door
-- Time to enter - detecting another situations, like cleaning bathroom

-- NOTICE TO CHANGE DEVICES ID's:
doorID = 7;
lightID = 17;

-- time to enter, longer time will detect as another situation, like: cleaning
timeToEnter = 10;

local light = fibaro:getValue(lightID, 'value');
local door = fibaro:getValue(doorID, 'value');
local armed, lastArmed = fibaro:get(doorID, 'armed');
local trigger = fibaro:getSourceTrigger();

if (fibaro:countScenes()>1) then
  fibaro:debug('Kill second scene!');
  fibaro:abort();
end

if (trigger['type']=='property') then

  -- door trigger
  if (trigger['deviceID']==tostring(doorID)) then
   
    -- door opened
    if (door=='1') then
 
      fibaro:debug('Door opened.');
     
      if (armed=='0') then
        fibaro:call(lightID, 'turnOn');
        fibaro:call(doorID, 'setArmed', '1');
        fibaro:call(doorID, 'setArmed', '0');
        fibaro:debug('Light on!');
      end
 
    -- door closed
    elseif (door=='0') then

      fibaro:debug('Door closed.');
     
      if (armed=='1' or (os.time()-lastArmed)>=timeToEnter) then
        fibaro:call(lightID, 'turnOff');
        fibaro:call(doorID, 'setArmed', '0');
        fibaro:debug('Light off, room empty!');
      else
        fibaro:call(doorID, 'setArmed', '1');
        fibaro:debug('Someone inside!');
      end
 
    end
 
  -- light manual
  elseif (trigger['deviceID']==tostring(lightID) and (os.time()-lastArmed)>0) then

    -- light manual off
    if (light=='0') then
      if (door=='1') then
        -- when door are opened
        fibaro:call(doorID, 'setArmed', '1');
      else
        -- when door are closed
        fibaro:call(doorID, 'setArmed', '0');
      end
      fibaro:debug('Light manual off!');
    -- light manual on
    elseif (light=='1') then
      fibaro:call(doorID, 'setArmed', '1');
      fibaro:debug('Light manual on, arming...');
    end
   
  end
 
end
Modifié par moicphil
Je me suis permi de modifié le titre (je l'ai passé en francais ) ;-)
  • Upvote 1

Partager ce message


Lien à poster
Partager sur d’autres sites

Superbe réalisation, à  l'ouverture et à  la fermeture, les informations debug, c'est super pratique.

En revanche, le script, comme tu l'avais supposé, déclenche l'alarme, ca fout un bordel et envoie un push (message d'erreur de la box).

 

Est-il possible d'adapter ton script aux nouvelles fonctions de notre bel HC2.

 

Merci pour tes infos.

Partager ce message


Lien à poster
Partager sur d’autres sites

C'est malin, quand tu ouvre la porte, il l'arme et la désarme de suite. Cela pour savoir quand elle a été ouverte la dernière fois (lastArmed).

Par contre si tu as une alarme... Quel bordel... Lol.

Partager ce message


Lien à poster
Partager sur d’autres sites

×