mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-27 16:54:04 +00:00
feat: added Home Assistant notification integration
This commit is contained in:
parent
9650418ef7
commit
f84ae82983
36 changed files with 114 additions and 0 deletions
38
server/notification-providers/home-assistant.js
Normal file
38
server/notification-providers/home-assistant.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
|
||||
const defaultNotificationService = "notify";
|
||||
|
||||
class HomeAssistant extends NotificationProvider {
|
||||
name = "HomeAssistant";
|
||||
|
||||
async send(notification, message, monitor = null, heartbeat = null) {
|
||||
const notificationService = notification?.notificationService || defaultNotificationService;
|
||||
|
||||
try {
|
||||
await axios.post(
|
||||
`${notification.homeAssistantUrl}/api/services/notify/${notificationService}`,
|
||||
{
|
||||
title: "Uptime Kuma",
|
||||
message,
|
||||
...(notificationService !== "persistent_notification" && { data: {
|
||||
name: monitor?.name,
|
||||
status: heartbeat?.status,
|
||||
} }),
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${notification.longLivedAccessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return "Sent Successfully.";
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = HomeAssistant;
|
|
@ -35,6 +35,7 @@ const Gorush = require("./notification-providers/gorush");
|
|||
const Alerta = require("./notification-providers/alerta");
|
||||
const OneBot = require("./notification-providers/onebot");
|
||||
const PushDeer = require("./notification-providers/pushdeer");
|
||||
const HomeAssistant = require("./notification-providers/home-assistant");
|
||||
|
||||
class Notification {
|
||||
|
||||
|
@ -82,6 +83,7 @@ class Notification {
|
|||
new Alerta(),
|
||||
new OneBot(),
|
||||
new PushDeer(),
|
||||
new HomeAssistant(),
|
||||
];
|
||||
|
||||
for (let item of list) {
|
||||
|
|
40
src/components/notifications/HomeAssistant.vue
Normal file
40
src/components/notifications/HomeAssistant.vue
Normal file
|
@ -0,0 +1,40 @@
|
|||
<template>
|
||||
<div class="mb-3">
|
||||
<label for="homeAssistantUrl" class="form-label">{{ $t("Home Assistant URL") }}<span style="color: red;"><sup>*</sup></span></label>
|
||||
<input id="homeAssistantUrl" v-model="$parent.notification.homeAssistantUrl" type="url" class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="longLivedAccessToken" class="form-label">{{ $t("Long-Lived Access Token") }}<span style="color: red;"><sup>*</sup></span></label>
|
||||
<input id="longLivedAccessToken" v-model="$parent.notification.longLivedAccessToken" type="text" class="form-control" required>
|
||||
|
||||
<div class="form-text">
|
||||
<p>{{ $t("Long-Lived Access Token can be created by clicking on your profile name (bottom left) and scrolling to the bottom then click Create Token. ") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="notificationService" class="form-label">{{ $t("Notification Service") }}</label>
|
||||
<input id="notificationService" v-model="$parent.notification.notificationService" type="text" :placeholder="$t('default: notify all devices')" class="form-control">
|
||||
|
||||
<div class="form-text">
|
||||
<p>{{ $t("A list of Notification Services can be found in Home Assistant under \"Developer Tools > Services\" search for \"notification\" to find your device/phone name.") }}</p>
|
||||
<p>{{ $t("Automations can optionally be triggered in Home Assistant:") }}</p>
|
||||
<p>
|
||||
{{ $t("Trigger type:") }} <code>Event</code><br />
|
||||
{{ $t("Event type:") }} <code>call_service</code><br />
|
||||
{{ $t("Event data:") }}
|
||||
</p>
|
||||
<pre>domain: notify
|
||||
service: mobile_app_my_phone # change to your device name
|
||||
service_data:
|
||||
title: Uptime Kuma
|
||||
data:
|
||||
status: 0 # 0=down 1=up
|
||||
# name: Optional Uptime Kuma Monitor Name to filter by</pre>
|
||||
<p>
|
||||
{{ $t("Then choose an action, for example switch the scene to where an RGB light is red.") }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
|
@ -33,6 +33,7 @@ import Gorush from "./Gorush.vue";
|
|||
import Alerta from "./Alerta.vue";
|
||||
import OneBot from "./OneBot.vue";
|
||||
import PushDeer from "./PushDeer.vue";
|
||||
import HomeAssistant from "./HomeAssistant.vue";
|
||||
|
||||
/**
|
||||
* Manage all notification form.
|
||||
|
@ -75,6 +76,7 @@ const NotificationFormList = {
|
|||
"alerta": Alerta,
|
||||
"OneBot": OneBot,
|
||||
"PushDeer": PushDeer,
|
||||
"HomeAssistant": HomeAssistant,
|
||||
};
|
||||
|
||||
export default NotificationFormList;
|
||||
|
|
|
@ -536,4 +536,5 @@ export default {
|
|||
Domain: "Домейн",
|
||||
Workstation: "Работна станция",
|
||||
disableCloudflaredNoAuthMsg: "Тъй като сте в режим \"No Auth mode\", парола не се изисква.",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -364,4 +364,5 @@ export default {
|
|||
smtpDkimHashAlgo: "Hashovací algoritmus (volitelné)",
|
||||
smtpDkimheaderFieldNames: "Podepisovat tyto hlavičky (volitelné)",
|
||||
smtpDkimskipFields: "Nepodepisovat tyto hlavičky (volitelné)",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -352,4 +352,5 @@ export default {
|
|||
serwersmsPhoneNumber: "Telefonnummer",
|
||||
serwersmsSenderName: "SMS Afsender Navn (registreret via kundeportal)",
|
||||
stackfield: "Stackfield",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -455,4 +455,5 @@ export default {
|
|||
"Domain Names": "Domainnamen",
|
||||
signedInDisp: "Angemeldet als {0}",
|
||||
signedInDispDisabled: "Authentifizierung deaktiviert.",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -536,4 +536,5 @@ export default {
|
|||
"Domain": "Domain",
|
||||
"Workstation": "Workstation",
|
||||
disableCloudflaredNoAuthMsg: "You are in No Auth mode, password is not require.",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -206,4 +206,5 @@ export default {
|
|||
records: "registros",
|
||||
"One record": "Un registro",
|
||||
steamApiKeyDescription: "Para monitorear un servidor de juegos de Steam, necesita una clave Steam Web-API. Puede registrar su clave API aquí: ",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -206,4 +206,5 @@ export default {
|
|||
alertaApiKey: "API võti",
|
||||
alertaAlertState: "Häireseisund",
|
||||
alertaRecoverState: "Taasta algolek",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -536,4 +536,5 @@ export default {
|
|||
Domain: "Domeinua",
|
||||
Workstation: "Lan gunea",
|
||||
disableCloudflaredNoAuthMsg: "Ez Auth moduan zaude, pasahitza ez da beharrezkoa.",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -205,4 +205,5 @@ export default {
|
|||
pushbullet: "Pushbullet",
|
||||
line: "Line Messenger",
|
||||
mattermost: "Mattermost",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -309,4 +309,5 @@ export default {
|
|||
alertaApiKey: "Clé de l'API",
|
||||
alertaAlertState: "État de l'Alerte",
|
||||
alertaRecoverState: "État de récupération",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -375,4 +375,5 @@ export default {
|
|||
alertaAlertState: "Stanje upozorenja",
|
||||
alertaRecoverState: "Stanje oporavka",
|
||||
deleteStatusPageMsg: "Sigurno želite obrisati ovu statusnu stranicu?",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -373,4 +373,5 @@ export default {
|
|||
alertaAlertState: "Figyelmeztetési állapot",
|
||||
alertaRecoverState: "Visszaállási állapot",
|
||||
deleteStatusPageMsg: "Biztos, hogy törölni akarja a státusz oldalt?",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -283,4 +283,5 @@ export default {
|
|||
promosmsPhoneNumber: "Nomor telepon (untuk penerima Polandia Anda dapat melewati kode area)",
|
||||
promosmsSMSSender: "Nama Pengirim SMS : Nama pra-registrasi atau salah satu bawaan: InfoSMS, Info SMS, MaxSMS, INFO, SMS",
|
||||
"Feishu WebHookUrl": "Feishu WebHookUrl",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -364,4 +364,5 @@ export default {
|
|||
smtpDkimheaderFieldNames: "Campi Intestazione da firmare (opzionale)",
|
||||
smtpDkimskipFields: "Campi Intestazione da non firmare (opzionale)",
|
||||
GoogleChat: "Google Chat (solo per Google Workspace)",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -198,4 +198,5 @@ export default {
|
|||
pushbullet: "Pushbullet",
|
||||
line: "Line Messenger",
|
||||
mattermost: "Mattermost",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -528,4 +528,5 @@ export default {
|
|||
"Go back to the previous page.": "이전 페이지로 돌아가기",
|
||||
"Coming Soon": "Coming Soon",
|
||||
wayToGetClickSendSMSToken: "{0}에서 API 사용자 이름과 키를 얻을 수 있어요.",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -282,4 +282,5 @@ export default {
|
|||
promosmsTypeSpeed: "SMS SPEED - Høyest prioritet i systemet.Veldig rask på pålitelig, men dyrt (omtrent det dobbeltet av SMS FULL pris).",
|
||||
promosmsPhoneNumber: "Telefonnummber (for polske mottakere. Du trenger ikke områdekode.)",
|
||||
promosmsSMSSender: "SMS Avsendernavn : Forhåndsregistert navn eller en av standardnavnene: InfoSMS, SMS Info, MaxSMS, INFO, SMS",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -462,4 +462,5 @@ export default {
|
|||
"Footer Text": "Footer Tekst",
|
||||
"Show Powered By": "Laat 'Mogeljik gemaakt door' zien",
|
||||
"Domain Names": "Domein Namen",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -467,4 +467,5 @@ export default {
|
|||
"Domain Names": "Domeny",
|
||||
signedInDisp: "Zalogowany jako {0}",
|
||||
signedInDispDisabled: "Autoryzacja wyłączona.",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -200,4 +200,5 @@ export default {
|
|||
pushbullet: "Pushbullet",
|
||||
line: "Line Messenger",
|
||||
mattermost: "Mattermost",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -400,4 +400,5 @@ export default {
|
|||
proxyDescription: "Прокси должны быть привязаны к монитору, чтобы работать.",
|
||||
enableProxyDescription: "Этот прокси не будет влиять на запросы монитора, пока не будет активирован. Вы можете контролировать временное отключение прокси для всех мониторов через статус активации.",
|
||||
setAsDefaultProxyDescription: "Этот прокси будет по умолчанию включен для новых мониторов. Вы всё ещё можете отдельно отключать прокси в каждом мониторе.",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -354,4 +354,5 @@ export default {
|
|||
serwersmsPhoneNumber: "Telefonska številka",
|
||||
serwersmsSenderName: "Ime SMS pošiljatelja (registrirani prek portala za stranke)",
|
||||
"stackfield": "Stackfield",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -201,4 +201,5 @@ export default {
|
|||
pushbullet: "Pushbullet",
|
||||
line: "Line Messenger",
|
||||
mattermost: "Mattermost",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -201,4 +201,5 @@ export default {
|
|||
pushbullet: "Pushbullet",
|
||||
line: "Line Messenger",
|
||||
mattermost: "Mattermost",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -107,4 +107,5 @@ export default {
|
|||
"Repeat Password": "Upprepa Lösenord",
|
||||
respTime: "Svarstid (ms)",
|
||||
notAvailableShort: "Ej Tillg.",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -518,4 +518,5 @@ export default {
|
|||
"Go back to the previous page.": "กลับไปที่หน้าก่อนหน้า",
|
||||
"Coming Soon": "เร็ว ๆ นี้",
|
||||
wayToGetClickSendSMSToken: "คุณสามารถรับ API Username และ API Key ได้จาก {0}",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -527,4 +527,5 @@ export default {
|
|||
"do nothing": "hiçbir şey yapma",
|
||||
"auto acknowledged": "otomatik onaylama",
|
||||
"auto resolve": "otomatik çözümleme",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -392,4 +392,5 @@ export default {
|
|||
alertaAlertState: "Стан алерту",
|
||||
alertaRecoverState: "Стан відновлення",
|
||||
deleteStatusPageMsg: "Дійсно хочете видалити цю сторінку статусів?",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -466,4 +466,5 @@ export default {
|
|||
"Domain Names": "Domain Names",
|
||||
signedInDisp: "Signed in as {0}",
|
||||
signedInDispDisabled: "Auth Disabled.",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -540,4 +540,5 @@ export default {
|
|||
"ntfy Topic": "ntfy 主题",
|
||||
"Domain": "域名",
|
||||
"Workstation": "工作站",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -380,4 +380,5 @@ export default {
|
|||
proxyDescription: "必須將代理伺服器指派給監測器才能運作。",
|
||||
enableProxyDescription: "此代理伺服器在啟用前不會在監測器上生效,您可以藉由控制啟用狀態來暫時對所有的監測器停用代理伺服器。",
|
||||
setAsDefaultProxyDescription: "預設情況下,新監測器將啟用此代理伺服器。您仍可分別停用各監測器的代理伺服器。",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
|
@ -465,4 +465,5 @@ export default {
|
|||
"Footer Text": "頁尾文字",
|
||||
"Show Powered By": "顯示技術支援文字",
|
||||
"Domain Names": "網域名稱",
|
||||
HomeAssistant: "Home Assistant",
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue