Skip to content

Instantly share code, notes, and snippets.

@svenblum
Created May 21, 2021 13:30
Show Gist options
  • Save svenblum/8cbe02c96bd96d095f8cd4a790716487 to your computer and use it in GitHub Desktop.
Save svenblum/8cbe02c96bd96d095f8cd4a790716487 to your computer and use it in GitHub Desktop.
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": []
}
]
@klemensatgithub
Copy link

Hi
was ist mit "NummervomAuto" gemeint? VIN? ID in Tronity? oder laufende Nummer der Fahrzeuge?

Kriegt das nicht zum laufen

VG
Klemens

@svenblum
Copy link
Author

svenblum commented Feb 5, 2022

Hi @klemensatgithub

Du musst dich bei Tronity auf der API-Plattform anmelden (gleiche Zugangsdaten). Dort findest du die gesuchte Info.

https://app.platform.tronity.io/

Viel Erfolg
Sven

@klemensatgithub
Copy link

klemensatgithub commented Feb 5, 2022 via email

@svenblum
Copy link
Author

svenblum commented Feb 5, 2022

Du musst einfach die folgenden 3 Dinge ersetzen

-Client-ID & Client-Secret (stehen links) im ersten set-payload da im Json-Script (kleine 3 Punkte klicken)

Viel Glück
Sven

@klemensatgithub
Copy link

klemensatgithub commented Feb 5, 2022 via email

@svenblum
Copy link
Author

svenblum commented Feb 5, 2022

Den Skoda kriegst du über die VW-Schnittstelle viel besser direkt. Da musst du den Umweg über Tronity nicht machen. Kuck mal hier: https://flows.nodered.org/node/node-red-contrib-volkswagen-we

@klemensatgithub
Copy link

klemensatgithub commented Feb 5, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment