With this command line switch it’s possible to turn on and off and update the internal schedule of the super-bright white LED on the ColorVU Hikvision cameras.
The switch toggles the checkbox corresponding to “System Settings > External Device > Enable Supplement Light” in the web UI of the camera. One would want to do this temporarily because the LED is so bright that it may be annoying to people spending some time on the area watched by the camera. There’s an automation included which turns it back on after 2 hours, just in case someone forgets to do do this.
I’ve added to the example a shell_command and an automation to update every day the LED operation schedule on the camera, for those not satisfied by the automatic mode.
It turned out in my case that the LED wouldn’t turn on by itself at night on certain cameras. It seems the built-in automation is disturbed by the LEDs of the others. But thankfully there is a different way to use it, scheduled. With this, mode is switched in the camera from “Auto” to “Scheduled” and it turns ON automatically 1 hour after sunset, and OFF 30mins before sunrise. The ON/OFF times in the camera are updated every day by a template in Home Assistant.
Note that the ON/OFF swicth is more complicated in schedule mode, as the camera requires the whole XML (including the schedule time) to toggle the state of the checkbox… and since the command_line switch doesn’t accept templates, the shell_command has to be run again after switching to re-update the dummy values set by the switch. Quite dirty but usable.
Tested and working with DS-2CD2T47G1-L firmware v5.6.5.
I’m pretty sure the idea of the light is to turn it ON when you suspect there is someone suspicious hanging around so you get colour video of them rather than black & white for identity purposes. It’s not supposed to be ON all the time and turned OFF when you don’t like it…
Nope, that LED gives enough light for the camera to produce a colorful picture in complete darkness. You usually want to keep it ON all night (with “Enable Supplement Light” it turns on and off automatically whenever the camera needs it, ie. only when it’s really dark). You can’t really just turn it on when “there is someone suspicious hanging around” because without it you wouldn’t notice anything suspicious in the first place… And you usually look for suspicious things on the recorded footage later, not in real time - you can’t turn ON the LED on a video file LOL…
As @KTibow mentioned, for example if the camera is watching over a terrace where you’d spend some time occasionally (a few times per year) with your friends there after sunset, that stark light might be very annoying for most the people. This command line switch allows you to quickly turn it OFF for such cases, without you needing to look for the camera’s IP address, log into it’s web interface and search for which setting controls this. You don’t mind having a darker picture in such cases as you deliberately know you’re there…
And, since by default you’d usually like to have it ON, a small automation takes care for things you might forget. Of course this is just an example, one could set it up differently, eg. by connecting it with a presence detection, home/away status etc.
Exactly. The point is not to turn night into day all the time. The cameras see very well in the dark using IR, but the image will only be black and white.
I have one of these cameras at my front door. Having the light on all the time would be ugly as anything. Being able to turn it on to ensure a person standing there is identified is good, for security reasons, but thats it.
ummm. yes it would, just not in colour. Fairly sure the purpose is to turn it on when motion is detected so you can determine a persons clothing colour etc.
Don’t agree dude, but that’s why the world is a nice place - we don’t have to agree on everything. Just pass along please if you’re not interested in this code - I shared it for someone who’d find it useful.
At the front door, I might not want to be on all the time either, because I have enough light sources there already. It all depends on the unique case if you want it ON all the time or not.
I don’t care how ugly it is on my back terrace during the night - as security is far more important than the looks IMHO. And yes, the point is exactly the opposite: turn the entire night into day, to have the most possible information recorded. That’s why the camera can do this (and the model I use doesn’t have IR at all, only ColorVU).
I definitely appreciate the code work you have mate. I was planning on testing it out as I’ve only just bought the camera and not yet had the light setup
I’ve added to the example a shell_command and an automation to update every day the LED operation schedule on the camera, for those not satisfied by the automatic mode.
It turned out in my case that the LED wouldn’t turn on by itself at night on certain cameras. It seems the built-in automation is disturbed by the LEDs of the others. But thankfully there is a different way to use it, scheduled. With this, mode is switched in the camera from “Auto” to “Scheduled” and it turns ON automatically 1 hour after sunset, and OFF 30mins before sunrise. The ON/OFF times in the camera are updated every day by a template in Home Assistant.
Note that in scheduled mode the camera requires the whole XML to be put, even for switching just enable/disable (aka ON/OFF). Some fiddling is required to have both an ON/OFF switch and dynamic schedule times… but it’s feasible.
Thanks for this! I’ve been waiting for someone to do it.
I’m having issues implementing it though.
I plan only to use your switch and I’ve added this to my configuration.yaml (replaced admin:pass with mine):
- platform: command_line
scan_interval: 900
switches:
camera_led:
friendly_name: Camera ColorVU LED Auto
command_on: "curl -k --silent -H 'Content-Type:application/xml' -X PUT -d '<ExternalDevice><SupplementLight><enabled>true</enabled></SupplementLight></ExternalDevice>' http://192.168.1.64/ISAPI/System/externalDevice --digest -u user:pass"
command_off: "curl -k --silent -H 'Content-Type:application/xml' -X PUT -d '<ExternalDevice><SupplementLight><enabled>false</enabled></SupplementLight></ExternalDevice>' http://192.168.1.64/ISAPI/System/externalDevice --digest -u user:pass"
command_state: "curl -k --silent -X GET http://192.168.1.64/ISAPI/System/externalDevice --digest -u user:pass | grep -oP '(?<=enabled>).*?(?=</enabled>)'"
value_template: "{{ value == 'true' }}"
But when I toogle the switch it just reverts back to off (and the checkbox stays off in Hikvision web interface).
What am I missing here?
The idea is to keep the led schedule ON 24/7 and just toggle the switch when the motion is triggered (via separate motion sensor).
To test commands you should use CURL on your PC. See what error they throw.
Enable LED curl -k --silent -H 'Content-Type:application/xml' -X PUT -d '<ExternalDevice><SupplementLight><enabled>true</enabled></SupplementLight></ExternalDevice>' http://your.camera.ip/ISAPI/System/externalDevice --digest -u user:pass
Disable LED curl -k --silent -H 'Content-Type:application/xml' -X PUT -d '<ExternalDevice><SupplementLight><enabled>false</enabled></SupplementLight></ExternalDevice>' http://your.camera.ip/ISAPI/System/externalDevice --digest -u user:pass
Get Status of the LED curl -k --silent -X GET http://your.camera.ip/ISAPI/System/externalDevice --digest -u user:pass | grep -oP '(?<=enabled>).*?(?=</enabled>)'
OK my fault the status command is Linux specific as it contains a GREP to strip the XML searching for the state of the switch. That won’t work on Windows and that was the reason for the error message.