Bulk Updating Foscam Parameters

Quick and dirty updating of the Foscam presets on my camera
October 29, 2016
foscam decoder_control

I have one Foscam IP camera that is supposed to be focused on a door. Every few days he rotates up to some other angle and stops looking at the door. I think it’s a legacy preset position, so today I dug into it further.

There’s an API for Foscam cameras. (This is a link to a file in a Github repo where a guy has made a Python library for doing a lot of the heavy lifting, but the API is directly accessible over HTTP).

With that in hand, I simply looped a curl call to set all 16 presets to the current position:

set user "admin" 
set pass "password" 
for x in (seq 32 2 64) 
  set url "http://my.camera.address/decoder_control.cgi?command=$x&user=$user&pwd=$pass" 
  curl $url 
end

This is for the fish shell, but a comparable bash version would be:

user="admin" pass="password"; for x in $(seq 32 2 64); do 
  url="http://my.camera.address/decoder_control.cgi?command=$x&user=$user&pwd=$pass"
  echo $url 
done

Hopefully now he’ll stay pointing at the door.

(UPDATE - 2016-11-16)

So, it’s been a few weeks, and that camera still randomly points at the ceiling. It’s possessed.