What I want is when:
Switch is On -> Telegram Cam snapshot + Text: Security ON
Switch is Off -> Telegram Cam snapshot + Text: Security OFF
This script below is working well. But it works only when the switch "AlarmLed" goes on.
And there is no text above or below the picture.
So, what should be added to the script?
Thanks in advance for all the support.
John
Code: Select all
return {
on = {
devices = {'AlarmLed'},
},
execute = function(domoticz, device)
if(device.state == 'On') then
local teleTok = '111111111111111111111BBBBBBBBBBBBBBBBB'
local chatId = '-1234567890'
local snapFile = '/home/pi/domoticz/scripts/camera_'
local domoReq = 'http://192.168.178.231:8080/raspberry.cgi'
local camName = 'Frontdoor'
os.execute('wget -O "'..snapFile..camName..'.jpg" "'..domoReq..'"')
os.execute('curl -s -X POST "https://api.telegram.org/bot'..teleTok..'/sendPhoto?chat_id='..chatId..'" -F photo="@'..snapFile..camName..'.jpg"')
os.execute("rm " ..snapFile..camName..'.jpg')
end
end
}