How I created custom Scene/Modes for ReoLink NVR cameras in Home Assistant

Tags: #<Tag:0x00007fc42ecd6e60>

The Reolink app allows you to create “scenes” or modes to set “Home” or “Away” profile, to turn on/off motion alert notifications. However when using an NVR you only have the option to set it for all cameras, not camera specific. [Screenshot]

 

Problem:
I have 4 cameras and needed 3 specific scenes, “Home - some cameras enabled”, “Away - All cameras enabled” and “Disabled - All cameras disabled”.

 

Solution:
By using a rest_command you can update your notification scheduling with a POST request to the NVR itself.

 

Enable Push Notification on channel 1:
 

driveway_push_on:
    method: POST
    url: http://[IP_ADDRESS]:80/api.cgi?cmd=SetPushV20&channel=0&user=admin&password=[PASS]
    payload: '[{
    "cmd": "SetPushV20",
    "action": 0,
    "param": {
        "Push": {
        "schedule": {
         "channel": 0,
            "table": {
             "AI_PEOPLE": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111",
             "AI_VEHICLE": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111",
             "MD": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
         }
          }
        }
     }
    }]'

 

The 1’s and 0’s are the enabled/disabled for the schedule table. Each digit is a block. [Screenshot]. To turn it off, change all the 1s to 0s.

Increment the channel=0 (in the url) and “channel”: 0 (in the JSON body) upwards to set other cameras.

And of course add the IP_ADDRESS of your NVR and PASS.

 

Email Notification Example

driveway_email_on:
    method: POST
    url: http://[IP_ADDRESS]:80/api.cgi?cmd=SetEmailV20&channel=0&user=admin&password=[PASS]
    payload: '[{
    "cmd": "SetEmailV20",
    "action": 0,
    "param": {
        "Email": {
        "schedule": {
         "channel": 0,
            "table": {
             "AI_PEOPLE": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111",
             "AI_VEHICLE": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111",
             "MD": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
         }
          }
        }
     }
    }]'

 

Automation:

I’ve then set up scripts to handle each “scene” I want and set each cameras notifications accordingly. These can be called manually with a button, or automation, including asking your assistant to trigger them.

 

camera_home:
  sequence:
    - service: rest_command.backyard_push_off
    - delay:
        milliseconds: 1000
    - service: rest_command.backyard_email_off
    - delay:
        milliseconds: 1000
    - service: rest_command.driveway_push_on
    - delay:
        milliseconds: 1000
    - service: rest_command.driveway_email_on
    - delay:
        milliseconds: 1000
    - service: rest_command.frontyard_push_on
    - delay:
        milliseconds: 1000
    - service: rest_command.frontyard_email_on
    - delay:
        milliseconds: 1000
    - service: rest_command.sidehouse_push_on
    - delay:
        milliseconds: 1000
    - service: rest_command.sidehouse_email_on
    - delay:
        milliseconds: 500
    - service: notify.mobile_app_cyriss_iphone
      data:
        title: "Camera Mode: Home"
        message: Camera's set to home.

 

I’ve added my modes as buttons to my Home Assistant that triggers these.

 

Note:
The model I am using the ReoLink RLK8-520D4-A with 4x RLC-520A Turret Cameras. I believe you can get other models to work by settings “SetEmailV20” to “SetEmail” and so forth.

The only issue I face now is camera delay in Home Assistant. I am currently using reolink-dev integration but see a 10 -20 seconds delay on streams. Has anyone else figured out the best solution for this?