Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 55 additions & 14 deletions core/class/frigate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,23 @@ private static function configSave(array $array = []): void
}
}
}

public static function setConfigEqlogic()
{
$eqLogics = self::byType('frigate');
foreach ($eqLogics as $eqLogic) {
$refresh = config::byKey('refresh_snapshot', 'frigate', 5);
if ($eqLogic->getConfiguration('normal::refresh') === null) {
$eqLogic->setConfiguration('normal::refresh', $refresh);
$eqLogic->save();
}
if ($eqLogic->getConfiguration('normal::mobilerefresh') === null) {
$eqLogic->setConfiguration('normal::mobilerefresh', $refresh);
$eqLogic->save();
}
}
}

private static function execCron($frequence)
{
log::add(__CLASS__, 'debug', "╔════════════════════════ :fg-success:START CRON:/fg: ════════════════════════");
Expand Down Expand Up @@ -407,8 +424,18 @@ public function toHtml($_version = 'dashboard')
$replace['#cameraEqlogicId#'] = $this->getLogicalId();
$replace['#cameraName#'] = $this->getConfiguration("name");
$replace['#imgUrl#'] = $this->getConfiguration("img");
$replace['#enabled#'] = $this->getCmd('info', 'info_enabled') ? $this->getCmd('info', 'info_enabled')->execCmd() : 1;
$replace['#refresh#'] = (float)(config::byKey('refresh_snapshot', 'frigate')) * 1000;
$enabledCmd = $this->getCmd('info', 'info_enabled');
if ($enabledCmd) {
$value = $enabledCmd->execCmd();
$replace['#enabled#'] = ($value !== null && $value !== '') ? $value : 1;
} else {
$replace['#enabled#'] = 1;
}
if ($this->getConfiguration('normal::refresh') != '') {
$replace['#refresh#'] = (float)$this->getConfiguration('normal::refresh') * 1000;
} else {
$replace['#refresh#'] = (float)(config::byKey('refresh_snapshot', 'frigate', 5)) * 1000;
}

$replace['#actions#'] = $this->buildActions();
$replace['#iaActions#'] = $this->buildIaActions();
Expand Down Expand Up @@ -714,8 +741,19 @@ private static function getcURL($function, $url, $params = null, $decodeJson = t
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
}

// log de la commande curl
$curl_cmd = "curl -k -X " . $method;
if ($method !== 'DELETE') {
$curl_cmd .= " -H 'Content-Type: application/json'";
$curl_cmd .= " -d '" . json_encode($params) . "'";
}
$curl_cmd .= " '" . $url . "'";
log::add(__CLASS__, 'debug', "║ Commande exécutée : " . $curl_cmd);
// Fin du log

$data = curl_exec($ch);

log::add(__CLASS__, 'debug', "║ Réponse reçue : " . $data);
if (curl_errno($ch)) {
log::add(__CLASS__, "error", "║ Erreur getcURL (" . $method . "): " . curl_error($ch));
return null;
Expand All @@ -733,6 +771,9 @@ private static function postcURL($function, $url, $params = null, $decodeJson =

private static function putcURL($function, $url, $params = null, $decodeJson = true)
{
if (empty($params)) {
$params = new stdClass();
}
return self::getcURL($function, $url, $params, $decodeJson, 'PUT');
}

Expand Down Expand Up @@ -1519,8 +1560,8 @@ public static function getFolderSize()
} catch (Exception $e) {
return 0;
}
$t1 = microtime(true);
log::add(__CLASS__, 'debug', "║ Taille du dossier calculée via PHP : " . round($size / (1024 * 1024), 2) . " Mo en " . round($t1 - $t0, 2) . "s");
$t1 = microtime(true);
log::add(__CLASS__, 'debug', "║ Taille du dossier calculée via PHP : " . round($size / (1024 * 1024), 2) . " Mo en " . round($t1 - $t0, 2) . "s");
return round($size / (1024 * 1024), 2);
}

Expand Down Expand Up @@ -2021,33 +2062,33 @@ private static function updateCommands($eqlogicId, $type, $frigateEvent)
{
log::add(__CLASS__, 'debug', "║ MAJ Commandes pour le type : $type");

$update = function ($label, $subtype, $unit, $logicalId, $value) use ($eqlogicId) {
$cmd = self::createCmd($eqlogicId, $label, $subtype, $unit, $logicalId, "", 0, null, 0);
$update = function ($label, $subtype, $unit, $logicalId, $genericType, $value) use ($eqlogicId) {
$cmd = self::createCmd($eqlogicId, $label, $subtype, $unit, $logicalId, $genericType, 0, null, 0);
$cmd->save();
$cmd->event($value ?? '');
$cmd->save();
};

$update("Reconnaissance - Type", "string", "", "info_detection_type", $type);
$update("Reconnaissance - Type", "string", "", "info_detection_type", "", $type);

$withNameScore = ['face', 'lpr', 'classification'];
if (in_array($type, $withNameScore)) {
$update("Reconnaissance - Nom", "string", "", "info_detection_name", $frigateEvent->getRecognition_name());
$update("Reconnaissance - Score", "numeric", "%", "info_detection_score", $frigateEvent->getRecognition_score());
$update("Reconnaissance - Nom", "string", "", "info_detection_name", "", $frigateEvent->getRecognition_name());
$update("Reconnaissance - Score", "numeric", "%", "info_detection_score", "", $frigateEvent->getRecognition_score());
}

if ($type === 'description') {
log::add(__CLASS__, 'debug', "║ Mise à jour de la description : " . $frigateEvent->getRecognition_description());
$update("Reconnaissance - Description", "string", "", "info_description", $frigateEvent->getRecognition_description());
$update("Reconnaissance - Description", "string", "", "info_description", "", $frigateEvent->getRecognition_description());
}

if ($type === 'lpr') {
$update("Reconnaissance - Plaque d'immatriculation", "string", "", "info_plate", $frigateEvent->getRecognition_plate());
$update("Reconnaissance - Plaque d'immatriculation", "string", "", "info_plate", "", $frigateEvent->getRecognition_plate());
}

if ($type === 'classification') {
$update("Reconnaissance - Label", "string", "", "info_detection_subname", $frigateEvent->getRecognition_subname());
$update("Reconnaissance - Attributs", "string", "", "info_detection_attributes", $frigateEvent->getRecognition_attributes());
$update("Reconnaissance - Label", "string", "", "info_detection_subname", "", $frigateEvent->getRecognition_subname());
$update("Reconnaissance - Attributs", "string", "", "info_detection_attributes", "", $frigateEvent->getRecognition_attributes());
}
}

Expand Down Expand Up @@ -3164,7 +3205,7 @@ public static function handleMqttMessage($_message)
if (version_compare($version, "0.14", "<")) {
log::add("frigate_MQTT", 'info', ' => Traitement mqtt events <0.14');
log::add("frigate_MQTT", 'warning', ' => Version < 0.14, mettre à jour votre serveur frigate !');
message::add("frigate",__("Version de Frigate détectée : " . $version . ", certaines fonctionnalités du plugin peuvent ne pas fonctionner correctement. Veuillez mettre à jour votre serveur Frigate pour une expérience optimale.", __FILE__));
message::add("frigate", __("Version de Frigate détectée : " . $version . ", certaines fonctionnalités du plugin peuvent ne pas fonctionner correctement. Veuillez mettre à jour votre serveur Frigate pour une expérience optimale.", __FILE__));
self::getEvents(true, [$value['after']], $value['type']);
event::add('frigate::events', array('message' => 'mqtt_update', 'type' => 'event'));
}
Expand Down
1 change: 1 addition & 0 deletions core/template/dashboard/widgetCamera.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
function startImageFetchInterval() {
if (!intervalId) {
intervalId = setInterval(refreshImage, #refresh#);
console.log('Interval started for camera #id# with refresh rate: ' + #refresh# + ' ms');
}
}

Expand Down
3 changes: 2 additions & 1 deletion core/template/dashboard/widgetPanel.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@

function startImageFetchInterval() {
if (!intervalId) {
intervalId = setInterval(refreshImage, #refresh#);
intervalId = setInterval(refreshImage, #refresh#);
console.log('Interval started for camera #id# with refresh rate: ' + #refresh# + ' ms');
}
}

Expand Down
43 changes: 29 additions & 14 deletions desktop/js/frigate.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,24 @@ function printEqLogic(_eqLogic) {
observer.observe(imgElement);

function startImageFetchInterval() {
if (!intervalId) {
intervalId = setInterval(refreshImage, refresh);
const eqRefresh = $('.eqLogicAttr[data-l1key="configuration"]')
.filter(function () {
return $(this).attr('data-l2key') === 'normal::refresh';
})
.val();
refreshSnap = refresh;
if (eqRefresh && !isNaN(eqRefresh) && eqRefresh > 0) {
refreshSnap = eqRefresh * 1000;
}

// On arrête toujours l'intervalle existant avant d'en créer un nouveau
if (intervalId) {
clearInterval(intervalId);
intervalId = null;
}

console.log('Refresh interval in milliseconds: ' + refreshSnap);
intervalId = setInterval(refreshImage, refreshSnap);
}

function stopImageFetchInterval() {
Expand Down Expand Up @@ -657,12 +672,12 @@ document.getElementById('addCmdHttp').addEventListener('click', function () {

},
dataType: 'json',
error: function (error) {
jeedomUtils.showAlert({
message: error.message,
level: 'danger'
});
},
error: function (error) {
jeedomUtils.showAlert({
message: error.message,
level: 'danger'
});
},
success: function (data) {
jeedomUtils.showAlert({
message: '{{Création de la commande réussie.}}',
Expand Down Expand Up @@ -698,12 +713,12 @@ function editHTTP(cmd) {

},
dataType: 'json',
error: function (error) {
jeedomUtils.showAlert({
message: error.message,
level: 'danger'
});
},
error: function (error) {
jeedomUtils.showAlert({
message: error.message,
level: 'danger'
});
},
success: function (data) {
jeedomUtils.showAlert({
message: '{{Modification de la commande réussie.}}',
Expand Down
12 changes: 11 additions & 1 deletion desktop/php/frigate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
sendVarToJS('frigateURL', $urlFrigate);
$urlExterne = config::byKey('URLexterne', 'frigate');
sendVarToJS('frigateURLexterne', $urlExterne);

$refresh = (float)(config::byKey('refresh_snapshot', 'frigate')) * 1000;
sendVarToJS('refresh', $refresh);
?>
Expand Down Expand Up @@ -209,6 +208,17 @@
</span>
</div>
</div>
<div class="form-group eqFrigate">
<label class="col-sm-4 control-label">{{Rafraichissement}}
<sup><i class="fas fa-question-circle tooltips" title="{{Si aucune configuration, la configuration globale est prise en compte.}}"></i></sup>
</label>
<div class="col-sm-3">
<input type="text" class="eqLogicAttr form-control" data-l1key="configuration" data-l2key="normal::refresh" placeholder="{{Dashboard et Panel}}">
</div>
<div class="col-sm-3">
<input type="text" class="eqLogicAttr form-control" data-l1key="configuration" data-l2key="normal::mobilerefresh" placeholder="{{Jeemate}}">
</div>
</div>
<div class="form-group eqFrigate">
<label class="col-sm-4 control-label">{{Afficher sur le panel}}</label>
<div class="col-sm-6">
Expand Down
7 changes: 5 additions & 2 deletions docs/fr_FR/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
>
>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.

# 13/05/2026 Beta 1.5.2
# 19/04/2026 Beta 1.5.4
- Correction du put curl pour l'activation et la désactivation des caméras via API

# 13/04/2026 Beta 1.5.2
- Correction widget dashboard

# 09/05/2026 Beta 1.5.1
# 09/04/2026 Beta 1.5.1
- Amélioration du processus de nettoyage des évènements
- Correction maj sur cron via http

Expand Down
2 changes: 1 addition & 1 deletion plugin_info/info.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "frigate",
"name": "Frigate",
"pluginVersion": "1.5.2",
"pluginVersion": "1.5.24",
"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.",
Expand Down
2 changes: 2 additions & 0 deletions plugin_info/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function frigate_install()

frigate::setConfig();
frigate::setConfigCron();
frigate::setConfigEqlogic();
frigate::addMessages();
Log::add("frigate", 'info', 'Finish Install');
}
Expand Down Expand Up @@ -93,6 +94,7 @@ function frigate_update()
}

frigate::setConfig();
frigate::setConfigEqlogic();
frigate::addMessages();
frigate::deleteLatestFile();
Log::add("frigate", 'info', 'Finish Update');
Expand Down