Use Old Foscam FI8909W Camera for Home Assistant Motion Detection and More

Maybe you still have one of these old foscam camera laying around and collecting dust? You don't really have to break your bank account to purchase those fancy security camera to enjoy motion detection and more advanced features with home assistant. In this article, I am going to show you how to re-use these old cameras for motion detection and more advanced home assistant tasks to make your life easier!

1. Basics of Foscam FI8909W

Foscam FI8909W

I purchased 2 Foscam FI8909W perhaps 10 years ago when RTSP security cameras were still very rare. These Foscam wireless cameras have 640X480 resolution and basic features via the web GUI. Unfortunately it's firmware stopped being updated years ago so home assistant support is very limited. People integrated them via generic camera or MJPEG camera in home assistant.

In order to secure the camera access, I would strongly recommend set a username/password via the web GUI, as well as enable Motion Detect Armed under Alarm Service Settings. Other settings can be configured according to your own preferences. foscam alarm setting

Userful CGI command of the Foscam FI8909W

These command would be very helpful when integrated with home assistant

To retreive current camera status

http://192.168.x.x/get_status.cgi?user=admin&pwd=123456

Output:

 1var id='000DC5DBFB8E';
 2var sys_ver='11.40.2.46';
 3var app_ver='2.4.91.17';
 4var alias='FrontCam';
 5var now=1664303995;
 6var tz=28800;
 7var alarm_status=0;
 8var ddns_status=0;
 9var ddns_host='';
10var oray_type=0;
11var upnp_status=5;
12var p2p_status=0;
13var p2p_local_port=23321;
14var msn_status=0;
15var wifi_status=1;

Get current video stream

http://192.168.x.x/videostream.cgi?user=admin&pwd=123456

This will output a real-time MJPEG stream

2. Prepare integration for Home Assistant motion detection

First of all, we need a command line binary sensor created.

1- platform: command_line
2  name: "Front Camera Motion"
3  device_class: motion
4  command: 'curl -k --silent "http://192.168.x.x/get_status.cgi?user=admin&pwd=123456" | grep alarm | cut -b 18'
5  payload_on: "1"
6  payload_off: "0"
7  scan_interval: 3

Adding the above to your configuration.yaml will create a motion sensor from the camera. This motion sensor utilizes the build-in alarm service provided by foscam. This method is prone to light change therefore not 100% accruate.

For advanced usage, it's recommended to use Frigate for locally processed AI deteced objects to reduce false positives. Once the camera is added in Frigate, some motion sensors will be generated automatically.

3. Usages of the Foscam motion sensor

Now with or without Frigate, we have turned the old Foscam camera into a security camera that support motion detection. We could create automations to trigger various actions when a motion is detected in the target areas.

I have put one of the foscam camera in my porch, as well as two wifi smart bulbs. One of my favorite automations is to brighten up my front door porch light to 100% brightness when motion detected, and darken the light to 15% brightness after motion is cleared to save energy. Note that condition of sun.below_horizon is added to not trigger the automation during daytime.

The automation YAML is below:

 1alias: Bright up porch light on motion
 2trigger:
 3  - platform: state
 4    entity_id:
 5      - binary_sensor.front_camera_motion
 6    to: "on"
 7condition:
 8  - condition: state
 9    entity_id: sun.sun
10    state: below_horizon
11action:
12  - service: light.turn_on
13    data:
14      brightness_pct: 100
15    target:
16      entity_id:
17        - light.smart_lighting_tunable_white_and_color
18        - light.smart_lighting_tunable_white_and_color_2
19mode: single
20
 1alias: Darken porch light when no motion
 2trigger:
 3  - platform: state
 4    entity_id:
 5      - binary_sensor.front_camera_motion
 6    to: "off"
 7    for:
 8      hours: 0
 9      minutes: 1
10      seconds: 0
11condition:
12  - condition: state
13    entity_id: sun.sun
14    state: below_horizon
15action:
16  - service: light.turn_on
17    data:
18      brightness_pct: 15
19    target:
20      entity_id:
21        - light.smart_lighting_tunable_white_and_color_2
22        - light.smart_lighting_tunable_white_and_color
23mode: single
24
comments powered by Disqus

Translations: