First of all, I have set up the Telegram notification system and it is working when I press the Test button in Domoticz settings. Next, the script is triggered if the doorbell is pressed. But what happens next is obscure.
I have this in my script (the print statements below are only there for checking the strings sent by os.execute):
Code: Select all
return {
on = {
devices = {'Doorbell'}
},
execute = function(domoticz, device)
local teleTok = '122356789:AABBCDEFGHIJKLMNOPQRSTUVWZYZabcdef'
local chatId = '987654321'
local snapFile= '/var/tmp/camsnapshot.jpg'
local domoReq = 'http://123.45.67.89:8088/camsnapshot.jpg?idx=7'
local teststring = 'wget -O "' ..snapFile..'" "' ..domoReq .. '"'
print ("WGET string: " ..teststring)
os.execute(teststring)
local teststring = 'curl -s -X POST "https://api.telegram.org/bot'..teleTok..'/sendPhoto?chat_id='..chatId..'" -F photo="@' ..snapFile..'"'
print ("POST string: " ..teststring)
os.execute(teststring)
local teststring = "rm " ..snapFile
print ("RM string: " ..teststring)
os.execute(teststring)
end
}
Code: Select all
2019-07-18 00:12:41.477 Status: dzVents: WGET: wget -O "/var/tmp/camsnapshot.jpg" "http://123.45.67.89:8088/camsnapshot.jpg?idx=7"
2019-07-18 00:12:41.510 Status: dzVents: POST: curl -s -X POST "https://api.telegram.org/bot122356789:AABBCDEFGHIJKLMNOPQRSTUVWZYZabcdef/sendPhoto?chat_id=987654321" -F photo="@/var/tmp/camsnapshot.jpg"
2019-07-18 00:12:41.725 Status: dzVents: RM: rm /var/tmp/camsnapshot.jpg
2019-07-18 00:12:41.739 Status: dzVents: Info: ------ Finished Doorbellphotoscript
BTW the camera I am using is a cheap and simple ESP32CAM model. Typing 'http://123.45.67.89:8088/camsnapshot.jpg?idx=7' in the browser results in the download of a file named 'snapshot.jpg'.