Enable lights by motion detection camera

Post Reply
Spanky899
Posts: 2
Joined: Wednesday 17 January 2018 5:59
Target OS: Raspberry Pi
Domoticz version: v3.8153
Contact:

Enable lights by motion detection camera

Post by Spanky899 » Wednesday 17 January 2018 6:20

Hi all,

What i want to do is as follow:
When my camera detects motion (foscam c1), the lights must be go on and after a time, the lights must be go off automatically.
I have added the camera and the lights in domoticz and thats working.
In domoticz the camera don't have a idx unlike the lights.
How can i make the link between the motion of the camera and the lights?

The web interface of the camera is configured when motion is detected, the images are forwarded to an ftp server.
Do i have to add a dummy switch and configure the dummy switch with an script or something?
Or is this only possible with a real motion detector?

SweetPants
Posts: 2064
Joined: Friday 12 July 2013 21:24
Target OS: Linux
Domoticz version: V3.9651
Location: The Netherlands
Contact:

Re: Enable lights by motion detection camera

Post by SweetPants » Wednesday 17 January 2018 8:59

Unless your camera is capable of sending something to domoticz, this is not going to work easely. If your camera is able to send email (and trigger an action) or something like an SNMP trap, you might be able to use the camera motion detector. Otherwise you have to use a separate PIR or other kind of motion detector. I myself use these https://www.ebay.com/itm/Motion-Sensor- ... SwAYJZhV3b , nice thing is they can 'look' through walls so you don't see them. But this requires some capabilities of hardware designing/building
Ubuntu 16.04.3 LTS, Intel NUC, MySensors 2.3.0-alpha, Pro Mini 3.3/8M RFM69(HW), ESP8266 (SDK2.2.0), Sonoff, RFLink, RFXcom, MQTT, NodeRed, Domoticz Beta (source)

lost
Posts: 168
Joined: Thursday 10 November 2016 10:30
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Enable lights by motion detection camera

Post by lost » Wednesday 17 January 2018 10:05

Spanky899 wrote:
Wednesday 17 January 2018 6:20
The web interface of the camera is configured when motion is detected, the images are forwarded to an ftp server.
Do i have to add a dummy switch and configure the dummy switch with an script or something?
Or is this only possible with a real motion detector?
On my side, I've a similar setup working. But as it is not a Domoticz feature to be able to monitor a FTP directory for new images resulting from camera motion detection, I've done this through a python script executed as a Linux service that control some domoticz virtual switches (declared as PIRs) using the http API.

So this can be done, but requires some program skills.

On my side, this is linked to alarm function so a bit more complex than what would be required to just switch-on lights: False positive are not the same problem as it may not fire-up a siren at night! And for cameras, rejecting false positive is not so easy. Even with in-cam flexible sensitivity & motion zones setup to reject zones when light may vary a lot with clouds or vegetation move with wind, this may still be a challenge with neighborhood cats passing by of even birds, spiders... This requires as well to e-mail captures & as this is private data but gmail is quite reliable, to send them in password protected archives (another feature domoticz does not propose).
So the python service monitor FTP directory (a tmpfs in ram not to wear the PI SD) for each camera every 10s for new captures. If some are there, they are archived & sent through gmail + domoticz virtual PIR for the cam receives an "on for xx" seconds command through http api. Then captures are then locally erased (only copied to SD if gmail does not work at the moment, never arrived in more than a year).

alanlsmith
Posts: 76
Joined: Monday 07 August 2017 17:17
Target OS: Linux
Domoticz version: 3.8153
Location: Near London
Contact:

Re: Enable lights by motion detection camera

Post by alanlsmith » Wednesday 17 January 2018 11:45

I might be worth having a look at this:

Code: Select all

https://www.domoticz.com/wiki/Camera_Setup#Using_your_camera_as_motion_sensor
and monitor changes in the camera snapshot image to trigger a switch in Domoticz.
Domoticz v3.8153 stable, Ubuntu 18.04 on Intel NUC i3, 8Gb ram, 70Gb drive, RFXtrx433 & z-wave

User avatar
EddyG
Posts: 238
Joined: Monday 02 November 2015 6:54
Target OS: Raspberry Pi
Domoticz version: 3.9517
Location: Rhenen, Netherlands
Contact:

Re: Enable lights by motion detection camera

Post by EddyG » Wednesday 17 January 2018 12:44

That part on the Wiki works, but complicated to setup.
Besides that it takes a LOT of CPU power.
If you have a Foscam it is possible to poll the camera by cron and get motiondetection.
Something like this:

Code: Select all

    # Get data from status.txt and place text status.txt in new file named FOSCAM.txt
    curl $CURL_PARAM "http://$FOSCAM_IP_IN:$FOSCAM_PORT_IN/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=admin&pwd=xxxx" > tmp/Foscam.txt

    # FOSCAM Status
    FOSCAMStatus=`grep -oP '(?<=<motionDetectAlarm>).*(?=<\/motionDetectAlarm>)' /tmp/Foscam.txt`
    MOTIONStatus=`curl -s -H "Accept: application/json" "http://$DomoticzIP:$DomoticzPort/json.htm?type=devices&rid=$FOSCAM_MOTION_IDX_IN" | jq r .result[]."Status"`
    echo $FOSCAMStatus
    echo $MOTIONStatus
Regards,
Eddy

Spanky899
Posts: 2
Joined: Wednesday 17 January 2018 5:59
Target OS: Raspberry Pi
Domoticz version: v3.8153
Contact:

Re: Enable lights by motion detection camera

Post by Spanky899 » Thursday 18 January 2018 0:44

Thanks a lot for the replies. I thought it was pretty good to do.
I think i'm going to buy a motion sensor.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests