Skip to content

A live bird collage card for your Home Assistant dashboard.

Update to return IdentifiedSoFar.txt - IDFILE location

jaredb7e9987425179d
diff --git a/scripts/common.php b/scripts/common.php
index e5c08537..045b554e 100644
--- a/scripts/common.php
+++ b/scripts/common.php
@@ -1103,6 +1103,8 @@ function getDirectory($dir)
*/
function getFilePath($filename)
{
+ global $config;
+
if ($filename == "analyzing_now.txt") {
return getDirectory('birdnet_pi') . "/analyzing_now.txt";
//
@@ -1145,6 +1147,10 @@ function getFilePath($filename)
} else if ($filename == "HUMAN.txt") {
return getDirectory('birdnet_pi') . "/HUMAN.txt";
//
+ } else if ($filename == "IdentifiedSoFar.txt" ||$filename == "IDFILE" ) {
+ $id_file_setting = $config['IDFILE'];
+ return getDirectory('home') . str_replace('$HOME', '', $id_file_setting);
+ //
} else if ($filename == "include_species_list.txt") {
return getDirectory('scripts') . "/include_species_list.txt";
//
diff --git a/tests/test_filepath_resolver_common.php b/tests/test_filepath_resolver_common.php
index 08e080ba..511b517e 100644
--- a/tests/test_filepath_resolver_common.php
+++ b/tests/test_filepath_resolver_common.php
@@ -6,7 +6,8 @@ const TEST_HOMES = ['/home/pi', '/home/another_user', '/opt/birdnet'];
$config = [
"RECS_DIR" => "\$HOME/BirdSongs",
"PROCESSED" => "\${RECS_DIR}/Processed",
- "EXTRACTED" => "\${RECS_DIR}/Extracted"
+ "EXTRACTED" => "\${RECS_DIR}/Extracted",
+ "IDFILE" => "\$HOME/BirdNET-Pi/IdentifiedSoFar.txt"
];
function test()
@@ -135,6 +136,10 @@ function test()
$expected = $_test_home . "/BirdNET-Pi/HUMAN.txt";
($result == $expected) ?: (print "failed file path 'HUMAN.txt', expected: " . ($expected) . " got: " . ($result) . "\r\n");
+ $result = getFilePath('IdentifiedSoFar.txt');
+ $expected = $_test_home . "/BirdNET-Pi/IdentifiedSoFar.txt";
+ ($result == $expected) ?: (print "failed file path 'IdentifiedSoFar.txt', expected: " . ($expected) . " got: " . ($result) . "\r\n");
+
$result = getFilePath('include_species_list.txt');
$expected = $_test_home . "/BirdNET-Pi/scripts/include_species_list.txt";
($result == $expected) ?: (print "failed file path 'include_species_list.txt', expected: " . ($expected) . " got: " . ($result) . "\r\n");