Created
April 16, 2020 08:24
-
-
Save Log1x/0c24e25952d039fa7e708d5205cd94f9 to your computer and use it in GitHub Desktop.
Discord Notification Webhook for unRAID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Replace Slack.sh in /boot/config/plugins/dynamix/notifications/agents | |
# Set to your Discord webhook token. | |
WEBHOOK="https://discordapp.com/api/webhooks/ID/TOKEN" | |
curl "$WEBHOOK" \ | |
-X "POST" \ | |
-H 'Content-Type: application/json' \ | |
--data @<(cat <<EOF | |
{ | |
"embeds": [ | |
{ | |
"title": "$EVENT", | |
"description": "$SUBJECT", | |
"footer": { | |
"text": "$(date) on $(hostname)" | |
}, | |
"thumbnail": { | |
"url": "https://i.imgur.com/tlooVc1.png", | |
"height": 16, | |
"width": 16 | |
}, | |
"fields": [ | |
{ | |
"name": "Priority", | |
"value": "${IMPORTANCE^}" | |
}, | |
{ | |
"name": "Description", | |
"value": "$DESCRIPTION\n\n$CONTENT" | |
} | |
] | |
} | |
] | |
} | |
EOF | |
) |
Author
Log1x
commented
Apr 16, 2020
Here's a alternative for HomeAssistant:
#!/bin/bash
# Replace with your Home Assistant instance URL and long-lived token
HA_URL="http://homeassistant.local:8123"
HA_TOKEN="<token from http://homeassistant.local/profile/security>"
# Create event data
event_data=$(cat <<EOF
{
"event": "$EVENT",
"subject": "$SUBJECT",
"priority": "${IMPORTANCE^}",
"description": "$DESCRIPTION",
"content": "$CONTENT",
"timestamp": "$(date)",
"hostname": "$(hostname)"
}
EOF
)
# Send the event to Home Assistant
curl "$HA_URL/api/events/unraid" \
-X "POST" \
-H "Authorization: Bearer $HA_TOKEN" \
-H "Content-Type: application/json" \
-d "$event_data"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment