Divers
Exploitation de l'API sous NodeRED
L'API est facilement exploitable sous NodeRED (pour piloter sa domotique par exemple).
Voici un exemple très simple qui va s'authentifier et récuperercupérer les infos :
[{"id":"603f5240575d69fd","type":"inject","z":"65c639a94675a525","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":340,"wires":[["46170720978be76e"]]},{"id":"46170720978be76e","type":"http request","z":"65c639a94675a525","name":"","method":"POST","ret":"obj","paytoqs":"ignore","url":"digital.iservices.rte-france.com/token/oauth","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Authorization","valueType":"other","valueValue":"Basic XXXXXXXXXXXXX"}],"credentials":{"user":"","password":""},"x":350,"y":340,"wires":[["6c061581acde6df7","dc37b04498e7925b"]]},{"id":"6c061581acde6df7","type":"debug","z":"65c639a94675a525","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":530,"y":300,"wires":[]},{"id":"889244ce6c90785a","type":"http request","z":"65c639a94675a525","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"digital.iservices.rte-france.com/open_api/ecowatt/v4/signals","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Authorization","valueType":"msg","valueValue":"payload"}],"x":730,"y":340,"wires":[["9e28966d6da84a1a"]]},{"id":"dc37b04498e7925b","type":"function","z":"65c639a94675a525","name":"function 6","func":"msg.payload=\"Bearer \" + msg.payload.access_token;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":340,"wires":[["889244ce6c90785a"]]},{"id":"9e28966d6da84a1a","type":"debug","z":"65c639a94675a525","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":910,"y":340,"wires":[]}]
Pour l'insérer aller dans le menu > import et copier le code JSON précédent. La seule étape restante consiste à mettre votre clé d'accès à l'application concernée (dans le premier nœud "HTTP request" modifiez le header et ajouter votre clé en remplacement des XXXXXXXXXXXXX). Pour obtenir cette clé il faut créer un compte sur le portail RTE, s'abonner à l'application puis récupérer la clé en base 64 (Mes Applications > App concenrnée > Copier en base64)