Hikvision Night/Day Windows Service

mlapaglia

Getting comfortable
Joined
Apr 6, 2016
Messages
849
Reaction score
506

Tolting Colt Acres

Pulling my weight
Joined
Jun 7, 2016
Messages
379
Reaction score
153
I wrote a linux shell script to do this quite some time ago.

this runs every day at midnite to execute a script at a set time each day (one at sunrise, one at sunset)

Code:
#!/bin/sh

SUNRISE=`python /root/cameras/py/getsunrise.py`
SUNSET=`python /root/cameras/py/getsunset.py`

echo at -f /root/cameras/daytime.sh $SUNRISE | sh
echo at -f /root/cameras/nitetime.sh $SUNSET | sh
getsunrise.py:
Code:
import ephem 
o=ephem.Observer() 
o.lat='my_latitude_goes_here'
o.long='my_longitude_goes_here'
s=ephem.Sun() 
s.compute() 
print str(ephem.localtime(o.next_rising(s))).replace('.', ' ').split()[1].replace(':', '')[0:4]
getsunset.py:
Code:
import ephem 
o=ephem.Observer() 
o.lat='my_latitude_goes_here'
o.long='my_longitude_goes_here'
s=ephem.Sun() 
s.compute() 
print str(ephem.localtime(o.next_setting(s))).replace('.', ' ').split()[1].replace(':','')[0:4]

and then finally the scripts which run at sunrise/sunset to change parameters:

daytime.sh
Code:
for i in 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 247; do
   RC=`cat /root/cameras/xml/shutterlevel-1000.xml | \
   curl -X PUT -s -d @- http://mypass@192.168.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://mypass@192.168.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
...and then a similar script which runs at night to change the shutter speed to a lower setting and turn WDR off.

Adapt the scripts as necessar with the ISAPI commands you deem necessary.
 
Top