Tronity - get SOC for your BEV from their API

Example how to get the state of charge (and maybe other useful information) for your car using the Tronity API*. The API is available for paid customers only (tronity.io).

[{"id":"3f3f5aae.72acee","type":"tab","label":"Tronity","disabled":false,"info":""},{"id":"60b00bb6.c7d104","type":"http request","z":"3f3f5aae.72acee","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api-eu.TRONITY.io/v1/vehicles/dieNummerVomAuto/bulk","tls":"","persist":false,"proxy":"","authType":"","x":670,"y":300,"wires":[["e1264f92.4b7f4","a6e605ae.1e255","5009da1b.247ab4"]]},{"id":"e1264f92.4b7f4","type":"debug","z":"3f3f5aae.72acee","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":850,"y":240,"wires":[]},{"id":"7d530788.01291","type":"http request","z":"3f3f5aae.72acee","name":"","method":"POST","ret":"obj","paytoqs":"query","url":"https://api-eu.TRONITY.io/oauth/authentication","tls":"","persist":false,"proxy":"","authType":"","x":550,"y":180,"wires":[["1cc29f2a.b43be1"]]},{"id":"b34d9e97.3816a","type":"inject","z":"3f3f5aae.72acee","name":"15 minutes","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"900","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":180,"wires":[["18f329a5.5f6e7e"]]},{"id":"18f329a5.5f6e7e","type":"change","z":"3f3f5aae.72acee","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"client_id\":\"die ID\",\"client_secret\":\"das Passwort\",\"grant_type\":\"app\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":180,"wires":[["7d530788.01291"]]},{"id":"ced764e7.359328","type":"comment","z":"3f3f5aae.72acee","name":"Get car info","info":"","x":130,"y":260,"wires":[]},{"id":"d6859fce.3159","type":"comment","z":"3f3f5aae.72acee","name":"Get new token every 15 minutes","info":"","x":190,"y":140,"wires":[]},{"id":"1cc29f2a.b43be1","type":"change","z":"3f3f5aae.72acee","name":"","rules":[{"t":"set","p":"tronitybearer","pt":"flow","to":"payload.access_token","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":180,"wires":[[]]},{"id":"c41b108d.772ae","type":"function","z":"3f3f5aae.72acee","name":"set headers with JWT Bearer Token","func":"let token = flow.get('tronitybearer');\n\nmsg.headers = {\n    'Authorization': 'Bearer ' + token\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":300,"wires":[["60b00bb6.c7d104"]]},{"id":"64090349.cc9f3c","type":"inject","z":"3f3f5aae.72acee","name":"3 minutes","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"180","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":300,"wires":[["c41b108d.772ae"]]},{"id":"a6e605ae.1e255","type":"change","z":"3f3f5aae.72acee","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.level","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":300,"wires":[["82cd1c8a.ac5c5"]]},{"id":"82cd1c8a.ac5c5","type":"debug","z":"3f3f5aae.72acee","name":"SOC","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"soc","statusType":"auto","x":1070,"y":300,"wires":[]},{"id":"5009da1b.247ab4","type":"change","z":"3f3f5aae.72acee","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.charging","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":360,"wires":[["da987961.161518"]]},{"id":"da987961.161518","type":"debug","z":"3f3f5aae.72acee","name":"Ladestatus","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"soc","statusType":"auto","x":1090,"y":360,"wires":[]},{"id":"c82a10b6.b67cc","type":"comment","z":"3f3f5aae.72acee","name":"Info (click me)","info":"1) Login here: https://app.platform.tronity.io/\n(same credentials as in the app)\n\n2) Open the existing app. Needed are 3 things:\n- ID \n- Password (regenerate a new one to show it)\n- Number of your car\n\n3) Enter ID and password in the payload from token\n4) Enter the number of your car in http-request","x":130,"y":60,"wires":[]}]

Flow Info

Created 3 years, 2 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x4)
  • comment (x3)
  • debug (x3)
  • function (x1)
  • http request (x2)
  • inject (x2)
Other
  • tab (x1)

Tags

  • oauth
  • jwt
  • bev
  • soc
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option