can you share the script?
a cron task runs at midnight each day, below, "setparms.sh"... this creates two at jobs which run at sunrise and sunset to change the camera parameters. Logs output to /tmp/setparms for reference purposes
setparams.sh:
#!/bin/sh
SUNRISE=`python /root/cameras/py/getsunrise.py`
SUNSET=`python /root/cameras/py/getsunset.py`
# set time to change shutter speed to 1/500
# and turn wdr on
echo at -f /root/cameras/daytime.sh $SUNRISE > /tmp/setparms
echo at -f /root/cameras/daytime.sh $SUNRISE | sh
# set time to close shutter speed to 1/30
# and set wdr off
echo at -f /root/cameras/nitetime.sh $SUNSET >> /tmp/setparms
echo at -f /root/cameras/nitetime.sh $SUNSET | sh
daytime.sh:
#!/bin/sh
for i in 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245; do
RC=`cat /root/cameras/xml/shutterlevel-1000.xml | \
curl -X PUT -s -d @-
http://admin:xxxxxxxxx@172.16.100.$i/ISAPI/Image/channels/1/shutter | \
grep statusCode | \
tr '>' ' ' | tr '<' ' ' | \
awk '{print $2}' `
if [ -n "$RC" ] ; then
if [ $RC -ne 1 ] ; then
echo Error increasing shutter speed on IP address $i
else
echo Increased shutter speed on $i
fi
else
echo Cannot get camera on $i
fi
RC=`cat /root/cameras/xml/wdr-on-50.xml | \
curl -X PUT -s -d @-
http://admin:xxxxxxx@172.16.100.$i/ISAPI/Image/channels/1/WDR | \
grep statusCode | \
tr '>' ' ' | tr '<' ' ' | \
awk '{print $2}' `
if [ -n "$RC" ] ; then
if [ $RC -ne 1 ] ; then
echo Error enabling WDR on IP address $i
else
echo Enabled WDR on $i
fi
else
echo Cannot get camera on $i
fi
done
nitetime.sh:
#!/bin/sh
for i in 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245; do
RC=`cat /root/cameras/xml/shutterlevel-30.xml | \
curl -X PUT --silent -d @-
http://admin:xxxxxxxx@172.16.100.$i/ISAPI/Image/channels/1/shutter | \
grep statusCode | \
tr '>' ' ' | tr '<' ' ' | \
awk '{print $2}' `
if [ -n "$RC" ] ; then
if [ $RC -ne 1 ] ; then
echo Error decreasing shutter speed on IP address $i
else
echo Reduced shutter speed on IP address $i
fi
else
echo Did not find camera at IP address $i
fi
RC=`cat /root/cameras/xml/wdr-off.xml | \
curl -X PUT --silent -d @-
http://admin:xxxxxxxx@172.16.100.$i/ISAPI/Image/channels/1/WDR | \
grep statusCode | \
tr '>' ' ' | tr '<' ' ' | \
awk '{print $2}' `
if [ -n "$RC" ] ; then
if [ $RC -ne 1 ] ; then
echo Error disabling WDR on IP address $i
else
echo Disabled WDR on IP address $i
fi
else
echo Did not find camera at IP address $i
fi
done
py/getsunrise.py:
import ephem
o=ephem.Observer()
o.lat='mylat'
o.long='mylong'
s=ephem.Sun()
s.compute()
print str(ephem.localtime(o.next_rising(s))).replace('.', ' ').split()[1].replace(':', '')[0:4]
py/getsunset.py:
import ephem
o=ephem.Observer()
o.lat='mylat'
o.long='mylong'
s=ephem.Sun()
s.compute()
print str(ephem.localtime(o.next_setting(s))).replace('.', ' ').split()[1].replace(':','')[0:4]
xml/shutterlevel-1000.xml:
<Shutter>
<ShutterLevel>1/1000</ShutterLevel>
</Shutter>
xml/shutterlevel-30.xml:
<Shutter>
<ShutterLevel>1/30</ShutterLevel>
</Shutter>
xml/wdr-off.xml:
<WDR>
<mode>close</mode>
</WDR>
xml/wdr-on-50.xml:
<WDR>
<mode>open</mode>
<WDRLevel>50</WDRLevel>
</WDR>