starkillerOG / reolink_aio

Reolink NVR/camera API PyPI package
MIT License
71 stars 14 forks source link

I can help you if you need some help about reolink command #10

Open mnpg opened 1 year ago

mnpg commented 1 year ago

Hi @starkillerOG, If you need some help about the reolink commands, i can help you if you will. i made an unofficial documentation for the Reolink Cameras (it concerns only the 5MP cams, i ain't got some latest ones) that you can find on my Github channel : https://github.com/mnpg/Reolink_api_documentations

Sorry, all the unofficial documentations are in French but easy to google translate them.

Regards

starkillerOG commented 1 year ago

@mnpg any help is always apreciated, you can just make PRs to this library and/or the HomeAssistant integration and I will review them and help you out if you get stuck.

Yes I already found your documentation library, very helpfull! I found at least the new doorbell quick reply commands there.

Do you have any other particular commands/features that you would like to see added?

mnpg commented 1 year ago

Hi @starkillerOG, for a feature, i think the calibration one. It's easy to include it but i don't know if you have already added it. here the commands i use to do that : PtzCheck and GetPtzCheckState.

In the command below, change #IP# to the IP address of the cam and #username# and #password# (an admin account credentials) by your own values and also the channel #X# of the camera (0 if the camera is a standalone cam). The URL is in https, change it to http if it doesn't work

curl -s -k -X POST -H "Content-Type : application/json" -d '[{\"cmd\":\"PtzCheck\",\"action\":0,\"param\":{\"channel\":#X#}}]' "https://#IP#/cgi-bin/api.cgi?user=#USERNAME#&password=#PASSWORD#"

curl -s -k -X POST -H "Content-Type : application/json" -d '[{\"cmd\":\"GetPtzCheckState\",\"action\":0,\"value\":{\"channel\":#X#}}]' "https://#IP#/cgi-bin/api.cgi?user=#USERNAME#&password=#PASSWORD#"

return status (field PtzCheckState): 0 : calibration is required 1 : calibration is running 2 : calibration done

IMPORTANT : This feature depends on the Abitity "supportPtzCheck" of the camera

Regards

mnpg commented 1 year ago

just for my information : which camera(s) to do have? and also which commands you need some informations?

FYI : i really want help you but python isn't easy for me.

starkillerOG commented 1 year ago

@mnpg yes the callibration using PtzCheck has already been included as a button entity. I did not include the GetPtzCheckState, but I don't think that status will really be that helpfull in HomeAssistant, what do you think?

I have:

But I have good contacts with Reolink, so if there is a particular model which is causing difficult issues, I can ask for that model for testing. Thats also why the TrackMix is on its way, not going to use it myself, but it has slightly diffrent API, so I am going to test and programm with it.

starkillerOG commented 1 year ago

@mnpg At this moment I would like a command to trigger the doorbell quick replay message, but reolink already confirmed to me it is not yet included in there firmware API. I would also like a command to set the absolute Pan/Tilt position, but have not found it yet and think it is not yet included in the API.

mnpg commented 1 year ago

@mnpg At this moment I would like a command to trigger the doorbell quick replay message, but reolink already confirmed to me it is not yet included in there firmware API.

i confime you that it's not possible to do this except to choose the reply message. It's seems like the 2-way audio feature that we cannot use through API.

I would also like a command to set the absolute Pan/Tilt position, but have not found it yet and think it is not yet included in the API.

For which camera?

starkillerOG commented 1 year ago

For which camera?

I am not programming for myself, but for all 15.000 current users of the reolink homeassistant integration. So for all camera's that support PTZ basically, hopefully (and probably) the command will be the same in all models if the firmware supports it.

mnpg commented 1 year ago

@mnpg yes the callibration using PtzCheck has already been included as a button entity. I did not include the GetPtzCheckState, but I don't think that status will really be that helpfull in HomeAssistant, what do you think?

It's a good thing to have it. When you have the status at 0 of the GetPtzCheckState status field (PtzCheckState), you can automate through HA to launch the calibration.

starkillerOG commented 1 year ago

@mnpg when will it become 0 (required)? Does that often happen, and have you experianced that?

mnpg commented 1 year ago

when you reboot the camera, the calibration is required

mnpg commented 1 year ago

beware, the E1Zoom (not the AI version) have also the calibration BUT there are no PTZCheck or GetPtzCheckState commands in there firmware. These commands appear with the AI cameras.

mnpg commented 1 year ago

So for all camera's that support PTZ basically, hopefully (and probably) the command will be the same in all models if the firmware supports it.

For the Ptz, i've found some difference with the oldest cameras, in particular with some movements or zoom and focus.

mnpg commented 1 year ago

If you have a E1-Zoom, i invite you to take a look a my github wiki page. This camera have a easter egg : the patrol mode : https://github.com/mnpg/Reolink_api_documentations/wiki/Easter-Egg-dans-la-Reolink-E1-Zoom-:-le-mode-Patrol

starkillerOG commented 1 year ago

@mnpg nice find the Patrol mode in the E1 zoom 👍

mnpg commented 1 year ago

Hi @starkillerOG for the Get/Set3DPos command, take a look at the RLC-823A_16X firmware (unpak the firmware with the command 'binwalk -e -M "pak"'), and you find the answer in the file ViewPtz3DLocation.js (in repositoy _IPC_523SD10.1646_22122622.RLC-823A-16X.IMX415.8MP.PTZ.REOLINK.pak.extracted/ubifs-root/2101463492/app/www/js/modules) NB: the firmware is available in the download center of Reolink (https://reolink.com/fr/download-center/) Regards

starkillerOG commented 1 year ago

@mnpg Thanks for the info, but I have never used binwalk. Could you maybe have a look at it for me and post the Set/Get3DPos commands (which parameters they take and what I schould expect for response?)

mnpg commented 1 year ago

sure, no pb. it's seeems that for Get3DPos, you will seen these parameters :

            channel: e
        }, function (t) {
            d === e && (t = t["3d_pos"], w = {
                    [EnumStreamType.CLEAR]: {
                        width: t.mainStream.width,
                        height: t.mainStream.height
                    },
                    [EnumStreamType.FLUENT]: {
                        width: t.subStream.width,
                        height: t.subStream.height
                    },
                    [EnumStreamType.BALANCED]: {
                        width: t.extStream.width,
                        height: t.extStream.height
                    }
                })

For the Set3PPos, here the parameters to set :

 iX: Math.floor(e * h / r.width),
                iY: Math.floor(i * n / r.height),
                iWidth: Math.floor(e * o / r.width),
                iHeight: Math.floor(i * a / r.height)
            }, CGI.sendCommand("Set3DPos", {
                "3DPos": {
                    channel: t,
                    posX: h.iX,
                    posY: h.iY,
                    posWidth: h.iWidth,
                    posHeight: h.iHeight,
                    speed: function () {
                        let t = 20;
                        var e = window.localStorage.getItem("/ptz/speed");
                        return t = e && !isNaN(parseFloat(e)) ? Math.max(1, Math.min(64, parseFloat(e))) : t
                    }
                    (),
                    width: e,
                    height: i
                }

for the Set3DPos, there are several parameters : 

- channel (it's normal -NVR or standalone-)
- posX
- posY
- posWidth
- posHeight
- width
- height
- speed
mnpg commented 1 year ago

For the Set command, I don't know how to use this command and parameters (Set3DPos) I ain't got a RLC-823_16X Sorry.

starkillerOG commented 1 year ago

Thank you very much for the information, so actually the Set3DPos seems to consern some display/image setting and not the Pan/Tilt position I was hoping for, but still very usefull to know.

mnpg commented 1 year ago

The Get/Set3DPos command this feature in particular with this version of firmware of the RLC-823_16X

mnpg commented 1 year ago

Hi @starkillerOG, You're right, it's another feature (the 3D Zoom feature) introducted with the firmware 3.1.0.1646 of the RLC-823_16X As i know about the Reolink cameras and about the Get/Set3DPos, i'm not sure but by experience with these cameras, here are, i suppose, how the parameters are defined for the feature 3D Zoom

mnpg commented 1 year ago

for the Set3DPos, there are several parameters :

Get-Set3DPOS parameters

mnpg commented 1 year ago

For the speed parameter, it's seems to be the time (in seconds or mseconds) to go the the 3D Zoom zone. It's my opinion, i'm not quite sure. We must wait more infos about this command as soon as they release a newer upgrade of the official Reolink API documentation. Regards

mnpg commented 1 year ago

not the Pan/Tilt position I was hoping for, but still very usefull to know.

hi @starkillerOG, for which camera?

mnpg commented 1 year ago

@starkillerOG : waiting for your answer

starkillerOG commented 1 year ago

I was looking for the Trackmix and/or E1 Zoom, I have figured out the GetPtzCurPos gives me the pan position on the Trackmix, still looking for a way to set the position

mnpg commented 1 year ago

Hi @starkillerOG, since the latest firmware from the E1-Zoom (I have one too), there will be no commands to tilt/pan the camera, they always add new commands on newer cameras. I think that it's probably in the TrackMix firmware, you'll find some informations. As always, we can't wait more information from the Reolink api guide, It's depends in our experience.

mnpg commented 1 year ago

@starkillerOG : which features you want to add in your "plugin" ? privacy mask, surveillance scheduler? Detection zone ?

starkillerOG commented 1 year ago

@mnpg No privacy mask, schedule and detection zone will be too difficult and not used that many to implement.

I would really love to have the triggering of a quick reply message for the Reolink doorbell. New firmware for the doorbell was published a week ago. Could you by any change look if that new firmware included a command to trigger the quick reply message?

mnpg commented 1 year ago

@starkillerOG, taken from the latest firmware of the Doorbell i've found new commands or parameters, here there are (not sure they 'll working with this firmware because these commands aren't included in the cgiserver.cgi file of the firmware):

also, from the command GetAudioCfg/SetAudioCfg, a new parameter appears (visitorLoudspeaker):

SetAudioCfg : {"cmd":"SetAudioCfg","param":{"AudioCfg":{"visitorLoudspeaker":0->100 (??), "channel":X}}

In this firmware, there were also included 2 new commands for the FishEye Camera :

EDIT : i can't see any manual trigger reply command in the files of the firmware. Perhaps, do a test with the command AudioAlarmPlay

starkillerOG commented 1 year ago

The visitorLoudspeaker parameter is 0 or 1, to enable/disable the sound of the doorbell itself (not the chime). I already included this in reolink-aio and HA in PR: https://github.com/home-assistant/home-assistant.io/pull/26791

The FishEye commands are certainly interesting, thanks for those, I would need one of these cameras to figure out what the parameter range is, but this is already helpfull!

The ExportAudioFile is (I think) for downloading the audio file from the doorbell, but will not play the sound.

mnpg commented 1 year ago

hi @starkillerOG, based with the @jasonk rl-api bash script (for linux) -FYI, its an awesome script-, i've created several examples of scripts when you can't define or configure some parameters (or features) through your Home Automation Solution. I regroup them on my github repo > Folder Bash-scripts

EDIT: these examples concern PrivacyMask, DetectionZone and VideoClip. I think there is a way to adapt these codes to HA.

mnpg commented 1 year ago

Hi @starkillerOG, i've win recently a reolink fish camera from Reolink contest. When i receive it, i will come back to you with more infos or commands about it Regards

mnpg commented 1 year ago

hi @starkillerOG, based with the @jasonk rl-api bash script (for linux) -FYI, its an awesome script-, i've created several examples of scripts when you can't define or configure some parameters (or features) through your Home Automation Solution. I regroup them on my github repo > Folder Bash-scripts

EDIT: these examples concern PrivacyMask, DetectionZone and VideoClip. I think there is a way to adapt these codes to HA.

New scripts are available :

More will come :

NB : I suppose they can be adapted to HA plugin

Regards

starkillerOG commented 1 year ago

Thanks for the info

starkillerOG commented 7 months ago

@mnpg there is a new firmware version of the reolink doorbell available on https://github.com/AT0myks/reolink-fw-archive/commit/ffa16f31b0ba610243174ab6ed5a869424c0c991

https://home-cdn.reolink.us/wp-content/uploads/2024/03/010147201709257640.8976.zip

Could you perhaps take a look if you can find a command to trigger playback of a quickreplay message in this new firmware?

mnpg commented 7 months ago

hi @starkillerOG, Here the first infos i've got from the Doorbell's firmware :


QuickReplyPlay COMMAND

NO INFO ABOUT IT

NB : Probably, not sure, it seems to work like the reboot command. Test this command : [{"cmd":"QuickReplyPlay","action":0,"param":{}}]


DingDong COMMANDS

########################### "supportDingDongCtrl" => getAbilityChnBy("supportDingDongCtrl") ###########################

DingDongCtrl

EDIT : It seems that this command is used to enter/exit in the pairing mode.

GetDingDongList

=> return Values

{ channel: this.index, maxPairNumber: i.maxPairNumber, # <--- 5 or 10 max ? # size: a.length, dingDong: a }

DingDongOpt (dingDongManualRing)

INFO : dingDongAudioBasenameMap => new Map([[0, "dingdong_001.mp3"], [1, "dingdong_002.mp3"], [2, "dingdong_003.mp3"], [3, "dingdong_004.mp3"], [4, "dingdong_005.mp3"], [5, "dingdong_006.mp3"], [6, "dingdong_007.mp3"], [7, "dingdong_008.mp3"], [8, "dingdong_009.mp3"], [9, "dingdong_010.mp3"]])

DingDongOpt (dingDongPair)

DingDongOpt (dingDongUnpair)

DingDongOpt (getDingDongOption)

=> return Values

{ dingDongId: t, volume:

{ defaultLevel: r.volLevel, level: r.volLevel, levelOptions: a ledState: r.ledState, name: r.name }

DingDongOpt (setDingDongOption)

GetDingDongCfg (getDingDongAudioInfo)

=> return Values

{ ?? }

SetDingDongCfg (setDingDongAudioInfo)

I will send you another commands soon

Regards

mnpg commented 7 months ago

Hi again,

in this post, it concerns a command of the NVRs and the long-awaited commands for Webhook

like the command GetDevInfo for a single camera, here a new command i've found for the NVR (probably you already know it) :


GetChnTypeInfo (getChannelVersion)

=> return Values

{ cName: "", cType: s.typeInfo, cSerialNo: "", cBuildDay: "", cHardwareVer: "", cCfgVer: "", cFirmwareVer: s.firmVer, cPakSuffix: s.pakSuffix, cDetail: "", cCC3200Ver: "", cSpVer: "" }

Here i've found these commands in the firmware :

Webhook COMMANDS

########################### "supportWebhook" => getAbilityChnBy("supportWebhook") ###########################

GetWebHook

=> return Values

{ index: o.index, indexEnable: o.indexEnable, hookUrl: o.hookUrl, bodyCustom: o.bCustom, hookBody: D["a"].recover2Str(o.hookBody, !1) }

SetWebHook

  • TypeCommand : SET Command
  • Command : SetWebHook
  • Parameters :
    WebHook:

    { channel: this.index, index: e.index, indexEnable: e.indexEnable, hookUrl: e.hookUrl, bCustom: e.bodyCustom, hookBody: D["a"].transform(e.hookBody, !1) }

    TestWebHook

  • TypeCommand : SET Command
  • Command : TestWebHook
  • Parameters :
    WebHook:

    { alarmChannel: this.index, type: 3, source: "hook", hookUrl: e.hookUrl, bCustom: e.bodyCustom, hookBody: D["a"].transform(e.hookBody, !1) }

starkillerOG commented 7 months ago

@mnpg Thank you soooo much!!!

The command: body = [{"cmd":"QuickReplyPlay","action":0,"param":{"id": 1}}] works and plays the quick reply message. I already implemented it in the reolink-aio library :)

starkillerOG commented 7 months ago

On the new firmware:

          "supportDingDongCtrl": {
            "permit": 0,
            "ver": 0
          },

So I think the dingDong commands are not fully working yet.

GetDingDongList gives: [{'cmd': 'GetDingDongList', 'code': 1, 'error': {'detail': 'rcv failed', 'rspCode': -17}}]

[{"cmd": "DingDongOpt", "action": 0, "param": {"channel": 0, "option": 4, "id": 0, "musicId": 1}}] gives: [{'cmd': 'DingDongOpt', 'code': 1, 'error': {'detail': 'rcv failed', 'rspCode': -17}}]

[{'cmd': 'DingDongOpt', 'action': 0, 'param': {'channel': 0, 'option': 2, 'id': 0}}] gives: [{'cmd': 'DingDongOpt', 'code': 1, 'error': {'detail': 'rcv failed', 'rspCode': -17}}]

GetDingDongCfg gives a intresting response: Seems like they are developing more advanced chimes that can be controlled through the API:

[
   {
      "cmd":"GetDingDongCfg",
      "code":0,
      "value":{
         "DingDongCfg":{
            "pairedlist":[
               {
                  "ringId":-1,
                  "ringName":"Reolink Chime",
                  "type":{
                     "md":{
                        "musicId":0,
                        "switch":0
                     },
                     "people":{
                        "musicId":0,
                        "switch":0
                     },
                     "visitor":{
                        "musicId":0,
                        "switch":1
                     }
                  }
               },
               {
                  "ringId":-1,
                  "ringName":"Reolink Chime",
                  "type":{
                     "md":{
                        "musicId":0,
                        "switch":0
                     },
                     "people":{
                        "musicId":0,
                        "switch":0
                     },
                     "visitor":{
                        "musicId":0,
                        "switch":1
                     }
                  }
               },
               {
                  "ringId":-1,
                  "ringName":"Reolink Chime",
                  "type":{
                     "md":{
                        "musicId":0,
                        "switch":0
                     },
                     "people":{
                        "musicId":0,
                        "switch":0
                     },
                     "visitor":{
                        "musicId":0,
                        "switch":1
                     }
                  }
               },
               {
                  "ringId":-1,
                  "ringName":"Reolink Chime",
                  "type":{
                     "md":{
                        "musicId":0,
                        "switch":0
                     },
                     "people":{
                        "musicId":0,
                        "switch":0
                     },
                     "visitor":{
                        "musicId":0,
                        "switch":1
                     }
                  }
               },
               {
                  "ringId":-1,
                  "ringName":"Reolink Chime",
                  "type":{
                     "md":{
                        "musicId":0,
                        "switch":0
                     },
                     "people":{
                        "musicId":0,
                        "switch":0
                     },
                     "visitor":{
                        "musicId":0,
                        "switch":1
                     }
                  }
               },
               {
                  "ringId":-1,
                  "ringName":"Reolink Chime",
                  "type":{
                     "md":{
                        "musicId":0,
                        "switch":0
                     },
                     "people":{
                        "musicId":0,
                        "switch":0
                     },
                     "visitor":{
                        "musicId":0,
                        "switch":1
                     }
                  }
               },
               {
                  "ringId":-1,
                  "ringName":"Reolink Chime",
                  "type":{
                     "md":{
                        "musicId":0,
                        "switch":0
                     },
                     "people":{
                        "musicId":0,
                        "switch":0
                     },
                     "visitor":{
                        "musicId":0,
                        "switch":1
                     }
                  }
               },
               {
                  "ringId":-1,
                  "ringName":"Reolink Chime",
                  "type":{
                     "md":{
                        "musicId":0,
                        "switch":0
                     },
                     "people":{
                        "musicId":0,
                        "switch":0
                     },
                     "visitor":{
                        "musicId":0,
                        "switch":1
                     }
                  }
               },
               {
                  "ringId":-1,
                  "ringName":"Reolink Chime",
                  "type":{
                     "md":{
                        "musicId":0,
                        "switch":0
                     },
                     "people":{
                        "musicId":0,
                        "switch":0
                     },
                     "visitor":{
                        "musicId":0,
                        "switch":1
                     }
                  }
               },
               {
                  "ringId":-1,
                  "ringName":"Reolink Chime",
                  "type":{
                     "md":{
                        "musicId":0,
                        "switch":0
                     },
                     "people":{
                        "musicId":0,
                        "switch":0
                     },
                     "visitor":{
                        "musicId":0,
                        "switch":1
                     }
                  }
               }
            ]
         }
      }
   }
]
starkillerOG commented 7 months ago

I have already been using the GetChnTypeInfo for some time. I really hope they will add the hardware version to this command!

GetWebHook, SetWebHook and TestWebHook were already implemented in the reolink-aio library. They work but are not too usefull, there is not so much info in the webhook calls and they are coupled to the push settings, making them very messy. ONVIF WS base subscription is a better option in my opinion.

starkillerOG commented 7 months ago

@mnpg thank you very very much for these additional commands, very usefull.

I am especially thrilled about the QuickReplyPlay command. And the GetDingDongCfg is certainly interesting since it looks like some new chimes are comming.

mnpg commented 7 months ago

The command: body = [{"cmd":"QuickReplyPlay","action":0,"param":{"id": 1}}] works and plays the quick reply message. I already implemented it in the reolink-aio library :)

@starkillerOG, in the command QuickReplyPlay, does the id parameter correspond to the response number (id parameter for the AudioFileList) we would like to hear?

starkillerOG commented 7 months ago

The command: body = [{"cmd":"QuickReplyPlay","action":0,"param":{"id": 1}}] works and plays the quick reply message. I already implemented it in the reolink-aio library :)

@starkillerOG, in the command QuickReplyPlay, does the id parameter correspond to the response number (id parameter for the AudioFileList) we would like to hear?

Yes exactly. The ID equals the file_id.

starkillerOG commented 6 months ago

@mnpg do you know how the SetAudioFileList command works for the doorbell? Does it allow you to upload a quick replay audio file directly?

mnpg commented 5 months ago

Hi @starkillerOG , sorry to reply you late i was on holidays. I will take a look.

mnpg commented 4 months ago

hi @starkillerOG, here the only infos i found about SetAudioFileList :


{
AudioFileList: {
                      id: n.identity,
                      fileName: n.cFileName,
                      channel: this.index
                      }
}

Does it allow you to upload a quick replay audio file directly?

I don't know, no easy to understand their js file

user45876 commented 4 months ago

Sorry for the noise. You guys are fabulous. Thank you very much.