Improve Home Assistant notifications

This commit is contained in:
seo
2026-06-21 07:46:28 +09:00
parent 49394a8ee5
commit 772010562a
6 changed files with 269 additions and 55 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/../config/config.php';
$channel = '';
foreach (array_slice($argv, 1) as $arg) {
if (str_starts_with($arg, '--remove=')) {
$channel = trim(substr($arg, 9));
}
}
if ($channel === '') {
fwrite(STDERR, "Usage: php bin/ha_notify_channel.php --remove=control_battery\n");
exit(2);
}
$result = send_ha_notify([
'title' => 'HA 알림 채널 제거',
'message' => 'remove_channel',
'level' => 'info',
'tag' => 'control-channel-remove-' . preg_replace('/[^a-zA-Z0-9_-]+/', '-', $channel),
'data' => [
'channel' => $channel,
'notification_icon' => 'mdi:notification-clear-all',
'persistent' => false,
'sticky' => 'false',
'renotify' => 'false',
],
]);
echo json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . PHP_EOL;
exit(($result['sent'] ?? 0) > 0 ? 0 : 1);