Script en boucle

Forum dédié aux problématiques concernant les scripts pour DomoticZ.
Entourez votre code et les logs avec les balises nommées code grâce au bouton <\>.
Sopalin
Messages : 97
Inscription : 04 juil. 2016, 10:07

Script en boucle

Message par Sopalin »

Hello tout le monde je viens vers vous suite à un soucis comportement bizarre sur l'un de mes script. A l'ouverture de ma porte d'entrée, plusieurs actions sont réalisées. Cependant le script se lance plusieurs fois en boucle avant de s'arrêter et je commence à caler sur l'origine.
J'ai un contacteur de porte qui passe à On ou Off et le device Présence est un switch virtuel.

Voici le script :

Code : Tout sélectionner

dofile('/home/pi/domoticz/scripts/lua/modules.lua')

commandArray = {}
time = os.date("*t")
if (otherdevices['Porte Entrée'] == 'Open' and otherdevices['Présence'] == 'Off') then
    print("Ouverture Maison")
    
    --commandArray['Maison']='On'
    switchOn('Maison')
    if (time.hour > 7 and time.hour < 21) then
      print("Ouverture Volet")    
      -- Ouverture du volet roulant du salon
      switchOff('Volet Salon')
      switchOff('Volet Bureau 1')
      switchOff('Volet Bureau 2')
      switchOff('Volet Chambre')
      --commandArray['Volet Salon']='Off'
      --commandArray['Volet Bureau 1']='Off'
      --commandArray['Volet Bureau 2']='Off'
      --commandArray['Volet Chambre']='Off'
     end

    sWeatherUV = otherdevices_svalues['Lux']
    --minutesnow = timenow.min + timenow.hour * 60
    uv = tonumber(sWeatherUV)

    -- Allumage des lumières si UV inférieur à 1000
    if (uv < 1000) then
        print("Allumage Lumières") 
        switchOn('Lampe_Verre',100)
        switchOn('Lampe_Blanche',100)
        --commandArray['Lampe_Verre']='Set Level 100'
        --commandArray['Lampe_Blanche']='Set Level 100'
    end
    switchOn('Présence')
   --commandArray['Présence']='On'
   --Pushbullet("porte entrée;alerte")
end 
 
return commandArray
Voici les logs :

Code : Tout sélectionner

2018-04-13 19:02:38.418 LUA: Ouverture Maison
2018-04-13 19:02:38.430 LUA: Ouverture Volet
2018-04-13 19:02:37.752 (RFXcom) Lighting 2 (Porte Entrée)
2018-04-13 19:02:39.016 (RFXcom) Lighting 2 (Porte Entrée)
2018-04-13 19:02:39.490 User: Admin initiated a switch command (57/Maison/On)
2018-04-13 19:02:39.510 LUA: Ouverture Maison
2018-04-13 19:02:39.516 LUA: Ouverture Volet
2018-04-13 19:02:39.491 (Dummy For Virtual) Light/Switch (Maison)
2018-04-13 19:02:39.780 User: Admin initiated a switch command (61/Volet Salon/Off)
2018-04-13 19:02:39.794 LUA: Ouverture Maison
2018-04-13 19:02:39.800 LUA: Ouverture Volet
2018-04-13 19:02:39.780 (RFXcom) RFY (Volet Salon)
2018-04-13 19:02:39.860 User: Admin initiated a switch command (60/Volet Bureau 1/Off)
2018-04-13 19:02:39.885 LUA: Ouverture Maison
2018-04-13 19:02:39.892 LUA: Ouverture Volet
2018-04-13 19:02:39.860 (RFXcom) RFY (Volet Bureau 1)
2018-04-13 19:02:40.052 User: Admin initiated a switch command (59/Volet Bureau 2/Off)
2018-04-13 19:02:40.067 LUA: Ouverture Maison
2018-04-13 19:02:40.073 LUA: Ouverture Volet
2018-04-13 19:02:40.053 (RFXcom) RFY (Volet Bureau 2)
2018-04-13 19:02:40.245 User: Admin initiated a switch command (62/Volet Chambre/Off)
2018-04-13 19:02:40.260 LUA: Ouverture Maison
2018-04-13 19:02:40.266 LUA: Ouverture Volet
2018-04-13 19:02:40.246 (RFXcom) RFY (Volet Chambre)
2018-04-13 19:02:40.456 User: Admin initiated a switch command (17/Présence/On)
2018-04-13 19:02:40.457 (Dummy For Virtual) Lighting 1 (Présence)
2018-04-13 19:02:40.869 User: Admin initiated a switch command (57/Maison/On)
2018-04-13 19:02:40.870 (Dummy For Virtual) Light/Switch (Maison)
2018-04-13 19:02:41.085 User: Admin initiated a switch command (61/Volet Salon/Off)
2018-04-13 19:02:41.086 (RFXcom) RFY (Volet Salon)
2018-04-13 19:02:41.300 User: Admin initiated a switch command (60/Volet Bureau 1/Off)
2018-04-13 19:02:41.300 (RFXcom) RFY (Volet Bureau 1)
2018-04-13 19:02:41.514 User: Admin initiated a switch command (62/Volet Chambre/Off)
2018-04-13 19:02:41.515 (RFXcom) RFY (Volet Chambre)
2018-04-13 19:02:41.729 User: Admin initiated a switch command (59/Volet Bureau 2/Off)
2018-04-13 19:02:41.730 (RFXcom) RFY (Volet Bureau 2)
2018-04-13 19:02:41.954 User: Admin initiated a switch command (17/Présence/On)
2018-04-13 19:02:41.954 (Dummy For Virtual) Lighting 1 (Présence)
2018-04-13 19:02:42.169 User: Admin initiated a switch command (57/Maison/On)
2018-04-13 19:02:42.170 (Dummy For Virtual) Light/Switch (Maison)
2018-04-13 19:02:42.393 User: Admin initiated a switch command (61/Volet Salon/Off)
2018-04-13 19:02:42.394 (RFXcom) RFY (Volet Salon)
2018-04-13 19:02:42.609 User: Admin initiated a switch command (60/Volet Bureau 1/Off)
2018-04-13 19:02:42.609 (RFXcom) RFY (Volet Bureau 1)
2018-04-13 19:02:42.858 User: Admin initiated a switch command (59/Volet Bureau 2/Off)
2018-04-13 19:02:42.859 (RFXcom) RFY (Volet Bureau 2)
2018-04-13 19:02:43.084 User: Admin initiated a switch command (62/Volet Chambre/Off)
2018-04-13 19:02:43.084 (RFXcom) RFY (Volet Chambre)
2018-04-13 19:02:43.320 User: Admin initiated a switch command (17/Présence/On)
2018-04-13 19:02:43.321 (Dummy For Virtual) Lighting 1 (Présence)
2018-04-13 19:02:43.563 User: Admin initiated a switch command (57/Maison/On)
2018-04-13 19:02:43.564 (Dummy For Virtual) Light/Switch (Maison)
2018-04-13 19:02:43.834 User: Admin initiated a switch command (61/Volet Salon/Off)
2018-04-13 19:02:43.834 (RFXcom) RFY (Volet Salon)
2018-04-13 19:02:44.051 User: Admin initiated a switch command (59/Volet Bureau 2/Off)
2018-04-13 19:02:44.051 (RFXcom) RFY (Volet Bureau 2)
2018-04-13 19:02:44.267 User: Admin initiated a switch command (60/Volet Bureau 1/Off)
2018-04-13 19:02:44.268 (RFXcom) RFY (Volet Bureau 1)
2018-04-13 19:02:44.484 User: Admin initiated a switch command (62/Volet Chambre/Off)
2018-04-13 19:02:44.484 (RFXcom) RFY (Volet Chambre)
2018-04-13 19:02:44.710 User: Admin initiated a switch command (17/Présence/On)
2018-04-13 19:02:44.714 (Dummy For Virtual) Lighting 1 (Présence)
2018-04-13 19:02:44.930 User: Admin initiated a switch command (57/Maison/On)
2018-04-13 19:02:44.930 (Dummy For Virtual) Light/Switch (Maison)
2018-04-13 19:02:45.148 User: Admin initiated a switch command (61/Volet Salon/Off)
2018-04-13 19:02:45.148 (RFXcom) RFY (Volet Salon)
2018-04-13 19:02:45.365 User: Admin initiated a switch command (59/Volet Bureau 2/Off)
2018-04-13 19:02:45.366 (RFXcom) RFY (Volet Bureau 2)
2018-04-13 19:02:45.583 User: Admin initiated a switch command (62/Volet Chambre/Off)
2018-04-13 19:02:45.583 (RFXcom) RFY (Volet Chambre)
2018-04-13 19:02:45.801 User: Admin initiated a switch command (60/Volet Bureau 1/Off)
2018-04-13 19:02:45.805 (RFXcom) RFY (Volet Bureau 1)
2018-04-13 19:02:46.028 User: Admin initiated a switch command (17/Présence/On)
2018-04-13 19:02:46.028 (Dummy For Virtual) Lighting 1 (Présence)
2018-04-13 19:02:46.245 User: Admin initiated a switch command (57/Maison/On)
2018-04-13 19:02:46.249 (Dummy For Virtual) Light/Switch (Maison)
2018-04-13 19:02:46.467 User: Admin initiated a switch command (61/Volet Salon/Off)
2018-04-13 19:02:46.471 (RFXcom) RFY (Volet Salon)
2018-04-13 19:02:46.694 User: Admin initiated a switch command (60/Volet Bureau 1/Off)
2018-04-13 19:02:46.697 (RFXcom) RFY (Volet Bureau 1)
2018-04-13 19:02:46.803 User: Admin initiated a switch command (59/Volet Bureau 2/Off)
2018-04-13 19:02:46.805 (RFXcom) RFY (Volet Bureau 2)
2018-04-13 19:02:46.940 User: Admin initiated a switch command (17/Présence/On)
2018-04-13 19:02:46.940 (Dummy For Virtual) Lighting 1 (Présence)
thier
Messages : 807
Inscription : 26 sept. 2015, 10:32
Localisation : charente

Re: Script en boucle

Message par thier »

J'essaierai u script du type device avec la fonction otherdeviceschanged . Comme ça le script ne se lancerai que sur le passage du détecteur de fermer vers ouvert
PI3+, Buster, Domoticz V2020.2, rflink, zwave, chauffage piloté par qubino, sondes oregon et Vil1d, boite aux lettres détection passage facteur, volets roulants qubino fibaro.
Sopalin
Messages : 97
Inscription : 04 juil. 2016, 10:07

Re: Script en boucle

Message par Sopalin »

C'est une poste, car là tant que la porte est ouverte, il lance les commandes d'ouverture.

Je vais essayer en utilisant otherdeviceschanged ce soir.
Répondre