@@ -2388,6 +2388,14 @@ private static function executeActionNewEvent($eqLogicId, $event)
23882388 log::add ("frigateActions " , 'debug ' , "║ label : " . $ label );
23892389 foreach ($ actions as $ action ) {
23902390 log::add ("frigateActions " , 'debug ' , "╠════════════════════════════════════ " );
2391+
2392+ // vérifier en premier si la commande est activée
2393+ $ enable = $ action ['options ' ]['enable ' ] ?? false ;
2394+ if (!$ enable ) {
2395+ log::add ("frigateActions " , 'debug ' , "║ Commande(s) désactivée(s) " );
2396+ continue ;
2397+ }
2398+
23912399 log::add ("frigateActions " , 'debug ' , "║ Action : " . json_encode ($ action ));
23922400 $ cmd = $ action ['cmd ' ];
23932401 $ cmdLabelName = $ action ['cmdLabelName ' ] ?: "all " ;
@@ -2396,11 +2404,6 @@ private static function executeActionNewEvent($eqLogicId, $event)
23962404 $ cmdZoneEndName = $ action ['cmdZoneEndName ' ] ?: "" ;
23972405
23982406 // Convertir les chaînes en tableaux
2399- /* $cmdLabels = array_map('trim', explode(',', $cmdLabelName));
2400- $cmdZones = array_map('trim', explode(',', $cmdZoneName));
2401- $cmdZonesEnd = array_map('trim', explode(',', $cmdZoneEndName));
2402- $eventZones = array_map('trim', explode(',', $zones)); */
2403-
24042407 $ cmdLabels = array_map (fn ($ s ) => self ::cleanString (trim ($ s )), explode (', ' , $ cmdLabelName ));
24052408 $ cmdZones = array_map (fn ($ s ) => self ::cleanString (trim ($ s )), explode (', ' , $ cmdZoneName ));
24062409 $ cmdZonesEnd = array_map (fn ($ s ) => self ::cleanString (trim ($ s )), explode (', ' , $ cmdZoneEndName ));
@@ -2439,28 +2442,19 @@ private static function executeActionNewEvent($eqLogicId, $event)
24392442 }
24402443
24412444 if (!($ labelMatch && $ typeMatch && $ zoneMatch )) {
2442- log::add (__CLASS__ , 'debug ' , "║ ACTION: Au moins une des conditions (label, type, zone) n'est pas remplie, l'action sera ignorée. " );
2443- // log::add("frigateActions", 'debug', "╠════════════════════════════════════");
2445+ log::add ("frigateActions " , 'debug ' , "║ Au moins une des conditions (label, type, zone) n'est pas remplie, l'action sera ignorée. " );
24442446 continue ;
24452447 }
24462448
24472449 $ options = $ action ['options ' ];
2448- $ enable = $ action ['options ' ]['enable ' ] ?? false ;
24492450 $ actionForced = $ action ['options ' ]['actionForced ' ] ?? false ;
24502451
2451- if (!$ enable ) {
2452- log::add ("frigateActions " , 'debug ' , "║ Commande(s) désactivée(s) " );
2453- // log::add("frigateActions", 'debug', "╠════════════════════════════════════");
2454- continue ;
2455- }
2456-
24572452 if (!$ conditionIsActived ) {
24582453 log::add ("frigateActions " , 'debug ' , "║ Commande en cour d'éxècution. " );
24592454 } elseif ($ conditionIsActived && $ actionForced ) {
24602455 log::add ("frigateActions " , 'debug ' , "║ Commande en cour d'éxècution car la condition est ignorée " );
24612456 } else {
24622457 log::add ("frigateActions " , 'info ' , "║ " . $ eqLogic ->getHumanName () . ' : actions non exécutées car ' . $ conditionIf . ' est vrai. ' );
2463- // log::add("frigateActions", 'debug', "╠════════════════════════════════════");
24642458 continue ;
24652459 }
24662460
@@ -2476,18 +2470,11 @@ private static function executeActionNewEvent($eqLogicId, $event)
24762470 continue ;
24772471 }
24782472
2479- /* if (!($labelMatch && $typeMatch && $zoneMatch)) {
2480- log::add("frigateActions", 'debug', "║ ACTION: Au moins une des conditions (label, type, zone) n'est pas remplie, l'action sera ignorée.");
2481- log::add("frigateActions", 'debug', "╠════════════════════════════════════");
2482- continue;
2483- } */
2484-
24852473 // Exécuter l'action selon le contenu des options
24862474 $ optionsJson = json_encode ($ action ['options ' ]);
24872475 if (strpos ($ optionsJson , '#clip# ' ) !== false || strpos ($ optionsJson , '#clip_path# ' ) !== false ) {
24882476 if ($ hasClip == 1 ) {
24892477 log::add ("frigateActions " , 'debug ' , "║ ACTION CLIP : " . $ optionsJson );
2490- // log::add("frigateActions", 'debug', "╠════════════════════════════════════");
24912478 scenarioExpression::createAndExec ('action ' , $ cmd , $ options );
24922479 } else {
24932480 log::add ("frigateActions " , 'debug ' , "║ Le clip n'est pas disponible, actions non éxècutée. " );
@@ -2496,15 +2483,13 @@ private static function executeActionNewEvent($eqLogicId, $event)
24962483 } elseif (strpos ($ optionsJson , '#snapshot# ' ) !== false || strpos ($ optionsJson , '#snapshot_path# ' ) !== false ) {
24972484 if ($ hasSnapshot == 1 ) {
24982485 log::add ("frigateActions " , 'debug ' , "║ ACTION SNAPSHOT : " . $ optionsJson );
2499- // log::add("frigateActions", 'debug', "╠════════════════════════════════════");
25002486 scenarioExpression::createAndExec ('action ' , $ cmd , $ options );
25012487 } else {
25022488 log::add ("frigateActions " , 'debug ' , "║ Le snapshot n'est pas disponible, actions non éxècutée. " );
25032489 log::add ("frigateActions " , 'debug ' , "╠════════════════════════════════════ " );
25042490 }
25052491 } else {
25062492 log::add ("frigateActions " , 'debug ' , "║ ACTION OTHER: " . $ optionsJson );
2507- // log::add("frigateActions", 'debug', "╠════════════════════════════════════");
25082493 scenarioExpression::createAndExec ('action ' , $ cmd , $ options );
25092494 }
25102495 }
0 commit comments