Using Hikvision HTTP API request with MSR
-
I have a Hikvision camera for a month and have been playing with it. Now I read a post of cw-kid (post : System integration roadmap) that you can control the camera by HTTP API request. That's cool if that also will work for me. Can someone explain what to enter in MSR for HTTPS request command to do so. (Marked red arrows)
I want to turn the smart supplement light on and off at a specific time. Now I do that with scheduled switch, but it is better to control that with sunrise and sunset function with MSR. I'm curious how it works.
-
Here is an example of what I did with my Hikvision camera settings using MSR and ISAPI to change the scheduled switch (day/night) based on sunrise/sunset daily etc. Nearly all configurable options on the Hikvision can be changed with ISAPI.
HTTP Request: PUT
Request URL:http://user:pass@ipcamaddr:80/ISAPI/Image/channels/1/ISPMode
Request Header:Content-Type: application/xml
Request Body:<ISPMode xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"> <mode>schedule</mode> <Schedule> <scheduleType>day</scheduleType> <TimeRange> <beginTime>${{hikvision_sunrise}}</beginTime> <endTime>${{hikvision_sunset}}</endTime> </TimeRange> </Schedule> </ISPMode>
Capture response to:
text_response
set the following expressions:
text_response= hikvision_sunrise=strftime( "%R" , ( getEntity( "reactor_system>sun" ).attributes.suninfo.sunrise + ( 30 * 60 * 1000 ) ) ) hikvision_sunset=strftime( "%R", ( getEntity( "reactor_system>sun" ).attributes.suninfo.sunset - ( 30 * 60 * 1000 ) ) )
I offset the sunrise and sunset time by 30 mins both ways (30 * 60 * 1000). You can use civil dusk and civil dawn too if that works better for you.
For IRCut Filter, which is where the supplemental light setting is located, set it to ON then control it with the scheduled switch (there is no ISAPI to set it on/off unfortunately)
Request:
http://user:passipcamaddr:80/ISAPI/Image/channels/1/IrcutFilter
Header is the same as above
Body:<IrcutFilter xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"> <IrcutFilterType>schedule</IrcutFilterType> <nightToDayFilterLevel>4</nightToDayFilterLevel> <nightToDayFilterTime>5</nightToDayFilterTime> <Schedule> <scheduleType>day</scheduleType> <TimeRange> <beginTime>${{hikvision_sunrise}}</beginTime> <endTime>${{hikvision_sunset}}</endTime> </TimeRange> </Schedule> </IrcutFilter>
With ISAPI, there are many more things you can set on the camera without using the GUI.
-
Thanks for the quick response. I'm playing with it but I get an error when input expression.
@toggledbits Is this due to the prerelease MSR? I am using version (pre-release) 0.1-21096. I haven't upgraded to new version yet -
Thanks for the quick response. I'm playing with it but I get an error when input expression.
@toggledbits Is this due to the prerelease MSR? I am using version (pre-release) 0.1-21096. I haven't upgraded to new version yet@edwin1972 said in Using Hikvision HTTP API request with MSR:
Is this due to the prerelease MSR? I am using version (pre-release) 0.1-21096. I haven't upgraded to new version yet
Yes
-
@toggledbits I have updated MSR to latest-21258-6fb388e but still get the same error
-
Then your update didn't work, or MSR is not starting correctly because NODE_PATH is not defined or not correctly defined.
-
Here is an example of what I did with my Hikvision camera settings using MSR and ISAPI to change the scheduled switch (day/night) based on sunrise/sunset daily etc. Nearly all configurable options on the Hikvision can be changed with ISAPI.
HTTP Request: PUT
Request URL:http://user:pass@ipcamaddr:80/ISAPI/Image/channels/1/ISPMode
Request Header:Content-Type: application/xml
Request Body:<ISPMode xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"> <mode>schedule</mode> <Schedule> <scheduleType>day</scheduleType> <TimeRange> <beginTime>${{hikvision_sunrise}}</beginTime> <endTime>${{hikvision_sunset}}</endTime> </TimeRange> </Schedule> </ISPMode>
Capture response to:
text_response
set the following expressions:
text_response= hikvision_sunrise=strftime( "%R" , ( getEntity( "reactor_system>sun" ).attributes.suninfo.sunrise + ( 30 * 60 * 1000 ) ) ) hikvision_sunset=strftime( "%R", ( getEntity( "reactor_system>sun" ).attributes.suninfo.sunset - ( 30 * 60 * 1000 ) ) )
I offset the sunrise and sunset time by 30 mins both ways (30 * 60 * 1000). You can use civil dusk and civil dawn too if that works better for you.
For IRCut Filter, which is where the supplemental light setting is located, set it to ON then control it with the scheduled switch (there is no ISAPI to set it on/off unfortunately)
Request:
http://user:passipcamaddr:80/ISAPI/Image/channels/1/IrcutFilter
Header is the same as above
Body:<IrcutFilter xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"> <IrcutFilterType>schedule</IrcutFilterType> <nightToDayFilterLevel>4</nightToDayFilterLevel> <nightToDayFilterTime>5</nightToDayFilterTime> <Schedule> <scheduleType>day</scheduleType> <TimeRange> <beginTime>${{hikvision_sunrise}}</beginTime> <endTime>${{hikvision_sunset}}</endTime> </TimeRange> </Schedule> </IrcutFilter>
With ISAPI, there are many more things you can set on the camera without using the GUI.
-
T toggledbits locked this topic on