Skip to content

Instantly share code, notes, and snippets.

@casebeer
Last active November 16, 2023 23:18
Show Gist options
  • Save casebeer/4c1be6f993cc7fc21b6905e0c1ed4178 to your computer and use it in GitHub Desktop.
Save casebeer/4c1be6f993cc7fc21b6905e0c1ed4178 to your computer and use it in GitHub Desktop.
Home Assistant configuration using the REST Switch integration to control the white supplemental lights on Hikvision/Annke ColorVu or NightChroma color night vision cameras.
#
# # REST Switch configs for toggling the white "Supplemental Lights" on Hikvision/Annke cameras
#
# Note that we must hit the cameras' ISAPI endpoints directly, not through the NVR,
# since (at least the Annke N88PCH) NVR does not seem to support getting nor setting the
# `/ISAPI/Image/channels/<ID>/supplmentalLight` API endpoint. This also implies that
# we must use the NVR's "integration password," i.e. the username and password used by the
# NVR to automatically config the cameras, NOT a user of the NVR itself.
#
# ## Camera Settings
#
# IMPORTANT: Since the REST Switch integration only supports HTTP Basic auth (not Digest), each
# camera (not NVR) *MUST* be configured to allow Basic auth:
#
# Camera Config -> Security -> Authentication -> WEB Authentication: Set to "digest/basic."
#
# ## NVR Settings
#
# The NVR must allow direct access to the cameras' config and API interfaces by enabling the NVR's
# Virual Host setting:
#
# NVR Config -> Network -> Advanced Settings -> Enable Virtual Host: Ensure box is checked
#
# Note also that the "On" command will vary depending on the *type* of light being enabled:
#
# On: {colorVuWhiteLight|multiAzimuthWhiteLight}
# Off: {close}
#
# As a double-check, we're also overriding the brightness settings to 100% when turning the
# ligths on.
#
# ## Known Issues
#
# - When the cameras are set to "Day" mode, the white light config apepars to be ignored
# entirely, and the lights forced off. However, the config will persist, so if and when
# the camera returns to "Night" mode, the light will come on.
# - If the Day/Night switch is set to "Auto" and the camera's white light reflects off of
# nearby light colored objects, the camera may oscillate between Day and Night settings,
# toggling the light on and off. Workaround: Force camera to "Night" mode.
#
switch:
# NVR Channel 1, accessed via NVR VHost on port 65001
# ColorVu/NightChroma camera with white light
- platform: rest
resource: http://<NVR IP ADDRESS>:65001/ISAPI/Image/channels/1/SupplementLight
name: "ColorVu camera supplemental white light"
unique_id: 29c5f254-6130-44fa-abad-4080ddbd706a
method: put
body_on: |-
<?xml version="1.0" encoding="UTF-8"?>
<SupplementLight version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<supplementLightMode>colorVuWhiteLight</supplementLightMode>
<whiteLightBrightness>100</whiteLightBrightness>
<mixedLightBrightnessRegulatMode>manual</mixedLightBrightnessRegulatMode>
</SupplementLight>
body_off: |-
<?xml version="1.0" encoding="UTF-8"?>
<SupplementLight version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<supplementLightMode>close</supplementLightMode>
</SupplementLight>
is_on_template: >-
{{ value is search('<supplementLightMode>\s*colorVuWhiteLight\s*<.supplementLightMode>') }}
username: !secret nvr_integration_user
password: !secret nvr_integration_pass
# NVR Channel 2, accessed via NVR VHost on port 65002
# Hikvision/Annke ColorVu/NightChroma Panoramic dual lens cameras have dual white lights so different config:
- platform: rest
resource: http://<NVR IP Address>:65002/ISAPI/Image/channels/1/SupplementLight
name: "Panoramic dual lens camera supplemental white light"
unique_id: da88f049-3c33-42da-b65f-470a230937cd
method: put
body_on: |-
<?xml version="1.0" encoding="UTF-8"?>
<SupplementLight version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<supplementLightMode>multiAzimuthWhiteLight</supplementLightMode>
<MultiAzimuthWhiteLightCfg>
<brightnessRegulatMode>manual</brightnessRegulatMode>
<LightCtrlList size="2" >
<LightCtrl>
<azimuthType>left</azimuthType>
<lightType>white</lightType>
<brightness>100</brightness>
</LightCtrl>
<LightCtrl>
<azimuthType>right</azimuthType>
<lightType>white</lightType>
<brightness>100</brightness>
</LightCtrl>
</LightCtrlList>
</MultiAzimuthWhiteLightCfg>
</SupplementLight>
body_off: |-
<?xml version="1.0" encoding="UTF-8"?>
<SupplementLight version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<supplementLightMode>close</supplementLightMode>
</SupplementLight>
is_on_template: >-
{{ value is search('<supplementLightMode>\s*multiAzimuthWhiteLight\s*<.supplementLightMode>') }}
username: !secret nvr_integration_user
password: !secret nvr_integration_pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment