Plugin Reolink (en beta)

J’ai fait un push pour corriger ce bug.
As tu vérifier les updates sur le market?

Voila, je viens de faire l’update et ca fonctionne. Bravo :slight_smile:

Mes 3 cameras sont paramétrés mais par contre ca tourne en rond quand j’essaie de récupérer les PTZ

Fait voir le log stp que j’investigue

Voila le log :

[2022-01-23 21:27:34][DEBUG] : Action demandé : GetPtzPreset
[2022-01-23 21:27:34][DEBUG] : Vérification à 1642969654 du TOKEN : 396ac578382deb3 Valable jusqu'a : 1642972538
[2022-01-23 21:27:34][DEBUG] : API Token OK
[2022-01-23 21:27:34][DEBUG] : =========================================================
[2022-01-23 21:27:34][DEBUG] : URL de requête => http://192.168.11.44:1046/cgi-bin/api.cgi?cmd=GetPtzPreset&token=396ac578382deb3
[2022-01-23 21:27:34][DEBUG] : Payload => [{"cmd":"GetPtzPreset","action":0,"param":{"channel":0}}]
[2022-01-23 21:27:34][DEBUG] : Réponse caméra >> [    {       "cmd" : "GetPtzPreset",       "code" : 0,       "value" : {          "PtzPreset" : [             {                "channel" : 0,                "enable" : 1,                "id" : 1,                "name" : "P1"             },             {                "channel" : 0,                "enable" : 1,                "id" : 2,                "name" : "P0"             },             {                "channel" : 0,                "enable" : 0,                "id" : 3,                "name" : "pos3"             },             {                "channel" : 0,                "enable" : 0,                "id" : 4,                "name" : "pos4"             },             {                "channel" : 0,                "enable" : 0,                "id" : 5,                "name" : "pos5"             },             {                "channel" : 0,                "enable" : 0,                "id" : 6,                "name" : "pos6"             },             {                "channel" : 0,                "enable" : 0,                "id" : 7,                "name" : "pos7"             },             {                "channel" : 0,                "enable" : 0,                "id" : 8,                "name" : "pos8"             },             {                "channel" : 0,                "enable" : 0,                "id" : 9,                "name" : "pos9"             },             {                "channel" : 0,                "enable" : 0,                "id" : 10,                "name" : "pos10"             },             {                "channel" : 0,                "enable" : 0,                "id" : 11,                "name" : "pos11"             },             {                "channel" : 0,                "enable" : 0,                "id" : 12,                "name" : "pos12"             },             {                "channel" : 0,                "enable" : 0,                "id" : 13,                "name" : "pos13"             },             {                "channel" : 0,                "enable" : 0,                "id" : 14,                "name" : "pos14"             },             {                "channel" : 0,                "enable" : 0,                "id" : 15,                "name" : "pos15"             },             {                "channel" : 0,                "enable" : 0,                "id" : 16,                "name" : "pos16"             },             {                "channel" : 0,                "enable" : 0,                "id" : 17,                "name" : "pos17"             },             {                "channel" : 0,                "enable" : 0,                "id" : 18,                "name" : "pos18"             },             {                "channel" : 0,                "enable" : 0,                "id" : 19,                "name" : "pos19"             },             {                "channel" : 0,                "enable" : 0,                "id" : 20,                "name" : "pos20"             },             {                "channel" : 0,                "enable" : 0,                "id" : 21,                "name" : "pos21"             },             {                "channel" : 0,                "enable" : 0,                "id" : 22,                "name" : "pos22"             },             {                "channel" : 0,                "enable" : 0,                "id" : 23,                "name" : "pos23"             },             {                "channel" : 0,                "enable" : 0,                "id" : 24,                "name" : "pos24"             },             {                "channel" : 0,                "enable" : 0,                "id" : 25,                "name" : "pos25"             },             {                "channel" : 0,                "enable" : 0,                "id" : 26,                "name" : "pos26"             },             {                "channel" : 0,                "enable" : 0,                "id" : 27,                "name" : "pos27"             },             {                "channel" : 0,                "enable" : 0,                "id" : 28,                "name" : "pos28"             },             {                "channel" : 0,                "enable" : 0,                "id" : 29,                "name" : "pos29"             },             {                "channel" : 0,                "enable" : 0,                "id" : 30,                "name" : "pos30"             },             {                "channel" : 0,                "enable" : 0,                "id" : 31,                "name" : "pos31"             },             {                "channel" : 0,                "enable" : 0,                "id" : 32,                "name" : "pos32"             },             {                "channel" : 0,                "enable" : 0,                "id" : 33,                "name" : "pos33"             },             {                "channel" : 0,                "enable" : 0,                "id" : 34,                "name" : "pos34"             },             {                "channel" : 0,                "enable" : 0,                "id" : 35,                "name" : "pos35"             },             {                "channel" : 0,                "enable" : 0,                "id" : 36,                "name" : "pos36"             },             {                "channel" : 0,                "enable" : 0,                "id" : 37,                "name" : "pos37"             },             {                "channel" : 0,                "enable" : 0,                "id" : 38,                "name" : "pos38"             },             {                "channel" : 0,                "enable" : 0,                "id" : 39,                "name" : "pos39"             },             {                "channel" : 0,                "enable" : 0,                "id" : 40,                "name" : "pos40"             },             {                "channel" : 0,                "enable" : 0,                "id" : 41,                "name" : "pos41"             },             {                "channel" : 0,                "enable" : 0,                "id" : 42,                "name" : "pos42"             },             {                "channel" : 0,                "enable" : 0,                "id" : 43,                "name" : "pos43"             },             {                "channel" : 0,                "enable" : 0,                "id" : 44,                "name" : "pos44"             },             {                "channel" : 0,                "enable" : 0,                "id" : 45,                "name" : "pos45"             },             {                "channel" : 0,                "enable" : 0,                "id" : 46,                "name" : "pos46"             },             {                "channel" : 0,                "enable" : 0,                "id" : 47,                "name" : "pos47"             },             {                "channel" : 0,                "enable" : 0,                "id" : 48,                "name" : "pos48"             },             {                "channel" : 0,                "enable" : 0,                "id" : 49,                "name" : "pos49"             },             {                "channel" : 0,                "enable" : 0,                "id" : 50,                "name" : "pos50"             },             {                "channel" : 0,                "enable" : 0,                "id" : 51,                "name" : "pos51"             },             {                "channel" : 0,                "enable" : 0,                "id" : 52,                "name" : "pos52"             },             {                "channel" : 0,                "enable" : 0,                "id" : 53,                "name" : "pos53"             },             {                "channel" : 0,                "enable" : 0,                "id" : 54,                "name" : "pos54"             },             {                "channel" : 0,                "enable" : 0,                "id" : 55,                "name" : "pos55"             },             {                "channel" : 0,                "enable" : 0,                "id" : 56,                "name" : "pos56"             },             {                "channel" : 0,                "enable" : 0,                "id" : 57,                "name" : "pos57"             },             {                "channel" : 0,                "enable" : 0,                "id" : 58,                "name" : "pos58"             },             {                "channel" : 0,                "enable" : 0,                "id" : 59,                "name" : "pos59"             },             {                "channel" : 0,                "enable" : 0,                "id" : 60,                "name" : "pos60"             },             {                "channel" : 0,                "enable" : 0,                "id" : 61,                "name" : "pos61"             },             {                "channel" : 0,                "enable" : 0,                "id" : 62,                "name" : "pos62"             },             {                "channel" : 0,                "enable" : 0,                "id" : 63,                "name" : "pos63"             },             {                "channel" : 0,                "enable" : 0,                "id" : 64,                "name" : "pos64"             }          ]       }    } ]
1 « J'aime »

Au vu du log la requête abouti bien.
Quand tu dis ca tourne en rond c’est à dire ?

la fleche dans le coin superieur droite sur la tuile, elle tourne en rond et s arrete que quand je refresh la page sans jamais recuperer les PTZ

Normalement juste après le log que tu as mis il y a des lignes qui détails les PTZ trouvés :

[2022-01-24 21:08:26][DEBUG] : =========================================================
[2022-01-24 21:08:26][DEBUG] : URL de requête => http://192.168.0.63:80/cgi-bin/api.cgi?cmd=GetPtzPreset&token=73b3acd1eabf352
[2022-01-24 21:08:26][DEBUG] : HTTP code 200 OK
[2022-01-24 21:08:26][DEBUG] : Payload => [{"cmd":"GetPtzPreset","action":0,"param":{"channel":0}}]
[2022-01-24 21:08:26][DEBUG] : Réponse caméra >> [{"cmd":"GetPtzPreset","code":0,"value":{"PtzPreset":[{"channel":0,"enable":1,"id":1,"name":"Salon"},{"channel":0,"enable":1,"id":2,"name":"Fenêtre"},{"channel":0,"enable":1,"id":3,"name":"Entrée"},{"channel":0,"enable":1,"id":4,"name":"Cuisine"},{"channel":0,"enable":0,"id":5,"name":"pos5"},{"channel":0,"enable":0,"id":6,"name":"pos6"},{"channel":0,"enable":0,"id":7,"name":"pos7"},{"channel":0,"enable":0,"id":8,"name":"pos8"},{"channel":0,"enable":0,"id":9,"name":"pos9"},{"channel":0,"enable":0,"id":10,"name":"pos10"},{"channel":0,"enable":0,"id":11,"name":"pos11"},{"channel":0,"enable":0,"id":12,"name":"pos12"},{"channel":0,"enable":0,"id":13,"name":"pos13"},{"channel":0,"enable":0,"id":14,"name":"pos14"},{"channel":0,"enable":0,"id":15,"name":"pos15"},{"channel":0,"enable":0,"id":16,"name":"pos16"},{"channel":0,"enable":0,"id":17,"name":"pos17"},{"channel":0,"enable":0,"id":18,"name":"pos18"},{"channel":0,"enable":0,"id":19,"name":"pos19"},{"channel":0,"enable":0,"id":20,"name":"pos20"},{"channel":0,"enable":0,"id":21,"name":"pos21"},{"channel":0,"enable":0,"id":22,"name":"pos22"},{"channel":0,"enable":0,"id":23,"name":"pos23"},{"channel":0,"enable":0,"id":24,"name":"pos24"},{"channel":0,"enable":0,"id":25,"name":"pos25"},{"channel":0,"enable":0,"id":26,"name":"pos26"},{"channel":0,"enable":0,"id":27,"name":"pos27"},{"channel":0,"enable":0,"id":28,"name":"pos28"},{"channel":0,"enable":0,"id":29,"name":"pos29"},{"channel":0,"enable":0,"id":30,"name":"pos30"},{"channel":0,"enable":0,"id":31,"name":"pos31"},{"channel":0,"enable":0,"id":32,"name":"pos32"},{"channel":0,"enable":0,"id":33,"name":"pos33"},{"channel":0,"enable":0,"id":34,"name":"pos34"},{"channel":0,"enable":0,"id":35,"name":"pos35"},{"channel":0,"enable":0,"id":36,"name":"pos36"},{"channel":0,"enable":0,"id":37,"name":"pos37"},{"channel":0,"enable":0,"id":38,"name":"pos38"},{"channel":0,"enable":0,"id":39,"name":"pos39"},{"channel":0,"enable":0,"id":40,"name":"pos40"},{"channel":0,"enable":0,"id":41,"name":"pos41"},{"channel":0,"enable":0,"id":42,"name":"pos42"},{"channel":0,"enable":0,"id":43,"name":"pos43"},{"channel":0,"enable":0,"id":44,"name":"pos44"},{"channel":0,"enable":0,"id":45,"name":"pos45"},{"channel":0,"enable":0,"id":46,"name":"pos46"},{"channel":0,"enable":0,"id":47,"name":"pos47"},{"channel":0,"enable":0,"id":48,"name":"pos48"},{"channel":0,"enable":0,"id":49,"name":"pos49"},{"channel":0,"enable":0,"id":50,"name":"pos50"},{"channel":0,"enable":0,"id":51,"name":"pos51"},{"channel":0,"enable":0,"id":52,"name":"pos52"},{"channel":0,"enable":0,"id":53,"name":"pos53"},{"channel":0,"enable":0,"id":54,"name":"pos54"},{"channel":0,"enable":0,"id":55,"name":"pos55"},{"channel":0,"enable":0,"id":56,"name":"pos56"},{"channel":0,"enable":0,"id":57,"name":"pos57"},{"channel":0,"enable":0,"id":58,"name":"pos58"},{"channel":0,"enable":0,"id":59,"name":"pos59"},{"channel":0,"enable":0,"id":60,"name":"pos60"},{"channel":0,"enable":0,"id":61,"name":"pos61"},{"channel":0,"enable":0,"id":62,"name":"pos62"},{"channel":0,"enable":0,"id":63,"name":"pos63"},{"channel":0,"enable":0,"id":64,"name":"pos64"}]}}]
[2022-01-24 21:08:26][DEBUG] : Ajout du PTZ preset = 1|Salon
[2022-01-24 21:08:26][DEBUG] : Ajout du PTZ preset = 2|Fenêtre
[2022-01-24 21:08:26][DEBUG] : Ajout du PTZ preset = 3|Entrée
[2022-01-24 21:08:26][DEBUG] : Ajout du PTZ preset = 4|Cuisine

Tu as ces lignes ou rien ?

Non, je n’ai pas ces lignes.

J’ai installé la beta de ce matin et ça ne récupère toujours pas les PTZ

Voici le log

[2022-01-25 07:39:53][DEBUG] : Action demandé : GetPtzPreset
[2022-01-25 07:39:53][DEBUG] : Vérification à 1643092793 du TOKEN :  Valable jusqu'a : -15
[2022-01-25 07:39:53][DEBUG] : Aucun API Token > récupération nécéssaire
[2022-01-25 07:39:53][DEBUG] : Camera login...
[2022-01-25 07:39:53][DEBUG] : =========================================================
[2022-01-25 07:39:53][DEBUG] : URL de requête => ://192.168.11.44:1046/cgi-bin/api.cgi?cmd=Login&token=
[2022-01-25 07:39:53][ERROR] : HTTP code 0 NOK Protocol "" not supported or disabled in libcurl
[2022-01-25 07:39:53][ERROR] : Erreur lecture réponse
[2022-01-25 07:39:53][ERROR] : Echec > Login impossible
[2022-01-25 07:39:53][DEBUG] : =========================================================
[2022-01-25 07:39:53][DEBUG] : URL de requête => ://192.168.11.44:1046/cgi-bin/api.cgi?cmd=GetPtzPreset&token=
[2022-01-25 07:39:53][ERROR] : HTTP code 0 NOK Protocol "" not supported or disabled in libcurl
[2022-01-25 07:39:53][ERROR] : Erreur lecture réponse

Et je n’arrive plus me connecter à la caméra ni par « Tester la connexion » ni par « Récupérer les informations » j’ai sur mes 3 caméras le message « Impossible de se connecter à la caméra »

Pourtant elles fonctionnes bien, je les vois sur le board jeedom et je peux m’y connecter depuis mon navigateur.

Corrigé dans la dernière update sur le market

@mnpg aurais tu des informations sur les RLC810 il semble que les requêtes APi répondent ceci :

========================================================= 0022|[2022-01-25 08:55:37]DEBUG : URL de requête => http://192.168.1.239:80/cgi-bin/api.cgi?cmd=Login&token= 0023|[2022-01-25 08:55:37]ERROR : HTTP code 302 NOK Entête : # 302 Found nginx

Normalement le header est censé me retourner la location à contacter dans le cas d’une 302 mais là, la caméra n’est pas très loquace ?
Nouvelle URL d’API ?

salut @Jezza34000,

pour une nouvelle URL d’API, non, je ne pense pas (ou peut-être dans le tout tout dernier firmware et encore, je suis pas certain). Je suis étonné de cette réponse HTTP de la caméra en retour d’un push d’une commande. Je m’attends plus à avoir du 200, ou voir du 404.
Tu m’as fait suivre un bout du log, tu l’aurais en entier pour que je comprenne mieux?

C’est tout bon en faite HTTPS obligatoire, la caméra répond 302 lorsque tu essaie de te connecter en HTTP

ok.

J’ai une autre info a te donner. j’ai testé ton plugin avec mes cameras « AI » et de temps en temps, après que la commande de login soit passé correctement, tous les commandes exécutées retournent un payload crypté. Je l’avais déjà constaté avec des scripts perso.

voici le log de ma camera ayant eu ce problème :
[2022-01-25 03:54:41][DEBUG] : URL de requête => ://192.168.1.23:443/cgi-bin/api.cgi?cmd=Login&token=
[2022-01-25 03:54:41][ERROR] : HTTP code 0 NOK Protocol "" not supported or disabled in libcurl
[2022-01-25 03:54:41][ERROR] : Erreur lecture réponse
[2022-01-25 03:54:41][ERROR] : Echec > Login impossible
[2022-01-25 03:54:41][ERROR] : Connection à la caméra NOK
[2022-01-25 03:54:46][DEBUG] : Vérification à 1643079286 du TOKEN :  Valable jusqu'a : -15
[2022-01-25 03:54:46][DEBUG] : Aucun API Token > récupération nécéssaire
[2022-01-25 03:54:46][DEBUG] : Camera login...
[2022-01-25 03:54:46][DEBUG] : =========================================================
[2022-01-25 03:54:46][DEBUG] : URL de requête => http://192.168.1.23:80/cgi-bin/api.cgi?cmd=Login&token=
[2022-01-25 03:54:46][DEBUG] : HTTP code 200 OK
[2022-01-25 03:54:46][DEBUG] : Payload => [{"cmd":"Login","action":0,"param":{"User":{"userName":"admin","password":"******"}}}]
[2022-01-25 03:54:46][DEBUG] : Réponse caméra >> [{"cmd":"Login","code":0,"value":{"Token":{"leaseTime":3600,"name":"b7975277449a735"}}}]
[2022-01-25 03:54:46][DEBUG] : TOKEN récupéré, enregistrement OK
[2022-01-25 03:54:46][INFO] : Connection à la caméra réussie
[2022-01-25 03:54:48][DEBUG] : Obtention des informations de la caméra
[2022-01-25 03:54:48][DEBUG] : Vérification à 1643079288 du TOKEN : b7975277449a735 Valable jusqu'a : 1643082871
[2022-01-25 03:54:48][DEBUG] : API Token OK
[2022-01-25 03:54:48][DEBUG] : =========================================================
[2022-01-25 03:54:48][DEBUG] : URL de requête => http://192.168.1.23:80/cgi-bin/api.cgi?cmd=GetDevInfo&token=b7975277449a735
[2022-01-25 03:54:48][DEBUG] : HTTP code 200 OK
[2022-01-25 03:54:48][DEBUG] : Payload => [{"cmd":"GetDevInfo","action":0,"param":[]}]
[2022-01-25 03:54:48][DEBUG] : Réponse caméra >> vwMTSfsO+RSlwTmIS/px91Hv8g8tZ/7YshlV+o+o4OsO+3DojD2qJwVF3b9ZeriUWk7Vz6goG0HmHb472T+ukLqMFUuCe5pQfRTQSHRm5hjfsBuMMmRmHh1gMGIxzVhysprL+N+BMcn9+tnHd9UFxbJllOG8oNIVKQYfXq1+SigNlbt9pPib9dPJupxXECa82HF5Pw9piI4=
[2022-01-25 03:54:48][ERROR] : Erreur lecture réponse
[2022-01-25 03:55:18][DEBUG] : Vérification à 1643079318 du TOKEN : b7975277449a735 Valable jusqu'a : 1643082871
[2022-01-25 03:55:18][DEBUG] : API Token OK
[2022-01-25 03:55:18][INFO] : Connection à la caméra réussie
[2022-01-25 03:55:24][DEBUG] : Obtention des informations de la caméra
[2022-01-25 03:55:24][DEBUG] : Vérification à 1643079324 du TOKEN : b7975277449a735 Valable jusqu'a : 1643082871
[2022-01-25 03:55:24][DEBUG] : API Token OK

NB : j’ai relancé la connexion ce matin et cette fois-ci les payloads apparaissent en clair.

Ah… Effectivement
Et y a t-il de la doc quelque part concernant ce cryptage ?

malheureusement non.
Dans les nouveaux firmware, quand tu accède à l’interface web des cameras, les payloads sont cryptés à l’envoi et en retour.

Cela passe par une clé AES pour crypter/décrypter les payloads.

Cette clé AES est générée dès l’authentification. La méthode de génération de la clé est contenue dans le fichier js « ControllerLogin.js » -https://.../js/ControllerLogin.js-, en voici un extrait du code :

    ControllerLogin.login = function() {
        if($('#login_text_username').val() == ''){
            bc_alert('Invalid username.', 'error');
            return;
        }
        ControllerLogin.waiter.show();
        CGI.sendCommand('Login', {
            Version: 1
        },
        function(data) {
            var Realm = data.Realm;
            var Qop = data.Qop;
            var Nonce = data.Nonce;
            var Nc = data.Nc;
            var Method = data.Method;
            var Uri = data.Uri;
            var UserName = $('#login_text_username').val();
            var Password = $('#login_text_password').val();
            var Cnonce = '';
            var len = 48;
            const seed = '0123456789abcdef';
            while ( len -- > 0 ) {
                Cnonce += seed[Math.floor(Math.random() * seed.length)];
            }
            var hash1 = cryptoUtils.MD5(UserName + ':' + Realm + ':' + Password);
            var hash2 = cryptoUtils.MD5(Method + ':' + Uri);
            var Response = cryptoUtils.MD5(hash1 + ':' + Nonce + ':' + Nc + ':' + Cnonce + ':' + Qop + ':' + hash2);
            cryptoUtils.setAesKey(cryptoUtils.MD5(Nonce + '-' + Password + '-' + Cnonce).substr(0, 16).toUpperCase());
            CGI.sendCommand('Login', {
                Version: 1,
                Digest: {
                    UserName: UserName,
                    Realm: Realm,
                    Method: Method,
                    Uri: Uri,
                    Nonce: Nonce,
                    Nc: Nc,
                    Cnonce: Cnonce,
                    Qop: Qop,
                    Response: Response
                }
            },

Quand tu envoies un payload via une commande, voici ce qu’il fait (cf fichier remoteConfig.*****.js):
NB : la variable t est le payload envoyé

key: 'send',
          value: function (e, t, n) {
            var i = this;
            return this.location = CGI.getLocation(),
            w['a'].hasAesKey() && (t = w['a'].encrypt(t)),
            new Promise((function (a, r) {
              S.a.ajax({
                url: e,
                type: 'POST',
                contentType: 'application/json',
                timeout: n || i.timeout,
                data: t,
                success: function (e) {
                  a(e)
                },

Ca va poser problème ça :roll_eyes:

cela peut arriver
tu n’as pas le pb lors de l’envoi des payloads à la caméra. C’est plus côté réponse (payload en retour -cas des commandes Getxxx) où on a pas de fichier json « clair ».
Par expérience, mais sans infos Reolink, je me suis apercu de ce « dysfonctionnement » sur mes scripts quand le token était expiré et que je devait le regenere.J’étais obligé de « flusher » les infos du token existant et initié une nouvelle connexion.