8000 add camera privacy masking control by patriot1889 · Pull Request #307 · rroller/dahua · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

add camera privacy masking control #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ Service | Parameters | Description
`dahua.enable_time_overlay` | `target`: camera.cam13_main <br /> `channel`: The camera channel, e.g.: 0 <br /> `enabled`: True to enable, False to disable | Enables or disables the time overlay on the video
`dahua.enable_text_overlay` | `target`: camera.cam13_main <br /> `channel`: The camera channel, e.g.: 0 <br /> `group`: The group, used to apply multiple of text as an overly, e.g.: 0 <br /> `enabled`: True to enable, False to disable | Enables or disables the text overlay on the video
`dahua.enable_custom_overlay` | `target`: camera.cam13_main <br /> `channel`: The camera channel, e.g.: 0 <br /> `group`: The group, used to apply multiple of text as an overly, e.g.: 0 <br /> `enabled`: True to enable, False to disable | Enables or disables the custom overlay on the video
`dahua.set_privacy_masking` | `target`: camera.cam13_main <br /> `index`: The mask index, e.g.: 0 <br /> `enabled`: True to enable, False to disable | Enables or disabled a privacy mask on the camera
`dahua.set_record_mode` | `target`: camera.cam13_main <br /> `mode`: Auto, On, Off | Sets the record mode. On is always on recording. Off is always off. Auto based on motion settings, etc.
`dahua.enable_all_ivs_rules` | `target`: camera.cam13_main <br /> `channel`: The camera channel, e.g.: 0 <br /> `enabled`: True to enable all IVS rules, False to disable all IVS rules | Enables or disables all IVS rules
`dahua.enable_ivs_rule` | `target`: camera.cam13_main <br /> `channel`: The camera channel, e.g.: 0 <br /> `index`: The rule index <br /> enabled`: True to enable the IVS rule, False to disable the IVS rule | Enable or disable an IVS rule
Expand Down
14 changes: 14 additions & 0 deletions custom_components/dahua/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# This service handles setting the video profile mode to day or night
SERVICE_SET_VIDEO_PROFILE_MODE = "set_video_profile_mode"
SERVICE_SET_FOCUS_ZOOM = "set_focus_zoom"
SERVICE_SET_PRIVACY_MASKING = "set_privacy_masking"
SERVICE_SET_CHANNEL_TITLE = "set_channel_title"
SERVICE_SET_TEXT_OVERLAY = "set_text_overlay"
SERVICE_SET_CUSTOM_OVERLAY = "set_custom_overlay"
Expand Down Expand Up @@ -83,6 +84,15 @@ async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entitie
"async_adjustfocus"
)

platform.async_register_entity_service(
SERVICE_SET_PRIVACY_MASKING,
{
vol.Required("index", default=0): int,
vol.Required("enabled", default=False): bool,
},
"async_set_privacy_masking"
)

platform.async_register_entity_service(
SERVICE_ENABLE_CHANNEL_TITLE,
{
Expand Down Expand Up @@ -315,6 +325,10 @@ async def async_adjustfocus(self, focus: str, zoom: str):
""" Handles the service call from SERVICE_SET_INFRARED_MODE to set zoom and focus """
await self._coordinator.client.async_adjustfocus_v1(focus, zoom)
await self._coordinator.async_refresh()

async def async_set_privacy_masking(self, index: int, enabled: bool):
""" Handles the service call from SERVICE_SET_PRIVACY_MASKING to control the privacy masking """
await self._coordinator.client.async_setprivacymask(index, enabled)

async def async_set_enable_channel_title(self, enabled: bool):
""" Handles the service call from SERVICE_ENABLE_CHANNEL_TITLE """
Expand Down
11 changes: 11 additions & 0 deletions custom_components/dahua/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,17 @@ async def async_adjustfocus_v1(self, focus: str, zoom: str):

url = "/cgi-bin/devVideoInput.cgi?action=adjustFocus&focus={0}&zoom={1}".format(focus, zoom)
return await self.get(url, True)

async def async_setprivacymask(self, index: int, enabled: bool):
"""
async_setprivacymask will enable or disable the privacy mask
"""


url = "/cgi-bin/configManager.cgi?action=setConfig&PrivacyMasking[0][{0}].Enable={1}".format(
index, str(enabled).lower()
)
return await self.get(url, True)

async def async_set_night_switch_mode(self, channel: int, mode: str):
"""
Expand Down
27 changes: 27 additions & 0 deletions custom_components/dahua/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,30 @@ set_focus_zoom:
selector:
text:

set_privacy_masking:
name: Set the Dahua Privacy Masking
description: Enables or disabled the cameras privacy masking
target:
entity:
integration: dahua
domain: camera
fields:
index:
name: Index
description: "The mask index. 0 is the first mask"
example: 0
required: true
default: 0
selector:
number:
mode: box
min: 0
max: 100
enabled:
name: Enabled
description: "If true enables the mask, otherwise disables it"
example: true
required: true
default: true
selector:
boolean:
0