1
0

README ergänzt, HA-Benachrichtigung optional

This commit is contained in:
Anna Christina Naß
2025-07-16 10:11:20 +02:00
parent fdc2eb6c07
commit d48080da27
3 changed files with 75 additions and 11 deletions

View File

@@ -42,16 +42,18 @@ switch ($data['event']) {
function send_notification($msg, $url = null) {
global $hawebhook;
$post = [ 'message' => $msg ];
if ($url != null) $post['url'] = $url;
$ch = curl_init($hawebhook);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post));
$rc = curl_exec($ch);
curl_close($ch);
if ($hawebhook != "") {
$post = [ 'message' => $msg ];
if ($url != null) $post['url'] = $url;
$ch = curl_init($hawebhook);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post));
$rc = curl_exec($ch);
curl_close($ch);
}
}
function test_finished() {