Page 1 of 1

Telegram snapshot only when not at home

Posted: Wednesday 18 May 2016 4:34
by fransiefrans
hi,

I want to get snapshots send to telegram when my frontdoor opens and when uservariableor switch nobody home is on.

Since last update there is a possibility to send snapshots in blocky but I think that's only with email notification, not with telegram.

Is it possible to execute a script in blocky?
If not, is there an other solution?

The snapshot.sh script is working only when I execute in putty, somehow not when I put the script in the on-action of a switch. I got it working but when I did a fresh install of domoticz I still didn't manage to get it to work in domoticz. I use script:/// and changed the rights to 755. Any ideas how I could fix this?

Re: Telegram snapshot only when not at home

Posted: Wednesday 18 May 2016 7:32
by Egregius
With my php script and telegram bot integration I receive the snapshot of the motion detection always. But they ony make a notification sound when I'm not a sleep.
For that I use 2 virtual switches: 'Away' and 'Sleep'. They control everything in the home.
Once the switches are there it's as simple as:

Code: Select all

<?php
if($SAway=='Off') shell_exec('/home/pi/script.sh');

Re: Telegram snapshot only when not at home

Posted: Wednesday 18 May 2016 8:18
by fransiefrans
My Domoticz won't execute any sh script. in Putty the snapshots are send to telegram. When I try the same script with an on action I only see:

Code: Select all

Executing script: /home/pi/domoticz/scripts/bash/deurbel.sh


im using the following at on action: script:///home/pi/domoticz/scripts/bash/deurbel.sh
any ideas?

Re: Telegram snapshot only when not at home

Posted: Thursday 16 June 2016 14:27
by fransiefrans
I'm still trying to get the scripts working from domoticz without any luck. Has anyone an idea?

Re: Telegram snapshot only when not at home

Posted: Thursday 16 June 2016 20:56
by Derik
fransiefrans wrote:I'm still trying to get the scripts working from domoticz without any luck. Has anyone an idea?
Perhaps use a dummy switch that you switch with ping your phone or a pir..
And when this dummy is off run the script...

Quotum of attachments sorry

Re: Telegram snapshot only when not at home

Posted: Thursday 16 June 2016 21:01
by fransiefrans
Thanks for your reply.
Is that any different from a doorcontact or dummy switch switched by hand?

Re: Telegram snapshot only when not at home

Posted: Thursday 16 June 2016 21:06
by Derik
i do not understand php or more like that stuff.
Only switching a dummy give more freedom..
To active a script u can use a dummy with http to:
This how i activate a script:

Code: Select all

script:///home/linaro/domoticz/scripts/bash/hue/kachel_1_aan

Please let me see the script..

Re: Telegram snapshot only when not at home

Posted: Thursday 16 June 2016 21:14
by fransiefrans
Im trying the following script on an dummy:

Code: Select all

#!/bin/sh
#SendMsgTo=$1
SendMsgTo=$TelegramChatId
#################################################################
IP="192.168.2.2"                              # IP address Camera
##########################################################
SnapFile=$TempFileDir"snapshot.jpg"
if ping -c 1 $IP > /dev/null ; then  # if IPCAM is online then:
     wget -O - http://192.168.2.1:8080/camsnapshot.jpg?idx=1 > $SnapFile
   sleep 2
   curl -s -X POST "https://api.telegram.org/bot"$TelegramBotToken"/sendPhoto" -F chat_id=$SendMsgTo -F caption="er wordt aangebeld" -F photo="@$SnapFile"
else
   curl --data 'chat_id='$SendMsgTo --data-urlencode 'text=IP-cam niet beschikbaar.' 'https://api.telegram.org/bot'$TelegramBotToken'/sendMessage'
fi

Re: Telegram snapshot only when not at home

Posted: Friday 17 June 2016 8:43
by pj-r
I do the same with rtsp camera in LUA.
TakeSnapshot is virtual switch with 5sec off delay defined. Its becouse rtsp snapshot is quite slow..

Code: Select all

-- snapshot script

commandArray = {}
if (devicechanged['TakeSnapshot'] == 'On') then
        --os_time = os.date("%d.%m.%y %H:%M:%S")
        print('Snapshot!')
        os.execute('/usr/bin/avconv -i rtsp://user:[email protected]:554/ch0_0.h264 -frames:v 1 -an -y /home/user/domoticz/snapshots/snapshot.jpg')
        print('Done')
        
        -- now we can post the image to telegram
        os.execute('/usr/bin/curl -s -X POST "https://api.telegram.org/bot112233445:YOURTOKEN/sendPhoto" -F chat_id=-CHATID -F photo="@/home/user/domoticz/snapshots/snapshot.jpg" &')
end
return commandArray