
Foscam cameras are controlled through a web interface. The web interface has commands for changing brightness, contrast, and even rebooting the camera. You can run these commands by visiting specific URL’s. For example, to reboot the camera visit:
1 | http://192.168.1.110:8080/reboot.cgi?user=admin&pwd=password |
http://192.168.1.110:8080/reboot.cgi?user=admin&pwd=password
Where 192.* is your address and port, and user=<your username>, and pwd=<your password>. This will reboot the camera without you having to login and actually click Reboot.
Because we have the ability to execute commands from a single URL, they can be automated by having a web browser run them at a specific time and interval. Instead of keeping open a web browser on our computer – and having to refresh the commands using META or JavaScript, we can use a command-line web browser like Lynx with Windows Task Scheduler.
Below I explain how this is done.
Download and install Lynx for Windows
Direct link: http://csant.info/downloads/lynx_setup-2.8.5rel-1.zip
Author’s website: http://csant.info/lynx.htm
In Notepad
Now we will create a BATCH file that we can run on a scheduled basis
In Notepad you will type in your batch commands, then go to File.. Save As, for Save as type choose All Files — and for the filename do something like Foscam1.bat – .bat is the BATCH file extension
Batch Example 1
ReduceBrightness.bat
To reduce brightness during direct-sunlight I use the following BATCH commands:
1 2 3 4 | cd C:\lynx lynx "http://192.168.1.110:8080/camera_control.cgi?param=1&value=51&user=admin&pwd=password" -dump lynx "http://192.168.1.110:8080/camera_control.cgi?param=1&value=68&user=admin&pwd=password" -dump lynx "http://192.168.1.110:8080/camera_control.cgi?param=1&value=51&user=admin&pwd=password" -dump |
cd C:\lynx lynx "http://192.168.1.110:8080/camera_control.cgi?param=1&value=51&user=admin&pwd=password" -dump lynx "http://192.168.1.110:8080/camera_control.cgi?param=1&value=68&user=admin&pwd=password" -dump lynx "http://192.168.1.110:8080/camera_control.cgi?param=1&value=51&user=admin&pwd=password" -dump
Param 1 is brightness, we are changing the brightness from 51 to 68 back to 51
I change it to 51 twice in order to toggle the setting. Sometimes just changing the brightness does not take effect, I have to change it to a higher value and then back to a lower value
Batch Example 2
ResetBrightness.bat
I use the following commands to reset the camera’s brightness and contrast to default settings as well as restart the camera. I do this at the end of the day when it’s getting dark. This keeps the camera from going black like it would with lower brightness settings at night:
1 2 3 4 | cd C:\lynx lynx "http://192.168.1.110:8080/camera_control.cgi?param=1&value=68&user=admin&pwd=password" -dump lynx "http://192.168.1.110:8080/camera_control.cgi?param=2&value=4&user=admin&pwd=password" -dump lynx "http://192.168.1.110:8080/reboot.cgi?user=admin&pwd=password" -dump |
cd C:\lynx lynx "http://192.168.1.110:8080/camera_control.cgi?param=1&value=68&user=admin&pwd=password" -dump lynx "http://192.168.1.110:8080/camera_control.cgi?param=2&value=4&user=admin&pwd=password" -dump lynx "http://192.168.1.110:8080/reboot.cgi?user=admin&pwd=password" -dump
Schedule the BATCH files to run
Once your batch files are created, you can schedule them to run using Windows Task Scheduler, you can find it under Administrative Tools/Task Scheduler
When in Task Scheduler, click on Task Scheduler Library folder on the left side tree view
On the right, click on Create Task
General Tab
In the General tab, type in the name of your task like FOSCAM Reduce Brightness
I like to select Run whether user is logged on or not, and then UNCHECK Do not store password
In the bottom right of this tab you will see a Hidden checkbox, put a CHECK into this box, this will mean our BATCH file will run silently in the background
Trigger Tab
Next go to the Triggers tab and click New for a New Trigger
Select the Daily radio button
For my ReduceBrightness.bat I have it run every day at 10 AM when the camera is getting the most sunlight, set the Start date to 10 AM today, or 10 AM tomorrow (whichever hasn’t occurred yet)
Click Ok and the Trigger should now be saved in the list
You can add more triggers, to reduce brightness several times in the day, I actually have ReduceBrightness.bat run every hour during the brightest parts of the day – even though its resetting it to 51 each time – it keeps the camera from getting washed out
Actions Tab
Now go to the Actions tab and do a New action, select Start a program and browse to where your .bat file is located and select it
Hit Ok and it will be added to the Actions list
You won’t need to change any of the other settings
Click OK to save your Task.
At this point it should ask you for a Username and Password for your computer (if you have one), so that it can run whether you are logged in or not
Now that your Reduce Brightness task is created, you can repeat the same steps for the Reset Brightness task, which I like to run around 7PM when it’s getting dark
Other Settings
You can do much more than reducing brightness and resetting brightness, take a look at edelske’s script he made for controlling all of the Foscam settings:
http://foscam.us/forum/fi8918w-html-control-view-any-browser-phones-too-free-t521.html
You can derive the values of other params/settings from his work
This post is mirrored on Foscam’s forums:
http://foscam.us/forum/tip-how-to-schedule-reboots-and-brightness-changes-silently-t748.html
For some reason I am unable to get lynx to work. What version did you use?
Thanks,
PSH
PSH,
I used a Lynx port found on this site http://csant.info/lynx.htm
I was able to get it to work on Windows 7 x64 without any issue
What problem are you encountering?
Fantastic write-up. Very detailed, and informative. I got this working first try, thanks to this article. Very cool!