Toggling motion detection on a camera via a lovelace switch

Exactly what I thought, == true is not required… OP, is that correct?

hi,
I’ve the same issue as described by @Peter_West earlier. When I toggle the template switch it immediately changes the motion_enabled state in the blink app. But the attribute in HA takes around 5 min until it reflects the same value as in the app.
Anyone has a clue why there is this delay?

When I toggle the template switch it immediately changes the motion_enabled state in the blink app. But the attribute in HA takes around 5 min until it reflects the same value as in the app.

5 minutes is the default scan_interval for the Blink integration - it is a polling integration.

Reducing the scan_interval is possible however excessive polling can lead to a server-side ban and a frustrating period of trying to get your account unlocked - I speak from experience as I spent nearly a week and a long time on a transatlantic phone call to regain access to my account.

Blink only support Amazon Alexa and IFTTT integrations and term any others “security risks”.

1 Like

Hello @finity
Hope that it is ok to hijack this old thread. I’m about to buy a bunch on indoor and outdoor cameras to my new house. I basically only have two demands:

  1. POE
  2. Being able to toggle recording or motion detection since I want the camera to be active as soon as I leave the house (arm it).

Found this thread and it looks like you have solved this and that would make me very happy :slight_smile:

Is this sort of a “hack” or is this something that is working permanently with permanently and is there something I should consider in this, like bugs or limitations?

Thanks a lot.

I have solved it but it depends on the API for the kind of camera you get.

If you use Foscams and the CGI commands are the same as mine then my solutions will work. Otherwise you’ll have to figure out if your camera provides that capability and how to use it.

1 Like

Thank you for your reply!
I was planning on getting a few Reolink cameras but might as well look into Foscam cameras.

Tweaked finity’s command line switch for IMOU Dome Lite and move the curl commands to the secrets file. This should work with IMOU/Dahua cameras that support CGI commands (typically these cameras can be configured via web interface as opposed to configuration via mobile app only):

secrets.yaml:

# Entrance IPC
ipc_entrance_motion_toggle_on: 'curl --digest --silent -u "username:password" "http://entrance./cgi-bin/configManager.cgi?action=setConfig&MotionDetect[0].Enable=true"'
ipc_entrance_motion_toggle_off: 'curl --digest --silent -u "username:password" "http://entrance./cgi-bin/configManager.cgi?action=setConfig&MotionDetect[0].Enable=false"'
ipc_entrance_motion_toggle_state: 'curl --digest --silent -u "username:password" "http://entrance./cgi-bin/configManager.cgi?action=getConfig&name=MotionDetect" | grep -o "table.MotionDetect\[0\].Enable=.*"'

configuration.yaml:

switch:
  - platform: command_line
    switches:
      ipc_entrane_motion_toggle:
        friendly_name: 'Entrance Motion Detection'
        command_on: !secret ipc_entrance_motion_toggle_on
        command_off: !secret ipc_entrance_motion_toggle_off
        command_state: !secret ipc_entrance_motion_toggle_state
        value_template: '{{ value == "table.MotionDetect[0].Enable=true" }}'

Is this configuration working for switching the motion detection from a template switch?

Because it is exactly my case but I’m getting an error like “failed call to service switch/turn_off”

Any suggestions?

Thanks!
Matteo