diff --git a/core/ajax/frigate.ajax.php b/core/ajax/frigate.ajax.php index 848cb94c..d256d80f 100644 --- a/core/ajax/frigate.ajax.php +++ b/core/ajax/frigate.ajax.php @@ -173,6 +173,14 @@ ajax::success(); } + if (init('action') == 'frigateDebug') { + $data = frigate::showEvents(false, true); + + ajax::success(array( + "object" => $data, + "json" => json_encode($data), + )); + } throw new Exception(__('Aucune méthode correspondante à', __FILE__) . ' : ' . init('action')); /* * *********Catch exeption*************** */ diff --git a/core/class/frigate.class.php b/core/class/frigate.class.php index c1011ce1..92abbea2 100644 --- a/core/class/frigate.class.php +++ b/core/class/frigate.class.php @@ -302,7 +302,8 @@ public function postInsert() {} public function preUpdate() {} // Fonction exécutée automatiquement après la mise à jour de l'équipement - public function postUpdate() {} + public function postUpdate() { + } // Fonction exécutée automatiquement avant la sauvegarde (création ou mise à jour) de l'équipement public function preSave() @@ -1677,44 +1678,55 @@ public static function deleteEvent($id, $all = false) log::add(__CLASS__, 'debug', "╚════════════════════════════════════════════════════════"); return "OK"; } - public static function showEvents() + public static function showEvents(bool $_onlyEnable = FALSE, bool $_allType = FALSE) { $result = []; - $events = frigate_events::all(); + + $events = frigate_events::all($_onlyEnable, $_allType); foreach ($events as $event) { $date = date("d-m-Y H:i:s", $event->getStartTime()); $duree = round($event->getEndTime() - $event->getStartTime(), 0); - $box = $event->getBox(); - $boxArray = is_array($box) ? $box : json_decode($box, true); $result[] = array( - "id" => $event->getId(), - "img" => $event->getLasted(), - "camera" => $event->getCamera(), - "label" => $event->getLabel(), - "box" => $boxArray, - "date" => $date, - "duree" => $duree, - "startTime" => $event->getStartTime(), - "endTime" => $event->getEndTime(), - "snapshot" => $event->getSnapshot(), - "clip" => $event->getClip(), - "thumbnail" => $event->getThumbnail(), - "hasSnapshot" => $event->getHasSnapshot(), - "hasClip" => $event->getHasClip(), - "eventId" => $event->getEventId(), - "score" => $event->getScore(), - "top_score" => $event->getTopScore(), - "type" => $event->getType(), - "isFavorite" => $event->getIsFavorite() ?? 0, - "zones" => $event->getZones() ?? '', - "description" => $event->getRecognition_description() + "id" => $event->getId(), + "eventId" => $event->getEventId(), + "img" => $event->getLasted(), + "camera" => $event->getCamera(), + "label" => $event->getLabel(), + "subLabel" => $event->getSubLabel(), + "box" => json_decode($event->getBox(), true), + "date" => $date, + "duree" => $duree, + "startTime" => $event->getStartTime(), + "endTime" => $event->getEndTime(), + "falsePositive" => $event->getFalsePositive(), + "snapshot" => $event->getSnapshot(), + "clip" => $event->getClip(), + "thumbnail" => $event->getThumbnail(), + "hasSnapshot" => $event->getHasSnapshot(), + "hasClip" => $event->getHasClip(), + "score" => $event->getScore(), + "top_score" => $event->getTopScore(), + "plusId" => $event->getPlusId(), + "retain" => $event->getRetain(), + "type" => $event->getType(), + "isFavorite" => $event->getIsFavorite() ?? 0, + "zones" => $event->getZones() ?? '', + "data" => $event->getData(), + "recognition_type" => $event->getRecognition_type(), + "description" => $event->getRecognition_description(), + "recognition_name" => $event->getRecognition_name(), + "recognition_subname" => $event->getRecognition_subname(), + "recognition_attributes" => $event->getRecognition_attributes(), + "recognition_plate" => $event->getRecognition_plate(), + "recognition_score" => $event->getRecognition_score() ); } - usort($result, [self::class, 'orderByDate']); - + if (!empty($result)) { + usort($result, 'frigate::orderByDate'); + } return $result; } diff --git a/core/class/frigate_events.class.php b/core/class/frigate_events.class.php index 6fa972a6..b4d070c5 100644 --- a/core/class/frigate_events.class.php +++ b/core/class/frigate_events.class.php @@ -57,14 +57,26 @@ class frigate_events /** * @throws Exception */ - public static function all(bool $_onlyEnable = FALSE) + public static function all(bool $_onlyEnable = FALSE, bool $_allType = FALSE) { - $sql = 'SELECT ' . DB::buildField(__CLASS__) . ' - FROM frigate_events - WHERE type IS NOT NULL'; + $sql = 'SELECT ' . DB::buildField(__CLASS__) . ' FROM frigate_events'; + $where = []; + + if (!$_allType) { + $where[] = 'type IS NOT NULL'; + } + if ($_onlyEnable) { + $where[] = 'enabled = 1'; + } + if (!empty($where)) { + $sql .= ' WHERE ' . implode(' AND ', $where); + } + return DB::Prepare($sql, array(), DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__); } + + /** * @throws Exception */ diff --git a/desktop/js/frigate.js b/desktop/js/frigate.js index d643b026..61436b44 100644 --- a/desktop/js/frigate.js +++ b/desktop/js/frigate.js @@ -690,6 +690,31 @@ document.getElementById('addCmdHttp').addEventListener('click', function () { }) }); +document.getElementById('frigateDebug').addEventListener('click', function () { + domUtils.ajax({ + type: "POST", + url: "plugins/frigate/core/ajax/frigate.ajax.php", + data: { + action: "frigateDebug", + data: { function: "getAllEvents" } + }, + dataType: 'json', + error: function (error) { + jeedomUtils.showAlert({ + message: error.message, + level: 'danger' + }); + }, + success: function (data) { + var json = data.result.json; + const blob = new Blob([json], { + type: "text/plain;charset=utf-8" + }); + saveAs(blob, "getAllEvents.json.txt"); + } + }) +}); + function editHTTP(cmd) { var id = cmd.id; // Récupère l'id var data = cmd.getAttribute('data-request'); // Récupère la valeur de data-request diff --git a/desktop/php/frigate.php b/desktop/php/frigate.php index 229f7da6..9226e5ae 100644 --- a/desktop/php/frigate.php +++ b/desktop/php/frigate.php @@ -67,6 +67,11 @@
{{Logs Frigate}} +
+ +
+ {{Json}} +
>S'il n'y a pas d'information sur la mise à jour, c'est que celle-ci concerne uniquement de la mise à jour de documentation, de traduction ou de texte. -# 19/04/2026 Beta 1.5.4 +# 06/05/2026 Beta & Stable 1.5.4 +- nouveau bouton pour télécharger la liste des évènements (utile pour le debug dev) + +# 19/04/2026 Beta 1.5.3 - Correction du put curl pour l'activation et la désactivation des caméras via API # 13/04/2026 Beta 1.5.2 diff --git a/plugin_info/info.json b/plugin_info/info.json index 1267a5a1..6e979dd2 100644 --- a/plugin_info/info.json +++ b/plugin_info/info.json @@ -1,7 +1,7 @@ { "id": "frigate", "name": "Frigate", - "pluginVersion": "1.5.25", + "pluginVersion": "1.5.4", "installation": "Il est nécessaire d'avoir le plugin mqtt-manager installé avec un broker MQTT sécurisé (user / mdp) pour profiter de toutes les fonctionnalités. Dans le cas contraire, le plugin Frigate sera limité. Voir la documentation pour plus d'informations.", "description": { "fr_FR": "Plugin Frigate pour Jeedom. Ne fonctionne qu'avec les versions de Frigate > 0.13.0. Le plugin n'installe pas le serveur Frigate mais permet de le controler.",