Skip to content

A live bird collage card for your Home Assistant dashboard.

fix: look for an actual json file

frederik13e44a72de9f
diff --git a/scripts/spectrogram.php b/scripts/spectrogram.php
index 611e8f6e..831f3a93 100644
--- a/scripts/spectrogram.php
+++ b/scripts/spectrogram.php
@@ -18,9 +18,10 @@ if(isset($_GET['ajax_csv'])) {
if (empty($config['RTSP_STREAM'])) {
$look_in_directory = $STREAM_DATA_DIR;
- $files = scandir($look_in_directory, SCANDIR_SORT_ASCENDING);
- //Extract the filename, positions 0 and 1 are the folder hierarchy '.' and '..'
- $newest_file = $files[2];
+ $files = glob($look_in_directory . "*.wav.json");
+ if (count($files) !== 0) {
+ $newest_file = $files[0];
+ }
}
else {
$look_in_directory = $STREAM_DATA_DIR;