filipnet / ups-telegram-notify

Notification of the status of an Uninterruptible Power Supply by Telegram
BSD 3-Clause "New" or "Revised" License
10 stars 3 forks source link

Something is not working Correctly? #3

Open teambach opened 8 months ago

teambach commented 8 months ago

I followed your instructions and it's not working?

If I feed it some text into notifycmd.sh for example [ ./etc/nut/notifycmd.sh "test" ] I get a notification on Telegram, like this

IMG_5268

But when I test the UPS, by pulling power, I don't get any notification?

Here's my notifycmd.sh

#!/bin/bash

GROUP_ID=#######
BOT_TOKEN=######

NOW=$(date)
case "${NOTIFYTYPE}" in
    ONLINE|COMMOK)
        EMOJI=$'\xE2\x9C\x85' # white heavy check mark
        ;;
    ONBATT|COMMBAD|REPLBATT)
        EMOJI=$'\xE2\x9A\xA0' # warning sign
        ;;
    LOWBATT|FSD|NOCOMM|SHUTDOWN)
        EMOJI=$'\xF0\x9F\x86\x98' # squared sos
        ;;
    NOPARENT)
        EMOJI=$'\xF0\x9F\x94\x84' # anticlockwise downwards and upwards open circle arrows
        ;;
esac

EMOJI+=$'\xEF\xB8\x8F' # The emoji should be displayed with emoji presentation
MESSAGE="${EMOJI} UPS Notification%0A"
MESSAGE+="UPS Name: $UPSNAME %0ANotify type: $NOTIFYTYPE %0ANotify message: $*"

curl \
-s \
--data "parse_mode=HTML" \
--data "text=$MESSAGE" \
--data "chat_id=$GROUP_ID" 'https://api.telegram.org/bot'$BOT_TOKEN'/sendMessage' > /dev/null

And I added the text in the /etc/nut upsmod.config as recommended, also added the correct permission to the notifycmd.sh file and added it to the Nut group.

Please help

filipnet commented 4 months ago

Hi, did you also start the nut monitoring-service systemctl enable nut-monitor.service && systemctl start nut-monitor.service