Skip to content

A live bird collage card for your Home Assistant dashboard.

replaced radio buttons with slider

mcguirepr89d092d4fa7981
diff --git a/scripts/advanced.php b/scripts/advanced.php
index bfcd285a..f3859df1 100644
--- a/scripts/advanced.php
+++ b/scripts/advanced.php
@@ -109,27 +109,16 @@ if(isset($_GET['submit'])) {
}
}
- if(isset($_GET["privacy_mode"])) {
- $privacy_mode = $_GET["privacy_mode"];
- if(strcmp($config['PRIVACY_MODE'], "1") == 0 ) {
+ if(isset($_GET["privacy_threshold"])) {
+ $privacy_threshold = $_GET["privacy_threshold"];
+ if(strcmp($config['PRIVACY_THRESHOLD'], "1") == 0 ) {
$pmode = "on";
- }elseif(strcmp($config['PRIVACY_MODE'], "") == 0) {
+ }elseif(strcmp($config['PRIVACY_THRESHOLD'], "") == 0) {
$pmode = "off";
}
- if(strcmp($privacy_mode,$pmode) !== 0) {
- $contents = preg_replace("/PRIVACY_MODE=.*/", "PRIVACY_MODE=$privacy_mode", $contents);
- $contents2 = preg_replace("/PRIVACY_MODE=.*/", "PRIVACY_MODE=$privacy_mode", $contents2);
- if(strcmp($privacy_mode,"on") == 0) {
- exec('sudo sed -i \'s/\/usr\/local\/bin\/server.py/\/usr\/local\/bin\/privacy_server.py/g\' ../../BirdNET-Pi/templates/birdnet_server.service');
- exec('sudo systemctl daemon-reload');
- exec('restart_services.sh');
- header('Location: /log');
- } elseif(strcmp($privacy_mode,"off") == 0) {
- exec('sudo sed -i \'s/\/usr\/local\/bin\/privacy_server.py/\/usr\/local\/bin\/server.py/g\' ../../BirdNET-Pi/templates/birdnet_server.service');
- exec('sudo systemctl daemon-reload');
- exec('restart_services.sh');
- header('Location: /log');
- }
+ if(strcmp($privacy_threshold,$pmode) !== 0) {
+ $contents = preg_replace("/PRIVACY_THRESHOLD=.*/", "PRIVACY_THRESHOLD=$privacy_threshold", $contents);
+ $contents2 = preg_replace("/PRIVACY_THRESHOLD=.*/", "PRIVACY_THRESHOLD=$privacy_threshold", $contents2);
}
}
@@ -194,14 +183,21 @@ if (file_exists('./scripts/thisrun.txt')) {
?>
<h2>Advanced Settings</h2>
<form action="" method="GET">
- <label>Privacy Mode: </label>
- <label for="on">
- <input name="privacy_mode" type="radio" id="on" value="on" <?php if (strcmp($newconfig['PRIVACY_MODE'], "1") == 0) { echo "checked"; }?>>On</label>
- <label for="off">
- <input name="privacy_mode" type="radio" id="off" value="off" <?php if (strcmp($newconfig['PRIVACY_MODE'], "") == 0) { echo "checked"; }?>>Off</label>
- <p>Privacy mode can be set to 'on' or 'off' to configure analysis to be more sensitive to human detections. Privacy mode 'on' will purge any data that receives even a low Human confidence score.
- Please note that changing this setting restarts services and replaces the running server. It will take about 90, so please be patient!</p>
-
+ <label>Privacy Threshold: </label><br>
+ <div class="slidecontainer">
+ <input type="range" min="0" max="25" value="0" class="slider" id="myRange">
+ <p>Value: <span id="demo"></span>%</p>
+ </div>
+ <script>
+ var slider = document.getElementById("myRange");
+ var output = document.getElementById("demo");
+ output.innerHTML = slider.value; // Display the default slider value
+
+ // Update the current slider value (each time you drag the slider handle)
+ slider.oninput = function() {
+ output.innerHTML = this.value;
+ }
+ </script>
<label>Full Disk Behavior: </label>
<label for="purge">
<input name="full_disk" type="radio" id="purge" value="purge" <?php if (strcmp($newconfig['FULL_DISK'], "purge") == 0) { echo "checked"; }?>>Purge</label>