heatermeter + discord alerts


 

Jeremy_Pickett

New member
hey there!

I recently made the change to Discord away from Slack and I wanted to get my Heatermeter alerts working within that instead (for a Slack how-to see my old guide here)
Surprisingly it wasn't as easy as changing out the webhook URL in the code. There were some slight syntax differences in what is allowed

So ... for future users of heatermeter i thought would record what I found:

1// make a #channel in your discord server, go to the settings, and create a webhook:
1586938112182.png

2// within heatermeter, go to Configuration > Alarm Scripts > All Alarm Script
Then copy/paste something like this (changing what needs to be changed of course)

Code:
#!/bin/bash
message="$pn0: $pcurr0 ($sp) \n$pn1: $pcurr1 ($palh1) \n$pn2: $pcurr2 ($palh2) \n$pn3: $pcurr3 ($palh3) \n-- \nhttp://$ip/luci/lm/\nhttp://xxx.duckdns.org:1234/luci/lm/"
## format to parse to curl
echo Sending message: $message
msg_content=\"$message\"

## discord webhook
url='https://discordapp.com/api/webhooks/webhookcodeurlgoesinhere'
curl -H "Content-Type: application/json" -X POST -d "{\"content\": $msg_content}" $url

Capture_blur.PNG

3// tick in 'execute on alarm' and hit 'Submit'

4// test by going into Configuration > Alarms, and hitting one of the little bell icons:
ZzJkYTo.gif



5// bathe in your Discord glory, which will trigger an alert to your phone if you have the app installed.
Capture2_blurred.PNG
 

 

Back
Top