Hikvision Scene Change

I’m trying to get my Hikvision DS-2CD2087G2-L to change scenes from “Normal” to “Low Illumination” through a shell command in Home Assistant with no luck. I have set up the following:

In configuration.yaml:

shell_command:
  hik3_night: curl -k --silent -H "Content-Type:application/xml" -X PUT -d '<?xml version="1.0 encoding="UTF-8"?><MountingScenario><mode>lowIllumination</mode></MountingScenario>' http://CAMERA_IP/ISAPI/Image/channels/3/mountingScenario --digest -u user:pass

Then I call the shell command service to run it and it returns the following:

stdout: |-
  <?xml version="1.0" encoding="UTF-8" ?>
  <ResponseStatus version="2.0" xmlns="http://www.isapi.org/ver20/XMLSchema">
  <statusCode>4</statusCode>
  <statusString>Invalid Operation</statusString>
  <subStatusCode>notSupport</subStatusCode>
  </ResponseStatus>
stderr: ""
returncode: 0

What am I doing wrong?

For those in the same situation, I have figured it out. I have cameras connected to a Hikvision NVR, in this specific case, it’s camera 3 on POE port 65003. Ensure that the Image Parameters Switch is disabled. The following code can be put into the configuration.yaml:

shell_command:
  Hik3_normal: curl -k --silent -H "Content-Type:application/xml" -X PUT -d '<?xml version="1.0 encoding="UTF-8"?><MountingScenario><mode>normal</mode></MountingScenario>' http://CAMERA_IP:65003/ISAPI/Image/channels/1/mountingScenario --digest -u user:password
  Hik3_lowillumination: curl -k --silent -H "Content-Type:application/xml" -X PUT -d '<?xml version="1.0 encoding="UTF-8"?><MountingScenario><mode>lowIllumination</mode></MountingScenario>' http://CAMERA_IP:65003/ISAPI/Image/channels/1/mountingScenario --digest -u user:password

Then from any automation you can call the service “shell command” to execute it off any trigger/condition.

1 Like

Thank you so much, I saw your post about this on the CCTV forum too.

I had issues with this because I was capitalising the first letter of the mode Normal > normal (don’t use capitals) because that’s how the UI displays them. Just in case anyone else is wondering, you’ll probably have to change the port to 80 too unless you’ve changed that port.
Am using this in an automation with two Annke (Hik consumer brand) cameras and outdoor lux sensor so I don’t have to faff with sunrise and sunset time changes throughout the year.

1 Like

Thanks for this. This isn’t mentioned in the API docs I have for some reason. I prefer to use the restful command as it’s much simpler, plus you can do a quick reload of the restful YAML config for testing.

I run Frigate, so no NVR to worry about.

rest_command:
  front_normal_mode:
    url: "http://user:pass@CAMERA_IP/ISAPI/Image/channels/1/mountingScenario"
    method: PUT
    payload: <mode>normal</mode>
1 Like