Cameras and Motion

I’m looking into getting one or more cameras to add to my setup, and I want to pick an ecosystem and go with it. I am currently looking at Armcrest but I don’t have any strong preferences at this point. I’d like to know if any of the cameras out there are capable of signalling motion detection to HA to fire automations, or has anyone put together anything that does this as it will influence my camera choice.

Also, I would be interested in knowing if HA supports PTZ for any camera, either manuall via the UI or via automations.

1 Like

I use Foscam R2 (PTZ capable) cameras, and I’ve been able to integrate them pretty well as they have a CGI interface. A warning right off the bat, though: I can only integrate the camera’s motion detection via polling (I use a scan_interval of 5 seconds). I’ve seen reports that older Foscam cameras had motion detection callback, but Foscam decided to remove that capability.

I’m still working on finetuning the integration and adding new possibilities, but so far I can:

  • View the live video feed (obviously)
  • Move the camera between preset positions
  • Turn the infrared lighting on/off
  • Turn motion detection on/off
  • Detect motion (through polling)

On my current wish list I have:

  • Retrieve a snapshot taken by the camera upon detected motion and send it to my phone through a push notification
  • Install additional light sensors so I can turn the infrared lighting on/off more appropriately

EDIT: All this is done through command_line switches and sensors using the Foscam CGI interface (except for the live video feed which uses the Foscam component in Home Assistant). I’m nowhere near smart enough to develop a component (or expand the existing one).

2 Likes

I’m working on a component for Axis cameras (axis.com). They are quite feature rich and can push motion detection directly to HASS (to the component). They are unfortunately not the cheapest cameras but quality wise they’re great.

What functionality do you need from your camera?

I think I can post a first draft of the component within a week or two. Things have progressed quicker than expected.

/R

1 Like

Thanks for both your replies.

@Robban - I haven’t looked into Axis yet but I will do so. My goal would be to get the following:

  • Live Stream
  • Stills
  • Motion detection and alerting into HA along with a still from the camera (that I could then push out as an alert to my phone)

I would also want the above to work without relying on the cloud, although I also see the value of cloud recording and a decent app.

Ultimately I want the ability to use AppDaemon to signal motion events back to HADashboard and use that to pop up a large video stream over the top of everything, and I would also want to build a camera widget that can do PTZ.

I’m doing the same as @fanaticDavid with Foscams and I have curl commands linked to scripts and an input select to go to my saved PTZ locations.

Pretty much any camera that has a web UI that you can access with a direct URL can work in HA.

1 Like

Of course I’ll be glad to share with you what I found with curl commands and getting them set up - just let me know.

1 Like

OK, based on this feedback I think I will get a couple of Foscams,

1 Like

If I had to do it again ( currently using foscam ) I would absolutely look at Blink! Wireless, BAT Powered, built in temp sensor, and HASS integration

Might even go this route regardless, can’t beat the price!

1 Like

These actually look really good. I’d want to wait until they had the outdoor cam on the list though so I can see what the price is. Could totally see using these indoors though.

A few folks have used the indoor ones outdoors, as long as they don’t get wet it says on the blink site, they are good to go! :slight_smile:

1 Like

@shep

These look promising. Do they have a battery life indicator in their API? I’d like to be proactive about replacing batteries, rather than realize “oh dang, HASS reports the camera as off, now I need to order batteries.” Battery life would be a big concern for me… and are probably the reason why I’d stay away from this vs something that is POE.

1 Like

According to the linked post, there is a separate battery level sensor for each camera

If you are happy with a DIY solution we have a thread on use of raspberry pi camera for motion detection etc Door bell with pi camera and motion detection

1 Like

Annnd this is what I’ve been looking for. Now to write an AppDaemon app for this :slight_smile:

1 Like

Hey any chance you can post your code? I have the R2 and can’t get it to work.

Here’s what I use (per R2 camera):

Switches:

- platform: command_line
  switches:
    camera_bedroom_infrared:
      command_on: 'curl -k "https://192.168.xxx.xx:443/cgi-bin/CGIProxy.fcgi?cmd=openInfraLed&usr=YOURUSER&pwd=YOURPASSWORD"'
      command_off: 'curl -k "https://192.168.xxx.xx:443/cgi-bin/CGIProxy.fcgi?cmd=closeInfraLed&usr=YOURUSER&pwd=YOURPASSWORD"'
      command_state: 'curl -k --silent "https://192.168.xxx.xx:443/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=YOURUSER&pwd=YOURPASSWORD" | grep -oP "(?<=infraLedState>).*?(?=</infraLedState>)"'
      value_template: '{{ value == "1" }}'
    camera_bedroom_motion:
      command_on: 'curl -k "https://192.168.xxx.xx:443/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig1&isEnable=1&linkage=12&snapInterval=1&triggerInterval=10&schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655&width1=10000&height1=10000&sensitivity1=2&valid1=1&usr=YOURUSER&pwd=YOURPASSWORD"'
      command_off: 'curl -k "https://192.168.xxx.xx:443/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig1&isEnable=0&usr=YOURUSER&pwd=YOURPASSWORD"'
      command_state: 'curl -k --silent "https://192.168.xxx.xx:443/cgi-bin/CGIProxy.fcgi?cmd=getMotionDetectConfig1&usr=YOURUSER&pwd=YOURPASSWORD" | grep -oP "(?<=isEnable>).*?(?=</isEnable>)"'
      value_template: '{{ value == "1" }}'

Sensors:

- platform: command_line
  name: "camera bedroom motion"
  command: 'curl -k --silent "https://192.168.xxx.xx:443/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=YOURUSER&pwd=YOURPASSWORD" | grep -oP "(?<=motionDetectAlarm>).*?(?=</motionDetectAlarm>)"'
  value_template: >-
    {%- if value == "0" -%}
      Disabled
    {%- elif value == "1" -%}
      None
    {%- elif value == "2" -%}
      Detected
    {%- endif -%}
  scan_interval: 5

Shell_commands:

camera_bedroom_preset_off: 'curl -k "https://192.168.xxx.xx:443/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Off&usr=YOURUSER&pwd=YOURPASSWORD"'
camera_bedroom_preset_room: 'curl -k "https://192.168.xxx.xx:443/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Room&usr=YOURUSER&pwd=YOURPASSWORD"'
camera_bedroom_zoom_out: 'curl -k "https://192.168.xxx.xx:443/cgi-bin/CGIProxy.fcgi?cmd=zoomOut&usr=YOURUSER&pwd=YOURPASSWORD"'

Scripts (only so I can show the shell_commands in the UI):

camera_bedroom_preset_off:
  sequence:
    service: shell_command.camera_bedroom_preset_off
camera_bedroom_preset_room:
  sequence:
    service: shell_command.camera_bedroom_preset_room
8 Likes

@fanaticDavid can you share your motion detection curl command i cant seem to get mine to work I keep getting:

curl -k "https://192.168.2.165/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=1&usr=USER&pwd=PASSWORD"

<CGI_Result>
    <result>-3</result>
</CGI_Result>

all the other foscam ones work like a charm, but this on which is an R2 V3 does not

I found this at the end. Thanks this solved my issue!!!

how you do this?

Using a command_line sensor with a curl command. I shared the code in my previous post in this thread, a couple of posts up from this one.

I did recently switch from a regular command line sensor to a binary command line sensor. That sensor looks like this:

- platform: command_line
  name: "camera bedroom motion"
  command: 'curl -k --silent "https://xxx.xxx.xxx.xx:443/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=YOURUSER&pwd=YOURPASSWORD" | grep -oP "(?<=motionDetectAlarm>).*?(?=</motionDetectAlarm>)"'
  value_template: >-
    {%- if value == "2" -%}
      motion
    {%- else -%}
      none
    {%- endif -%}
  payload_on: motion
  payload_off: none
  device_class: motion
  scan_interval: 5

device_class: motion makes it so the off state shows as clear in the UI, and on as detected. Bare in mind the actual state of the binary sensor is still off or on. And don’t forget to replace xxx.xxx.xxx.xx with the ip address of your Foscam camera, as well as YOURUSER and YOURPASSWORD with your correct credentials.