Skip to content

A live bird collage card for your Home Assistant dashboard.

#397

ehpersonal38340fdc050544
diff --git a/homepage/index.php b/homepage/index.php
index dd459253..d39162ae 100644
--- a/homepage/index.php
+++ b/homepage/index.php
@@ -5,7 +5,7 @@ body::-webkit-scrollbar {
display:none
}
</style>
-<link rel="stylesheet" href="style.css?v=14.0.6">
+<link rel="stylesheet" href="style.css?v=14.0.7">
<body>
<div class="banner">
<div class="logo">
diff --git a/homepage/style.css b/homepage/style.css
index 6cc70eab..a912b7e2 100644
--- a/homepage/style.css
+++ b/homepage/style.css
@@ -776,4 +776,8 @@ form#views button .updatenumber {
.brbanner h1 {
margin:0px;
font-size: xx-large;
+}
+
+.testbtn {
+ background:#77c487;
}
\ No newline at end of file
diff --git a/scripts/config.php b/scripts/config.php
index cbf3d259..060d0447 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -130,6 +130,31 @@ if(isset($_GET["latitude"])){
shell_exec("sudo restart_services.sh");
}
+if(isset($_GET['sendtest']) && $_GET['sendtest'] == "true") {
+ $user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
+ $home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
+ $home = trim($home);
+ $cf = explode("\n",$_GET['apprise_config']);
+ $cf = "'".implode("' '", $cf)."'";
+
+ $title = $_GET['apprise_notification_title'];
+ $body = $_GET['apprise_notification_body'];
+
+ $title = str_replace("\$comname", "Common Name", $title);
+ $title = str_replace("\$sciname", "Scientific Name", $title);
+ $title = str_replace("\$confidence", "0.8", $title);
+ $title = str_replace("\$listenurl", "http://example.com", $title);
+
+ $body = str_replace("\$comname", "Common Name", $body);
+ $body = str_replace("\$sciname", "Scientific Name", $body);
+ $body = str_replace("\$confidence", "0.85", $body);
+ $body = str_replace("\$listenurl", "http://example.com/listenurl=", $body);
+
+ shell_exec($home."/BirdNET-Pi/birdnet/bin/apprise -vv -t '".$title."' -b '".$body."' ".$cf." ");
+
+ die();
+}
+
?>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
@@ -170,6 +195,26 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) {
}
?>
+<script>
+function sendTestNotification(e) {
+ e.classList.add("disabled");
+
+ var apprise_notification_title = document.getElementsByName("apprise_notification_title")[0].value;
+ var apprise_notification_body = document.getElementsByName("apprise_notification_body")[0].value;
+ var apprise_config = encodeURIComponent(document.getElementsByName("apprise_input")[0].value);
+
+ var xmlHttp = new XMLHttpRequest();
+ xmlHttp.onreadystatechange = function() {
+ if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
+
+ e.classList.remove("disabled");
+ }
+ }
+ xmlHttp.open("GET", "scripts/config.php?sendtest=true&apprise_notification_title="+apprise_notification_title+"&apprise_notification_body="+apprise_notification_body+"&apprise_config="+apprise_config, true); // true for asynchronous
+ xmlHttp.send(null);
+}
+</script>
+
<table class="settingstable"><tr><td>
<h2>Location</h2>
<label for="latitude">Latitude: </label>
@@ -212,6 +257,8 @@ https://discordapp.com/api/webhooks/{WebhookID}/{WebhookToken}
<label for="apprise_notify_new_species">Notify each new infrequent species detection (<5 visits per week)</label><br>
<input type="checkbox" name="apprise_notify_each_detection" <?php if($config['APPRISE_NOTIFY_EACH_DETECTION'] == 1 && filesize($home."/BirdNET-Pi/apprise.txt") != 0) { echo "checked"; };?> >
<label for="apprise_notify_each_detection">Notify each new detection</label><br><br>
+
+ <button type="button" class="testbtn" onclick="sendTestNotification(this)">Send Test Notification</button>
</td></tr></table><br>
<table class="settingstable"><tr><td>
<h2>Bird Photos from Flickr</h2>