homebridge-telegram
homebridge-telegram copied to clipboard
Send a jpeg as part of the message?
My doorbell produces a static small .jpeg file at http://192.168.xx.xx/snap.jpeg ... would it be possible to embed that image (not a link to the image, but the actual image?)
Did you manage to fix this? I have the same question at this moment...
@JohnF87 , I ended up switching to a different plugin (https://github.com/pponce/homebridge-script2) and then using a script to send the picture.
You can easily send a picture via a bash script (Google is your friend here... curl -X POST....)
Can you give me some help? I found this, but the JSON is invalid. What is the code you used?
#!/bin/sh
$1 = Chat ID
$2 = Caption
$3 = Disable Notification (true or false)
TelegramToken="12345678:AABBCCDDEEFFasdfjasdhfkashdf" SnapFile="/var/tmp/camsnapshot.jpg"
Get snapshot via Domoticz server
wget -O $SnapFile "http://192.168.123.100:8080/camsnapshot.jpg?idx=1"
Send Telegram message with image
curl -s -X POST "https://api.telegram.org/bot$TelegramToken/sendPhoto" -F chat_id=$1 -F caption="$2" -F disable_notification=$3 -F photo="@$SnapFile"
Remove SnapFile
/bin/rm $SnapFile
The exact code is below. Obviously you need to change the wget command (line 6) to point to where your image is and also change the "bot ID" and "chat ID" to match your circumstances. This will send a photo via the bot each time the doorbell script is activated.
`#!/bin/sh
current_time=$(date "+%Y.%m.%d-%H.%M.%S") new_filename=$current_time.jpeg new_message=$(date) wget http://192.168.1.19/snap.jpeg cp snap.jpeg ~/doorbell/$new_filename
curl -X POST "https://api.telegram.org/bot1111111111:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/sendPhoto" -F chat_id=111111111 -F parse_mode="MarkdownV2" -F text="${new_message} \- 🔔Doorbell Ring🔔"
curl -X POST "https://api.telegram.org/bot1111111111:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/sendPhoto" -F chat_id=1111111111 -F photo="@snap.jpeg"
rm snap.jpeg
`
The exact code is below. Obviously you need to change the wget command (line 6) to point to where your image is and also change the "bot ID" and "chat ID" to match your circumstances. This will send a photo via the bot each time the doorbell script is activated.
`#!/bin/sh
current_time=$(date "+%Y.%m.%d-%H.%M.%S") new_filename=$current_time.jpeg new_message=$(date) wget http://192.168.1.19/snap.jpeg cp snap.jpeg ~/doorbell/$new_filename
curl -X POST "https://api.telegram.org/bot1111111111:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/sendPhoto" -F chat_id=111111111 -F parse_mode="MarkdownV2" -F text="${new_message} - 🔔_Doorbell Ring🔔_"
curl -X POST "https://api.telegram.org/bot1111111111:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/sendPhoto" -F chat_id=1111111111 -F photo="@snap.jpeg"
rm snap.jpeg
`
Thanks for the code. Can you help me one more time. I have zero experience with scripting.
When I add the code to the JSON file it shows so errors in the code. What am I doing wrong?
@JohnF87 , the code above needs to be placed into a separate file, not within the JSON. The JSON config is simply to call the file to execute when certain triggers are met.