Foscam - easily add motion sensor and other control

That was it. I was at my wits end. Thank you sooo much.

@ReneTode helped me with the same problem the other day!

1 Like

Thank you helped me greatly

Here is my motion sensor configuration:

sensor:
  - platform: command_line
    name: Foscam PIR
    command: !secret camera_corridor_PIR
    value_template: "{{ value | regex_findall_index('<motionDetectAlarm>(.*)</motionDetectAlarm>') == '2' }}"
    scan_interval: 20
    command_timeout: 120

Switch for PTZ:

switch:
  - platform: command_line
    switches:
        ptz_foscam:
            command_on: !secret camera_corridor_new_office
            command_off: !secret camera_corridor_koridor
            friendly_name: PTZ Foscam

And RTSP:

camera:
  - platform: generic
    name: "Foscam"
    stream_source: !secret camera_corridor_rtsp
    still_image_url: !secret camera_corridor_image
    verify_ssl: false

URL:

secret:
#camera_corridor_PIR: "/usr/bin/curl -s -X GET 'http://192.168.15.21:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=mike&pwd=PASS' | grep -o -e '<motionDetectAlarm>.*</motionDetectAlarm>'"
camera_corridor_PIR: "/usr/bin/curl -X GET 'http://192.168.15.21:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=mike&pwd=PASS'"
camera_corridor_rtsp: rtsp://mike:[email protected]:88/videoSub #videoMain
camera_corridor_image: http://192.168.15.21:88/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=mike&pwd=PASS
camera_corridor_new_office: "/usr/bin/curl -X GET 'http://192.168.15.21:88/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=New&usr=mike&pwd=PASS'"
camera_corridor_koridor: "/usr/bin/curl -X GET 'http://192.168.15.21:88/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Koridor&usr=mike&pwd=PASS'"

I added in-camera motion detection for my FDT camera which may (or may not) give some ideas for Foscam users. See post here: