Bonjour, je cherche à programmer des On/Off en fonction de mon agenda google et jusque là ça ne fonctionne que quand j’ai un seul événement dans la journée… Est-il possible que les scénarios lancés soient limités à un nombre de 2 ? Quand je regarde le moteur de tâche (et que je lance un « launch » toutes les 5 secondes, j’ai l’impression de les voir écrasés les uns après les autres, l’id s’incrémentant mais le précédent disparaissant). C’est peut-être une protection de Jeedom ?
Je précise que mon scénario appelé est en « Multi-lancement »
Le code qui lit mon google agenda pour lancer un scénario à deux tags/paramètres (heure et action On/Off):
//Récupération de la liste des événements du jour (plugin installé iCalendar)
$string = cmd::byString('#[Appartement][Google agenda][Perso]#')->execCmd();
$Sc = scenario::byId(22);
if(strlen($string) > 0){
$evenements = explode('||',$string) ;
$nbEvnts = count($evenements);
//log::add('Scenario Arrêt Box Agenda','error','débug : nb evnts '.$nbEvnts);
$cmdTime = '';
if($nbEvnts>0){
foreach ($evenements as &$evnt) {
$infosEvnt = explode(';',$evnt) ;
//On traite l'heure de début (heures de transport en fonction des étiquettes)
if(strpos($infosEvnt[3],'Démos')!==false){
$TimeDebTSP = str_replace(':','',date("H:i", strtotime($infosEvnt[0].":00 -1 hour -30 minutes")));
$TimeFinTSP = str_replace(':','',date("H:i", strtotime($infosEvnt[1].":00 +1 hour 30 minutes")));
}elseif($infosEvnt[3]=='MF' or $infosEvnt[3]=='EC' or $infosEvnt[3]=='SdlP' or $infosEvnt[3]=='AG' or $infosEvnt[3]=='LG' or $infosEvnt[3]=='JC il cantante'){
$TimeDebTSP = str_replace(':','',date("H:i", strtotime($infosEvnt[0].":00 -1 hour")));
$TimeFinTSP = str_replace(':','',date("H:i", strtotime($infosEvnt[1].":00 +1 hour")));
}elseif(strpos($infosEvnt[3],'TAP 18')!==false){
$TimeDebTSP = str_replace(':','',date("H:i", strtotime($infosEvnt[0].":00 -45 minutes")));
$TimeFinTSP = str_replace(':','',date("H:i", strtotime($infosEvnt[1].":00 +45 minutes")));
}elseif($infosEvnt[3]=='JH'){
$TimeDebTSP = str_replace(':','',date("H:i", strtotime($infosEvnt[0].":00 -30 minutes")));
$TimeFinTSP = str_replace(':','',date("H:i", strtotime($infosEvnt[1].":00 +30 minutes")));
}elseif(strpos($infosEvnt[3],'TAP10')!==false){
$TimeDebTSP = str_replace(':','',date("H:i", strtotime($infosEvnt[0].":00 -15 minutes")));
$TimeFinTSP = str_replace(':','',date("H:i", strtotime($infosEvnt[1].":00 +15 minutes")));
}else{
$TimeDebTSP = str_replace(':','',$infosEvnt[0]);
$TimeFinTSP = str_replace(':','',$infosEvnt[1]);
}
if($cmdTime == ''){ //S'il s'agit du premier événement
#Récupérer les tags du scenaraio 'PC Box OnOff'
if(strpos($infosEvnt[3],'@')===false){
//lancer scénario box off
$Tags = $Sc->getTags();
#Ajouter des tags
$Tags['#tagTime#'] = $TimeDebTSP;
$Tags['#tagOnOff#'] = 0;
#Passer les tags à un sous-scenario et le lancer
$Sc->setTags($Tags);
$Sc->launch();
sleep(5);
//log::add('Scenario Box Agenda','error','Lancement PC Box Off : '.$TimeDebTSP);
$scenario->setLog('Lancement PC Box A Off : '.$TimeDebTSP);
}
$cmdTime = $TimeFinTSP;
}else{
// si les événements ne se chevauchent pas (transports compris pour plus tard)
if($TimeDebTSP>$cmdTime){
if(strpos($infosEvnt[3],'@')===false){
//lancer scénario box on (événement précédent)
$Tags = $Sc->getTags();
#Ajouter des tags
$Tags['#tagTime#'] = $cmdTime;
$Tags['#tagOnOff#'] = 1;
#Passer les tags à un sous-scenario et le lancer
$Sc->setTags($Tags);
$Sc->launch();
sleep(5);
//log::add('Scenario Box Agenda','error','Lancement PC Box On : '.$cmdTime);
$scenario->setLog('Lancement PC Box B On : '.$cmdTime.' '.strpos($infosEvnt[3],'@'));
}
if(strpos($infosEvnt[3],'@')===false){
//lancer scénario box off (événement en cours)
$Tags = $Sc->getTags();
#Ajouter des tags
$Tags['#tagTime#'] = $TimeDebTSP;
$Tags['#tagOnOff#'] = 0;
#Passer les tags à un sous-scenario et le lancer
$Sc->setTags($Tags);
$Sc->launch();
sleep(5);
//log::add('Scenario Box Agenda','error','Lancement PC Box Off : '.$TimeDebTSP);
$scenario->setLog('Lancement PC Box C Off : '.$TimeDebTSP.' '.strpos($infosEvnt[3],'@'));
}
}//sinon ne rien faire
$cmdTime = $TimeFinTSP;
}
}
//Gestion du dernier événement du jour
if(strpos($infosEvnt[3],'@')===false){
//lancer scénario box on
$Tags = $Sc->getTags();
#Ajouter des tags
$Tags['#tagTime#'] = $TimeFinTSP;
$Tags['#tagOnOff#'] = 1;
#Passer les tags à un sous-scenario et le lancer
$Sc->setTags($Tags);
$Sc->launch();
//log::add('Scenario Box Agenda','error','Lancement PC Box On : '.$TimeFinTSP);
$scenario->setLog('Lancement PC Box D On : '.$TimeFinTSP);
//NextScenario($TimeFinTSP,1);
}
}else{
log::add('Test Scénario','error','Aucun événement aujourdhui, la box va rester allumée !');
}
}
/*
public static function NextScenario($tagTime, $tagOnOff) {
$Sc = scenario::byId(22);
//lancer scénario box on
$Tags = $Sc->getTags();
#Ajouter des tags
$Tags['#tagTime#'] = $tagTime;
$Tags['#tagOnOff#'] = $tagOnOff;
#Passer les tags à un sous-scenario et le lancer
$Sc->setTags($Tags);
$Sc->launch();
//log::add('Scenario Box Agenda','error','Lancement PC Box On : '.$TimeFinTSP);
$scenario->setLog('Lancement PC Box On : '.$TimeFinTSP);
}
*/
Puis le log que j’obtiens de ce scénario :
[2024-06-07 08:29:02][SCENARIO] -- Début : Scenario lance manuellement.
[2024-06-07 08:29:02][SCENARIO] - Exécution du sous-élément de type [action] : action
[2024-06-07 08:29:03][SCENARIO] Exécution d'un bloc élément : 86
[2024-06-07 08:29:03][SCENARIO] - Exécution du sous-élément de type [action] : action
[2024-06-07 08:29:03][SCENARIO] Exécution d'un bloc élément : 87
[2024-06-07 08:29:03][SCENARIO] - Exécution du sous-élément de type [action] : code
[2024-06-07 08:29:03][SCENARIO] Exécution d'un bloc code
[2024-06-07 08:29:08][SCENARIO] Lancement PC Box A Off : 0200
[2024-06-07 08:29:13][SCENARIO] Lancement PC Box B On : 1300
[2024-06-07 08:29:18][SCENARIO] Lancement PC Box C Off : 1415
[2024-06-07 08:29:23][SCENARIO] Lancement PC Box B On : 1715
[2024-06-07 08:29:28][SCENARIO] Lancement PC Box C Off : 1830
[2024-06-07 08:29:28][SCENARIO] Lancement PC Box D On : 2130
[2024-06-07 08:29:28][SCENARIO] Fin correcte du scénario
Et enfin le moteur de tâches :
Et pourquoi pas le log de mon scénario appelé :
[2024-06-07 08:29:03][SCENARIO] -- Début : . Tags : {"#tagTime#":"0200","#tagOnOff#":0}
[2024-06-07 08:29:03][SCENARIO] - Exécution du sous-élément de type [action] : action
[2024-06-07 08:29:03][SCENARIO] Exécution d'un bloc élément : 103
[2024-06-07 08:29:03][SCENARIO] - Exécution du sous-élément de type [action] : code
[2024-06-07 08:29:03][SCENARIO] Exécution d'un bloc code
[2024-06-07 08:29:03][SCENARIO] //1/
[2024-06-07 08:29:03][SCENARIO] Log : Script lancé pour 0200 en mode 0
[2024-06-07 08:29:03][SCENARIO] - Exécution du sous-élément de type [condition] : if tag(tagOnOff,1) == 1
[2024-06-07 08:29:03][SCENARIO] Evaluation de la condition : [0 == 1] = Faux
[2024-06-07 08:29:03][SCENARIO] - Exécution du sous-élément de type [action] : else
[2024-06-07 08:29:03][SCENARIO] Exécution d'un bloc élément : 96
[2024-06-07 08:29:03][SCENARIO] - Exécution du sous-élément de type [condition] : at tag(tagTime,tag(tagTime,time_op(#time#,+1)))
[2024-06-07 08:29:03][SCENARIO] Evaluation de la condition : [0200] = 200
[2024-06-07 08:29:04][SCENARIO] Tâche : 96 programmée à : 2024-06-08 02:00:00
[2024-06-07 08:29:04][SCENARIO] Fin correcte du scénario
------------------------------------
[2024-06-07 08:29:08][SCENARIO] -- Début : . Tags : {"#tagTime#":"1300","#tagOnOff#":1}
[2024-06-07 08:29:08][SCENARIO] - Exécution du sous-élément de type [action] : action
[2024-06-07 08:29:08][SCENARIO] Exécution d'un bloc élément : 103
[2024-06-07 08:29:08][SCENARIO] - Exécution du sous-élément de type [action] : code
[2024-06-07 08:29:08][SCENARIO] Exécution d'un bloc code
[2024-06-07 08:29:08][SCENARIO] //1/
[2024-06-07 08:29:08][SCENARIO] Log : Script lancé pour 1300 en mode 1
[2024-06-07 08:29:08][SCENARIO] - Exécution du sous-élément de type [condition] : if tag(tagOnOff,1) == 1
[2024-06-07 08:29:08][SCENARIO] Evaluation de la condition : [1 == 1] = Vrai
[2024-06-07 08:29:08][SCENARIO] - Exécution du sous-élément de type [action] : then
[2024-06-07 08:29:08][SCENARIO] Exécution d'un bloc élément : 95
[2024-06-07 08:29:08][SCENARIO] - Exécution du sous-élément de type [condition] : at tag(tagTime,time_op(#time#,+1))
[2024-06-07 08:29:08][SCENARIO] Evaluation de la condition : [1300] = 1300
[2024-06-07 08:29:08][SCENARIO] Tâche : 95 programmée à : 2024-06-07 13:00:00
[2024-06-07 08:29:08][SCENARIO] Fin correcte du scénario
------------------------------------
[2024-06-07 08:29:13][SCENARIO] -- Début : . Tags : {"#tagTime#":"1415","#tagOnOff#":0}
[2024-06-07 08:29:13][SCENARIO] - Exécution du sous-élément de type [action] : action
[2024-06-07 08:29:13][SCENARIO] Exécution d'un bloc élément : 103
[2024-06-07 08:29:13][SCENARIO] - Exécution du sous-élément de type [action] : code
[2024-06-07 08:29:13][SCENARIO] Exécution d'un bloc code
[2024-06-07 08:29:13][SCENARIO] //1/
[2024-06-07 08:29:13][SCENARIO] Log : Script lancé pour 1415 en mode 0
[2024-06-07 08:29:13][SCENARIO] - Exécution du sous-élément de type [condition] : if tag(tagOnOff,1) == 1
[2024-06-07 08:29:13][SCENARIO] Evaluation de la condition : [0 == 1] = Faux
[2024-06-07 08:29:13][SCENARIO] - Exécution du sous-élément de type [action] : else
[2024-06-07 08:29:13][SCENARIO] Exécution d'un bloc élément : 96
[2024-06-07 08:29:13][SCENARIO] - Exécution du sous-élément de type [condition] : at tag(tagTime,tag(tagTime,time_op(#time#,+1)))
[2024-06-07 08:29:13][SCENARIO] Evaluation de la condition : [1415] = 1415
[2024-06-07 08:29:13][SCENARIO] Tâche : 96 programmée à : 2024-06-07 14:15:00
[2024-06-07 08:29:13][SCENARIO] Fin correcte du scénario
------------------------------------
[2024-06-07 08:29:18][SCENARIO] -- Début : . Tags : {"#tagTime#":"1715","#tagOnOff#":1}
[2024-06-07 08:29:18][SCENARIO] - Exécution du sous-élément de type [action] : action
[2024-06-07 08:29:18][SCENARIO] Exécution d'un bloc élément : 103
[2024-06-07 08:29:18][SCENARIO] - Exécution du sous-élément de type [action] : code
[2024-06-07 08:29:18][SCENARIO] Exécution d'un bloc code
[2024-06-07 08:29:18][SCENARIO] //1/
[2024-06-07 08:29:18][SCENARIO] Log : Script lancé pour 1715 en mode 1
[2024-06-07 08:29:18][SCENARIO] - Exécution du sous-élément de type [condition] : if tag(tagOnOff,1) == 1
[2024-06-07 08:29:18][SCENARIO] Evaluation de la condition : [1 == 1] = Vrai
[2024-06-07 08:29:18][SCENARIO] - Exécution du sous-élément de type [action] : then
[2024-06-07 08:29:18][SCENARIO] Exécution d'un bloc élément : 95
[2024-06-07 08:29:18][SCENARIO] - Exécution du sous-élément de type [condition] : at tag(tagTime,time_op(#time#,+1))
[2024-06-07 08:29:18][SCENARIO] Evaluation de la condition : [1715] = 1715
[2024-06-07 08:29:18][SCENARIO] Tâche : 95 programmée à : 2024-06-07 17:15:00
[2024-06-07 08:29:18][SCENARIO] Fin correcte du scénario
------------------------------------
[2024-06-07 08:29:23][SCENARIO] -- Début : . Tags : {"#tagTime#":"1830","#tagOnOff#":0}
[2024-06-07 08:29:23][SCENARIO] - Exécution du sous-élément de type [action] : action
[2024-06-07 08:29:23][SCENARIO] Exécution d'un bloc élément : 103
[2024-06-07 08:29:23][SCENARIO] - Exécution du sous-élément de type [action] : code
[2024-06-07 08:29:23][SCENARIO] Exécution d'un bloc code
[2024-06-07 08:29:23][SCENARIO] //1/
[2024-06-07 08:29:23][SCENARIO] Log : Script lancé pour 1830 en mode 0
[2024-06-07 08:29:23][SCENARIO] - Exécution du sous-élément de type [condition] : if tag(tagOnOff,1) == 1
[2024-06-07 08:29:23][SCENARIO] Evaluation de la condition : [0 == 1] = Faux
[2024-06-07 08:29:23][SCENARIO] - Exécution du sous-élément de type [action] : else
[2024-06-07 08:29:23][SCENARIO] Exécution d'un bloc élément : 96
[2024-06-07 08:29:23][SCENARIO] - Exécution du sous-élément de type [condition] : at tag(tagTime,tag(tagTime,time_op(#time#,+1)))
[2024-06-07 08:29:23][SCENARIO] Evaluation de la condition : [1830] = 1830
[2024-06-07 08:29:24][SCENARIO] Tâche : 96 programmée à : 2024-06-07 18:30:00
[2024-06-07 08:29:24][SCENARIO] Fin correcte du scénario
------------------------------------
[2024-06-07 08:29:28][SCENARIO] -- Début : . Tags : {"#tagTime#":"2130","#tagOnOff#":1}
[2024-06-07 08:29:28][SCENARIO] - Exécution du sous-élément de type [action] : action
[2024-06-07 08:29:28][SCENARIO] Exécution d'un bloc élément : 103
[2024-06-07 08:29:28][SCENARIO] - Exécution du sous-élément de type [action] : code
[2024-06-07 08:29:28][SCENARIO] Exécution d'un bloc code
[2024-06-07 08:29:28][SCENARIO] //1/
[2024-06-07 08:29:28][SCENARIO] Log : Script lancé pour 2130 en mode 1
[2024-06-07 08:29:28][SCENARIO] - Exécution du sous-élément de type [condition] : if tag(tagOnOff,1) == 1
[2024-06-07 08:29:28][SCENARIO] Evaluation de la condition : [1 == 1] = Vrai
[2024-06-07 08:29:28][SCENARIO] - Exécution du sous-élément de type [action] : then
[2024-06-07 08:29:28][SCENARIO] Exécution d'un bloc élément : 95
[2024-06-07 08:29:28][SCENARIO] - Exécution du sous-élément de type [condition] : at tag(tagTime,time_op(#time#,+1))
[2024-06-07 08:29:28][SCENARIO] Evaluation de la condition : [2130] = 2130
[2024-06-07 08:29:29][SCENARIO] Tâche : 95 programmée à : 2024-06-07 21:30:00
[2024-06-07 08:29:29][SCENARIO] Fin correcte du scénario