IP camera motion detector

Is it possible to trigger an action if motion is detected on my IP Camera? I am connected to a Foscam C1 camera via the Generic IP Camera component (I wasn’t able to get HASS to connect to it using the Foscam component).

For example:

automation: alias: Motion Detector trigger: platform: state entity_id: camera.my_camera from: idle to: motion_detected condition: use_trigger_values action: # Do some action...

2 Likes

With my foscam I can check here: http://camURLorIP:88/cgi-bin/CGIProxy.fcgi?usr=USERNAME&pwd=PASSWORD&cmd=getDevState
then I get the following response: <CGI_Result> <result>0</result> <IOAlarm>0</IOAlarm> <motionDetectAlarm>0</motionDetectAlarm> <soundAlarm>0</soundAlarm> <record>0</record> <sdState>0</sdState> <sdFreeSpace>0k</sdFreeSpace> <sdTotalSpace>0k</sdTotalSpace> <ntpState>1</ntpState> <ddnsState>0</ddnsState> <url>URL</url> <upnpState>1</upnpState> <isWifiConnected>1</isWifiConnected> <wifiConnectedAP>WIFI</wifiConnectedAP> <infraLedState>0</infraLedState> </CGI_Result>

motionDetectAlarm is what you are looking for, but I think it might be easier to just watch a folder for the camera write a new picture to it. Then act on that instead of constantly polling “are you alarming now?”

2 Likes

Could you possibly, send the code for what you did to activate motion detection in the Foscam camera?

Sorry I haven’t logged into this site in a while.

http://camURL:88/cgi-bin/CGIProxy.fcgi?usr=USERNAME&pwd=PASSWORD&cmd=setMotionDetectConfig&isEnable=1

Then I add other option to the URL to set the motion detection area:
&area0=48&area1=48&area2=48&area3=48&area4=48

Then I set the schedule to be 24/7 so it doesn’t shut off automatically:
schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655

Then I set the snap interval, sensitivity, trigger interval:
&snapInterval=3&&sensitivity=1&triggerInterval=5

Whole thing looks like this:
http://camURL:88/cgi-bin/CGIProxy.fcgi?usr=USERNAME&pwd=PASSWORD&cmd=setMotionDetectConfig&isEnable=1&linkage=14&snapInterval=3&&sensitivity=1&triggerInterval=5&schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655&area0=48&area1=48&area2=48&area3=48&area4=48

1 Like

I took a different approach as I wanted to record video as well (haven’t figured out how to do that through HASS yet) and have an old Android phone that I leave plugged in and running that serves as my monitor running tinyCam. When motion is detected it emails me a screenshot and records video and using Tasker I have it trigger some automations in HASS.

https://www.youtube.com/watch?v=4Opkj-uopSg

1 Like

Anyone solved this for Ubiquiti cameras?

2 Likes

I finally was able to get a binary sensor created to reflect in-camera motion detection of my FDT camera. FDT cameras are very similar to Foscam, but they don’t have a corresponding cgi command that I could use to trigger automations in Home Assistant (at least that I could find). Here are the steps in case anyone else could use them. Basically, the binary sensor is “on” when motion was detected within the past 60 seconds.

  1. Temporarily install the “FDT View” app on your phone.
  2. Connect to the camera on the app and under settings -> alert, select push notifications.
  3. Add this to configuration.yaml changing CAMERAIP to your ip address:
sensor:
  - platform: command_line
    name: fdt motion raw
    command: "curl -s -k http://CAMERAIP/web/tmpfs/push_record.log | tail -1 | cut -c3-"
    value_template: "{{ as_timestamp(now()) | float - value | float }}"
binary_sensor:
  - platform: template
    sensors:
      fdt_motion:
        friendly_name: "FDT Motion"
        value_template: >-
           {{ states('sensor.fdt_motion_raw') | float < 60 }}
  1. Remove app from phone

Also, my motion trigger was too sensitive, and I couldn’t properly set the sensitivity from the webpage configuration so I used the following command. Play with the “s=xx” option to find the right sensitivity for you (0-100):

curl -k "http://CAMERAIP/cgi-bin/hi3510/param.cgi?cmd=setmdattr&-enable=1&-s=10&-name=1&-x=0&-y=0&-w=1920&-h=1080&-usr=admin&-pwd=xxxxxxxx"

Hi frelev,

I have the video integrated into HA for my Ubiquiti G4 Pro cameras.
But haven’t been able to get the motion detection yet. Did you?