Advertisement
xangin

HA earthquake notify shell script

May 24th, 2024 (edited)
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.80 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #修改成自己HA的IP:PORT,注意等號左右不能有空格唷!!
  4. DST=http://192.168.XXX.XXX:8123
  5.  
  6. #觸發HA的webhook以執行自動化
  7. curl -X POST \
  8.   -H "Content-Type: application/json" \
  9.   -d "{ \"level\": \"$1\" , \"seconds\": \"$2\" }" \
  10.   $DST/api/webhook/trigger_ea_cmd
  11.  
  12. #line notify權杖,頭尾引號勿刪除,引號裡面不能有空格
  13. line_token="REPLACE_WITH_YOUR_TOKEN"
  14.  
  15. #通知內容
  16. msg="警告!!芮氏規模$1的地震,將於$2秒後到達!!"
  17.  
  18. #截圖指令
  19. VNC=:0 gnome-screenshot -w -f /config/oxwu/OX.png
  20.  
  21. #發送line通知
  22. curl -X POST https://notify-api.line.me/api/notify \
  23.   -H "Authorization: Bearer "$line_token \
  24.   -F "message=${msg}" \
  25.   -F "imageFile=@/config/oxwu/OX.png"
  26.  
  27. #等待1秒
  28. sleep 1s
  29.  
  30. #刪除截圖
  31. rm -f /config/oxwu/OX.png
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement