Privacy Mode on Amcrest IP cameras via a switch

Amcrest cameras come with a privacy mode which can be enabled on the UI/App. However, the HA integration doesn’t have a service for it.

I checked the http sdk for Amcrest and couldn’t find an endpoint for that feature. However I managed to find the endpoints by doing some snooping on my Amcrest UI. From it I’ve managed to create this command_line switch which creates a switch that controls the Privacy Mode.

- platform: command_line
  switches:
    amcrest_privacy:
      command_on: !secret amcrest_command_privacy_on
      command_off: !secret amcrest_command_privacy_off
      command_state: !secret amcrest_command_privacy_state
      value_template: "{{ value.split('=', 1)[1] == 'true' }}"

The secrets are:

amcrest_command_privacy_on: 'curl -g --digest -u <user>:<password> "http://<camera-ip>/cgi-bin/configManager.cgi?action=setConfig&LeLensMask[0].Enable=true"'
amcrest_command_privacy_off: 'curl -g --digest -u <user>:<password> "http://<camera-ip>/cgi-bin/configManager.cgi?action=setConfig&LeLensMask[0].Enable=false"'
amcrest_command_privacy_state: 'curl -g --digest -u <user>:<password> "http://<camera-ip>/cgi-bin/configManager.cgi?action=getConfig&name=LeLensMask[0].Enable"'

I am now able to turn privacy mode on and off via Home Assistant automatons.

Would be great if we could add that to the amcrest integration, though it is technically an undocumented API.

UPDATE: This workaround is no longer needed. See the amcrest integration page for how to enable the switches in the integration itself. Amcrest - Home Assistant

3 Likes

This isn’t working for me, i have no errors in the config file but when i toggle the switch nothing happens.

Which camera do you have?

This is the one I have: https://www.amazon.com/gp/product/B0145OQXCK/ref=ppx_yo_dt_b_asin_title_o04_s00?ie=UTF8&psc=1

I don’t see why the API would be different between models. But if it is, what I did was check the calls mine did when I pressed the privacy mode button on the UI.

That is the same camera I have, I’ll post my config and switch below, do you see anything wrong?

when I use the switch is toggles on for a moment then goes back off.

How come you have the value_template commented out?

I was trying to get this to work. I have it set back i’ll provide a picture. Can you see anything wrong or show how you made a switch for the entity?

Looks exactly the same as mine. All I think is that there’s something wrong with the curl command. Can you try the curl commands on your PC and see what it does?

Sorry I am still new, how would I do that. DO i need to enable ssh on the camera somehow?

I got it, your code was great the error was in my !secret file.

Thank you so much, this is a great command!

1 Like

Oh, thank you. I have been using a power plug for a while for this functionality but it leaves a lot to be desired in speed from turning on to completely off. It’s almost instant using these commands.

Btw, I opened a PR against HA Core to add this functionality into the Amcrest integration.

Assuming it is merged, we will be able to use that instead of these scripts.

I am sure it will get merged, probably pretty quickly but until it does this helps a lot. I wasn’t using the camera because I was honestly a little pissed about how I wasn’t able to find this feature.

@pjrt What does privacy mode do?

It turns the camera to the base, disabling the video and audio

thx… googled it also, i asked before i did because he said it wasn’t documented.

The HTTP API isn’t documented, but the feature is used by the Amcrest Camera UI (that Privacy button on the right).

So…it is a bit of a weird feature. Fully used and advertised, yet not in their HTTP SDK documentation.

This is awesome!

I just got the 4MP version of that camera from Amcrest to test and I have it facing a wall when I’m home. When my alarm arms, it turns itself around.

I have, however, had to absolutely cripple the camera settings to even get borderline good performance. Current settings are h264, 1080p, 15fps, vbr with 8k max bitrate, no audio, no substream, and no smarts. Does yours perform poorly as well?

Can’t say I had that issue. I’ve been using pretty much default settings this whole time.

This PR has now been released as part of the 2021.12 release. See Amcrest - Home Assistant on how to enable it.

This workaround is no longer needed.