Improve Home Assistant notifications
This commit is contained in:
@@ -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);
|
||||
Reference in New Issue
Block a user