Cameras and Motion

Those trying to get the Foscam motion sensor to work with hassio, hassio’s docker image does not support the “P” option used in the grep command.
changing it to something like:

command: 'curl -k --silent "https://ip:443/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=USER&pwd=PASSWORD" | grep motionDetectAlarm | cut -b 24'

Should bypass the issue.

For those gooogling. My solution (rather than polling) was to set up a FTP server in HASSIO. Have snapshots on motion sent to the FTP server and than watch the FTP directory for file writes. I am using node red to do the automation and it is pretty quick (normally file write starts < 1 sec from motion. See to be vworking for me. Seems better to me than polling but each has its pros and cons

HA 0.98 includes Minio support, allowing files to be Put to the server and events triggered

Great, seems like a great idea, looking forward to checking it out

1 Like

I have a cheapy Vstarcam which uses the same API/Commands and from the command line I can get it to return a “0” or a “1” if motion is detected but when creating a command line binary sensor it never updates… also the returned value from command line comes up in red text which I thought was odd… was wondering if anyone can tell if I’m missing something simple…

- platform: command_line
  name: Vstarcam Motion
  command: 'curl -k --silent "http://192.168.1.XX:XXXX/get_status.cgi?user=XXXXX&pwd=XXXXXX" | grep -oP "(?<=alarm_status=).*?(?=;)"'
  value_template: '{{ value == "1" }}'

I got it to work with a rest binary_sensor I found in another post, just wanted to post it for anyone else looking in the future… thanks. (Would still appreciate if anyone knows why the command_line sensor didn’t work)

- platform: rest
  name: "Vstarcam Motion"
  resource: http://192.168.1.XX:XXXX/get_status.cgi?user=XXXXX&pwd=XXXXXX
  device_class: motion
  scan_interval: 2
  value_template: >-
    {%- if "alarm_status=1" in value -%}
      {{ true }}
    {%- else -%}
      {{ false }}
    {%- endif -%}

Never updates, or always shows no motion ?
Unless you set scan_interval: it defaults to 60 second updates.
I’ve set mine at 5 seconds.

I’ll have to try again, I did set a scan interval but not until a time I had also changed the value template to be more like the “rest” one… so maybe the value template change broke it enough that the scan interval didn’t matter…

So I just tried the command line sensor again with the scan interval set to 3 seconds (same as current rest sensor) and the rest sensor shows motion and binary sensor shows nothing, no errors in log…

I don’t use a binary_sensor. I use a regular sensor since it’s possible to have other values get returned.

But here’s an example of my sensor:

sensor:
  - platform: command_line
    name: "Kitchen Camera Motion"
    command: curl -k --silent "http://192.168.1.51:8001/get_status.cgi?user=xxxx&pwd=yyyyyyyy"
    value_template: >-
      {% set status = value | regex_findall_index('alarm_status=(\d+);') %}
      {%- if status == "0" -%}
        None
      {%- elif status == "1" -%}
        Detected
      {% else %}
        Not Determined
      {%- endif -%}
    scan_interval: 3