34 lines
918 B
PHP
34 lines
918 B
PHP
<?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);
|