Open Michael-K-at-GitHub opened 9 months ago
@andreas-fe Any link to an issue or pull request in that project with relation to that problem? I could not find it while scrolling through issues.
We are still in the issue #67 with the problem of the deprecated Tesla API. For me as new node-red user, the usage of the latest version will result in a crash + reboot of node-red
I know, that we are in issue #67 here ;) I was referring to the link you provided towards the evcc project. I was unable to find something with respect to that deprecated API issue in that repository, therefore I asked you for any more detailed info. My goal would be to see how they solved it in order to doublecheck whether that solution would be applicable here for node-red.
@onokje There seems to be no way as a private person to sign up to the new Tesla fleet API. I guess the easiest possibility to still revive this node red plugin might be to adapt it to use a proxy service where the provider relays towards the new Tesla fleet API.
I just recently found Teslemetry, who offer exactly this service. Of course this is not free of charge for the individual user, but their service has the capability to get back full functionality of node-red-tesla. What do you think?
I would like to have this work again, as I'm now left to manage my charging manually. But, I do not like that I have to rely on another online service that may collect my data, and that I have to pay for. And I understand that noone is going to offer a free proxy that I can fully trust. This is way out of this topic, but I want to see if I can plant a seed with someone that could make my wish come true: @jakepusateri linked to the official Tesla repo for complete local control over BLE: https://github.com/teslamotors/vehicle-command/blob/main/cmd/tesla-control/README.md My wish is that someone can make this into a package for ESP with MQTT or ESPhome support. That way I can have an ESP somewhere close to the cars parking spot and control the charging. With this we do not need a custom node, it relies on the default MQTT out for control through nodered. I realize it may not suit all needs though.
My 2 cents on the questing by @Lineflyer, is that his suggestion seems like the lesser of the protentional evil options out there. With for instance Tessie, you know they collect your data, as they will present it on their own web-dashboard.
This is related to my last post. I made a feature request a while ago for ESPhome, this have had some comments lately. More upvotes and activity will push it further up the wish-list and attract more developers. https://github.com/esphome/feature-requests/issues/2630
Has anyone already managed to get Teslemetry running with the "old" Tesla Node Red contribution? I signed up on Teslemetry, created a Access Token and tried to use this one in the Node Red Tesla node, but it is unfortunatelly not working. Would be very thankful to know that it is basically possible to do so.
Has anyone already managed to get Teslemetry running with the "old" Tesla Node Red contribution? I signed up on Teslemetry, created a Access Token and tried to use this one in the Node Red Tesla node, but it is unfortunatelly not working. Would be very thankful to know that it is basically possible to do so.
Teslemetry won't work out of the box using this palette. But all you need is a simple HTTP call (there are NodeRed palettes for this if you need them).
The API data itself is however fully compatible with what you might have used with the former palette. So you just need to replace the TeslaNodeRed specific box by the HTTP call.
This is how I implemented it:
The function prepare all the data for the HTTP request, then the request, then I remove the "response" object level of the teslemetry response which makes it 100% identical to the old data.
This is the content of the function node (tokens, VIN, etc. are stored as flow variables)
// Call: https://api.teslemetry.com/api/1/vehicles/{vin}?token={token}
let base_url = "https://api.teslemetry.com/api/1/vehicles/"
let token = flow.get ('accessToken')
let vin = flow.get ('VIN')
// GET /api/1/vehicles/{vehicle_tag}/vehicle_data
let scope = "/vehicle_data"
let query = "?endpoints=charge_state%3Bclimate_state%3Bclosures_state%3Bdrive_state%3Bgui_settings%3Blocation_data%3Bvehicle_config%3Bvehicle_state"
let url = base_url + vin + scope + query
msg.url = url
msg.bearerToken = flow.get('bearerToken')
return msg;
Hope this helps!
Sorry for the dumb question, but I've tried your flow and I get a message -
"{"status":401,"response":null,"error":"missing_token","service":"auth"}"
I've replaced 'accessToken' with my Token from the Teslemetry console and replaced VIN with my own. I'm a bit unclear where the 'bearerToken' comes from?
First of all many thanks for your support. It's so great having people here explaining thing more detailed. Big thanks !!
I'm at the same stage as ChutneyMary, getting the same error. Would be great if someone could explain that bearer token.
Greetings Michael
The bearerToken
I defined is simply used as a header information for the HTTP call as written in the Teslemetry documentation.
I defined it as follows:
flow.set('bearerToken', "Bearer " + accessToken)
So its simply your access token prepended by the string `Bearer ".
Within the http request node you have to add two headers as you may see in the screenshot:
I created a sample flow for you to import:
[
{
"id": "aa8dfd02dba5b031",
"type": "function",
"z": "d15d33a4fa9a8ad9",
"name": "Build example call",
"func": "// Call: https://api.teslemetry.com/api/1/vehicles/{vin}?token={token}\n\nlet base_url = \"https://api.teslemetry.com/api/1/vehicles/\"\nlet token = \"insert-your-access-token-here\"\nlet vin = \"insert-your-VIN-here\"\n\n// GET /api/1/vehicles/{vehicle_tag}/vehicle_data\nlet scope = \"/vehicle_data\"\nlet query = \"?endpoints=charge_state%3Bclimate_state%3Bclosures_state%3Bdrive_state%3Bgui_settings%3Blocation_data%3Bvehicle_config%3Bvehicle_state\"\n\nlet url = base_url + vin + scope + query\n\nmsg.url = url\nmsg.bearerToken = \"Bearer \" + token\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 330,
"y": 2800,
"wires": [
[
"a53074dc554aa469"
]
]
},
{
"id": "a53074dc554aa469",
"type": "http request",
"z": "d15d33a4fa9a8ad9",
"name": "Teslemetry GET",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "91a33722c228e6f1",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [
{
"keyType": "other",
"keyValue": "authorization",
"valueType": "msg",
"valueValue": "bearerToken"
},
{
"keyType": "other",
"keyValue": "accept",
"valueType": "other",
"valueValue": " application/json"
}
],
"x": 540,
"y": 2800,
"wires": [
[
"e3633a059c5103aa"
]
]
},
{
"id": "e3633a059c5103aa",
"type": "change",
"z": "d15d33a4fa9a8ad9",
"name": "Remove response level from object to make it look like Node-Red-contrib-tesla",
"rules": [
{
"t": "move",
"p": "payload.response",
"pt": "msg",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 940,
"y": 2800,
"wires": [
[]
]
},
{
"id": "91a33722c228e6f1",
"type": "tls-config",
"name": "",
"cert": "",
"key": "",
"ca": "",
"certname": "",
"keyname": "",
"caname": "",
"servername": "",
"verifyservercert": true,
"alpnprotocol": ""
}
]
Oh man, thank you sooo much!!! It's working :) And even better, I have an example now to understand whats happening and hopefully learn the rest by myself.
I would very much like to show my appreciation...
Great to hear, have fun. I am not so 100% happy, that I now have to use paid services to access my Tesla. IMHO not a good choice by Tesla to no longer allow indiviudals free access....the car was expensive enough...
Yeah, that’s right. I was also quite wondering and annoyed that Tesla changed this service. However, other brands don’t even offer anything like that. Even things like changing charging current in the vehicle is by far not standard. So for me it is worth it…
Likewise, I really appreciate the sample flow from @Lineflyer. Working well now.
What's not so clear to me is how to send commands. The three commands I used previously were Start Charge, Stop Charge, and Set Charging Amps.
Any suggestions?
Answering my own question... Here's a sample flow for Start Charge, Stop Charge and Set Charging Amps to 5 -
[ { "id": "ea0ef801d947afae", "type": "function", "z": "f18596704a26bc97", "name": "Charge Stop", "func": "let base_url = \"https://api.teslemetry.com/api/1/vehicles/\";\nlet token = \"Your_Teslemetry_Token_here\";\nlet vin = \"Your_VIN_here\";\n\n// POST /api/1/vehicles/{vehicle_tag}/vehicle_data\nlet scope = \"/command\";\nlet query = \"/charge_stop\";\n\nlet url = base_url + vin + scope + query;\n\n// Configure the msg object for the HTTP request\nmsg.method = \"POST\";\nmsg.url = url;\nmsg.headers = {\n 'Authorization': \"Bearer \" + token,\n 'Content-Type': 'application/json'\n};\n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 410, "y": 500, "wires": [ [ "e00e92c60aa1e6b6" ] ] }, { "id": "84e52d1abe17ad5a", "type": "inject", "z": "f18596704a26bc97", "name": "", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 240, "y": 500, "wires": [ [ "ea0ef801d947afae" ] ] }, { "id": "e00e92c60aa1e6b6", "type": "http request", "z": "f18596704a26bc97", "name": "Teslemetry POST", "method": "use", "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "91a33722c228e6f1", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [], "x": 670, "y": 500, "wires": [ [ "322dce8059e166de" ] ] }, { "id": "322dce8059e166de", "type": "debug", "z": "f18596704a26bc97", "name": "debug 20", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 860, "y": 500, "wires": [] }, { "id": "b8738ea936a56634", "type": "function", "z": "f18596704a26bc97", "name": "Charge Start", "func": "let base_url = \"https://api.teslemetry.com/api/1/vehicles/\";\nlet token = \"Your_Teslemetry_Token_here\";\nlet vin = \"Your_VIN_here\";\n\n// POST /api/1/vehicles/{vehicle_tag}/vehicle_data\nlet scope = \"/command\";\nlet query = \"/charge_start\";\n\nlet url = base_url + vin + scope + query;\n\n// Configure the msg object for the HTTP request\nmsg.method = \"POST\";\nmsg.url = url;\nmsg.headers = {\n 'Authorization': \"Bearer \" + token,\n 'Content-Type': 'application/json'\n};\n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 410, "y": 440, "wires": [ [ "febbe529f8d92091" ] ] }, { "id": "0b31a6e235d16557", "type": "inject", "z": "f18596704a26bc97", "name": "", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 240, "y": 440, "wires": [ [ "b8738ea936a56634" ] ] }, { "id": "febbe529f8d92091", "type": "http request", "z": "f18596704a26bc97", "name": "Teslemetry POST", "method": "use", "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "91a33722c228e6f1", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [], "x": 670, "y": 440, "wires": [ [ "7bd53abd0b45ca30" ] ] }, { "id": "7bd53abd0b45ca30", "type": "debug", "z": "f18596704a26bc97", "name": "debug 21", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 860, "y": 440, "wires": [] }, { "id": "bdcd206cecb33a1e", "type": "function", "z": "f18596704a26bc97", "name": "Set Charging Amps 5", "func": "let base_url = \"https://api.teslemetry.com/api/1/vehicles/\";\nlet token = \"Your_Teslemetry_Token_here\";\nlet vin = \"Your_VIN_here\";\n\n// POST /api/1/vehicles/{vehicle_tag}/vehicle_data\nlet scope = \"/command\";\nlet query = \"/set_charging_amps\";\n\nlet url = base_url + vin + scope + query;\n\n// Configure the msg object for the HTTP request\nmsg.method = \"POST\";\nmsg.url = url;\nmsg.headers = {\n 'Authorization': \"Bearer \" + token,\n 'Content-Type': 'application/json'\n};\n\nmsg.payload = {\"charging_amps\": \"5\"}; \n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 440, "y": 560, "wires": [ [ "9c11f1d5c1c00143" ] ] }, { "id": "55f10e8fd2475f49", "type": "inject", "z": "f18596704a26bc97", "name": "", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 240, "y": 560, "wires": [ [ "bdcd206cecb33a1e" ] ] }, { "id": "9c11f1d5c1c00143", "type": "http request", "z": "f18596704a26bc97", "name": "Teslemetry POST", "method": "use", "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "91a33722c228e6f1", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [], "x": 670, "y": 560, "wires": [ [ "d101e512cbe59c5a" ] ] }, { "id": "d101e512cbe59c5a", "type": "debug", "z": "f18596704a26bc97", "name": "debug 22", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 860, "y": 560, "wires": [] }, { "id": "91a33722c228e6f1", "type": "tls-config", "name": "", "cert": "", "key": "", "ca": "", "certname": "", "keyname": "", "caname": "", "servername": "", "verifyservercert": true, "alpnprotocol": "" } ]
Great, many thanks ! The only thing for me that’s missing is how to wake up the car when sleeping. Any hint on this ?
Try the following flow. The "if (msg.payload == 1)" in the Function node is to prevent the Wake Up being triggered on a redeploy of flows.
[
{
"id": "26d458d88ccdaba8",
"type": "inject",
"z": "e7594237b03366b2",
"name": "On only",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "1",
"payloadType": "num",
"x": 330,
"y": 240,
"wires": [
[
"7b307d3e82031041"
]
]
},
{
"id": "7b307d3e82031041",
"type": "function",
"z": "e7594237b03366b2",
"name": "Wake Up",
"func": "if (msg.payload == 1) {\n let base_url = \"https://api.teslemetry.com/api/1/vehicles/\";\n let token = \"Your_Teslemetry_token_here\";\n let vin = \"Your_VIN_here\";\n\n // POST /api/1/vehicles/{vehicle_tag}/wake_up\n let query = \"/wake_up\";\n\n let url = base_url + vin + query;\n\n // Configure the msg object for the HTTP request\n msg.method = \"POST\";\n msg.url = url;\n msg.headers = {\n 'Authorization': \"Bearer \" + token,\n 'Content-Type': 'application/json'\n };\n\n return msg;\n} else {\n return null;\n}",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 520,
"y": 240,
"wires": [
[
"454d77bb2ab5f4db"
]
]
},
{
"id": "454d77bb2ab5f4db",
"type": "http request",
"z": "e7594237b03366b2",
"name": "HTTP Request",
"method": "use",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "91a33722c228e6f1",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 740,
"y": 240,
"wires": [
[
"66d8774d0bb5a579"
]
]
},
{
"id": "66d8774d0bb5a579",
"type": "debug",
"z": "e7594237b03366b2",
"name": "debug 20",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 960,
"y": 240,
"wires": []
},
{
"id": "91a33722c228e6f1",
"type": "tls-config",
"name": "",
"cert": "",
"key": "",
"ca": "",
"certname": "",
"keyname": "",
"caname": "",
"servername": "",
"verifyservercert": true,
"alpnprotocol": ""
}
]
Great, many thanks ! The only thing for me that’s missing is how to wake up the car when sleeping. Any hint on this ?
Its in the API documentation. You need to do a HTTP POST with following content (in the syntax of my flows):
// Call: POST /api/1/vehicles/{vehicle_tag}/wake_up
let base_url = "https://api.teslemetry.com/api/1/vehicles/"
let token = flow.get ('accessToken')
let vin = flow.get ('VIN')
let scope = "/wake_up"
let query = ""
let url = base_url + vin + scope + query
msg.url = url
msg.bearerToken = flow.get('bearerToken')
return msg;
Answering my own question... Here's a sample flow for Start Charge, Stop Charge and Set Charging Amps to 5 -
[ { "id": "ea0ef801d947afae", "type": "function", "z": "f18596704a26bc97", "name": "Charge Stop", "func": "let base_url = \"https://api.teslemetry.com/api/1/vehicles/\";\nlet token = \"Your_Teslemetry_Token_here\";\nlet vin = \"Your_VIN_here\";\n\n// POST /api/1/vehicles/{vehicle_tag}/vehicle_data\nlet scope = \"/command\";\nlet query = \"/charge_stop\";\n\nlet url = base_url + vin + scope + query;\n\n// Configure the msg object for the HTTP request\nmsg.method = \"POST\";\nmsg.url = url;\nmsg.headers = {\n 'Authorization': \"Bearer \" + token,\n 'Content-Type': 'application/json'\n};\n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 410, "y": 500, "wires": [ [ "e00e92c60aa1e6b6" ] ] }, { "id": "84e52d1abe17ad5a", "type": "inject", "z": "f18596704a26bc97", "name": "", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 240, "y": 500, "wires": [ [ "ea0ef801d947afae" ] ] }, { "id": "e00e92c60aa1e6b6", "type": "http request", "z": "f18596704a26bc97", "name": "Teslemetry POST", "method": "use", "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "91a33722c228e6f1", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [], "x": 670, "y": 500, "wires": [ [ "322dce8059e166de" ] ] }, { "id": "322dce8059e166de", "type": "debug", "z": "f18596704a26bc97", "name": "debug 20", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 860, "y": 500, "wires": [] }, { "id": "b8738ea936a56634", "type": "function", "z": "f18596704a26bc97", "name": "Charge Start", "func": "let base_url = \"https://api.teslemetry.com/api/1/vehicles/\";\nlet token = \"Your_Teslemetry_Token_here\";\nlet vin = \"Your_VIN_here\";\n\n// POST /api/1/vehicles/{vehicle_tag}/vehicle_data\nlet scope = \"/command\";\nlet query = \"/charge_start\";\n\nlet url = base_url + vin + scope + query;\n\n// Configure the msg object for the HTTP request\nmsg.method = \"POST\";\nmsg.url = url;\nmsg.headers = {\n 'Authorization': \"Bearer \" + token,\n 'Content-Type': 'application/json'\n};\n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 410, "y": 440, "wires": [ [ "febbe529f8d92091" ] ] }, { "id": "0b31a6e235d16557", "type": "inject", "z": "f18596704a26bc97", "name": "", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 240, "y": 440, "wires": [ [ "b8738ea936a56634" ] ] }, { "id": "febbe529f8d92091", "type": "http request", "z": "f18596704a26bc97", "name": "Teslemetry POST", "method": "use", "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "91a33722c228e6f1", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [], "x": 670, "y": 440, "wires": [ [ "7bd53abd0b45ca30" ] ] }, { "id": "7bd53abd0b45ca30", "type": "debug", "z": "f18596704a26bc97", "name": "debug 21", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 860, "y": 440, "wires": [] }, { "id": "bdcd206cecb33a1e", "type": "function", "z": "f18596704a26bc97", "name": "Set Charging Amps 5", "func": "let base_url = \"https://api.teslemetry.com/api/1/vehicles/\";\nlet token = \"Your_Teslemetry_Token_here\";\nlet vin = \"Your_VIN_here\";\n\n// POST /api/1/vehicles/{vehicle_tag}/vehicle_data\nlet scope = \"/command\";\nlet query = \"/set_charging_amps\";\n\nlet url = base_url + vin + scope + query;\n\n// Configure the msg object for the HTTP request\nmsg.method = \"POST\";\nmsg.url = url;\nmsg.headers = {\n 'Authorization': \"Bearer \" + token,\n 'Content-Type': 'application/json'\n};\n\nmsg.payload = {\"charging_amps\": \"5\"}; \n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 440, "y": 560, "wires": [ [ "9c11f1d5c1c00143" ] ] }, { "id": "55f10e8fd2475f49", "type": "inject", "z": "f18596704a26bc97", "name": "", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 240, "y": 560, "wires": [ [ "bdcd206cecb33a1e" ] ] }, { "id": "9c11f1d5c1c00143", "type": "http request", "z": "f18596704a26bc97", "name": "Teslemetry POST", "method": "use", "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "91a33722c228e6f1", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [], "x": 670, "y": 560, "wires": [ [ "d101e512cbe59c5a" ] ] }, { "id": "d101e512cbe59c5a", "type": "debug", "z": "f18596704a26bc97", "name": "debug 22", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 860, "y": 560, "wires": [] }, { "id": "91a33722c228e6f1", "type": "tls-config", "name": "", "cert": "", "key": "", "ca": "", "certname": "", "keyname": "", "caname": "", "servername": "", "verifyservercert": true, "alpnprotocol": "" } ]
Sorry, but this seems not to work for me. I get following error: "..." 9.6.2024, 22:52:35node: debug 21 msg.payload : Object object response: null error: "invalid_response" error_description: "Command proxy response not json" "..."
Any hint?
If someone is interested, I developed a tiny HTTP API to make BLE request to my Tesla :
https://github.com/Jeoffreybauvin/tesla-http-api-over-ble
Basically, you'll need a bluetooth dongle, and your Tesla in range. I did it last night, so, it's pretty fresh :D.
Answering my own question... Here's a sample flow for Start Charge, Stop Charge and Set Charging Amps to 5 -
[ { "id": "ea0ef801d947afae", "type": "function", "z": "f18596704a26bc97", "name": "Charge Stop", "func": "let base_url = \"https://api.teslemetry.com/api/1/vehicles/\";\nlet token = \"Your_Teslemetry_Token_here\";\nlet vin = \"Your_VIN_here\";\n\n// POST /api/1/vehicles/{vehicle_tag}/vehicle_data\nlet scope = \"/command\";\nlet query = \"/charge_stop\";\n\nlet url = base_url + vin + scope + query;\n\n// Configure the msg object for the HTTP request\nmsg.method = \"POST\";\nmsg.url = url;\nmsg.headers = {\n 'Authorization': \"Bearer \" + token,\n 'Content-Type': 'application/json'\n};\n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 410, "y": 500, "wires": [ [ "e00e92c60aa1e6b6" ] ] }, { "id": "84e52d1abe17ad5a", "type": "inject", "z": "f18596704a26bc97", "name": "", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 240, "y": 500, "wires": [ [ "ea0ef801d947afae" ] ] }, { "id": "e00e92c60aa1e6b6", "type": "http request", "z": "f18596704a26bc97", "name": "Teslemetry POST", "method": "use", "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "91a33722c228e6f1", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [], "x": 670, "y": 500, "wires": [ [ "322dce8059e166de" ] ] }, { "id": "322dce8059e166de", "type": "debug", "z": "f18596704a26bc97", "name": "debug 20", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 860, "y": 500, "wires": [] }, { "id": "b8738ea936a56634", "type": "function", "z": "f18596704a26bc97", "name": "Charge Start", "func": "let base_url = \"https://api.teslemetry.com/api/1/vehicles/\";\nlet token = \"Your_Teslemetry_Token_here\";\nlet vin = \"Your_VIN_here\";\n\n// POST /api/1/vehicles/{vehicle_tag}/vehicle_data\nlet scope = \"/command\";\nlet query = \"/charge_start\";\n\nlet url = base_url + vin + scope + query;\n\n// Configure the msg object for the HTTP request\nmsg.method = \"POST\";\nmsg.url = url;\nmsg.headers = {\n 'Authorization': \"Bearer \" + token,\n 'Content-Type': 'application/json'\n};\n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 410, "y": 440, "wires": [ [ "febbe529f8d92091" ] ] }, { "id": "0b31a6e235d16557", "type": "inject", "z": "f18596704a26bc97", "name": "", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 240, "y": 440, "wires": [ [ "b8738ea936a56634" ] ] }, { "id": "febbe529f8d92091", "type": "http request", "z": "f18596704a26bc97", "name": "Teslemetry POST", "method": "use", "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "91a33722c228e6f1", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [], "x": 670, "y": 440, "wires": [ [ "7bd53abd0b45ca30" ] ] }, { "id": "7bd53abd0b45ca30", "type": "debug", "z": "f18596704a26bc97", "name": "debug 21", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 860, "y": 440, "wires": [] }, { "id": "bdcd206cecb33a1e", "type": "function", "z": "f18596704a26bc97", "name": "Set Charging Amps 5", "func": "let base_url = \"https://api.teslemetry.com/api/1/vehicles/\";\nlet token = \"Your_Teslemetry_Token_here\";\nlet vin = \"Your_VIN_here\";\n\n// POST /api/1/vehicles/{vehicle_tag}/vehicle_data\nlet scope = \"/command\";\nlet query = \"/set_charging_amps\";\n\nlet url = base_url + vin + scope + query;\n\n// Configure the msg object for the HTTP request\nmsg.method = \"POST\";\nmsg.url = url;\nmsg.headers = {\n 'Authorization': \"Bearer \" + token,\n 'Content-Type': 'application/json'\n};\n\nmsg.payload = {\"charging_amps\": \"5\"}; \n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 440, "y": 560, "wires": [ [ "9c11f1d5c1c00143" ] ] }, { "id": "55f10e8fd2475f49", "type": "inject", "z": "f18596704a26bc97", "name": "", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 240, "y": 560, "wires": [ [ "bdcd206cecb33a1e" ] ] }, { "id": "9c11f1d5c1c00143", "type": "http request", "z": "f18596704a26bc97", "name": "Teslemetry POST", "method": "use", "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "91a33722c228e6f1", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [], "x": 670, "y": 560, "wires": [ [ "d101e512cbe59c5a" ] ] }, { "id": "d101e512cbe59c5a", "type": "debug", "z": "f18596704a26bc97", "name": "debug 22", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 860, "y": 560, "wires": [] }, { "id": "91a33722c228e6f1", "type": "tls-config", "name": "", "cert": "", "key": "", "ca": "", "certname": "", "keyname": "", "caname": "", "servername": "", "verifyservercert": true, "alpnprotocol": "" } ]
Sorry, but this seems not to work for me. I get following error: "..." 9.6.2024, 22:52:35node: debug 21 msg.payload : Object object response: null error: "invalid_response" error_description: "Command proxy response not json" "..."
Any hint?
Can no one help on this issue? Reading the car data does work, but sending a command always results in the error above. Since the car is a leased company car my Access rights are "Driver, not "Owner". Maybe that makes a difference?
The short answer is, I don't know. Some things to check -
Have you linked the Virtual Key as pictured?
Your suspicion sounds correct though. Here's an excerpt out of the Teslemetry documentation under Topics / Access Type -
When a vehicle is shared by the OWNER to another account, you get DRIVER access. This is also common when the vehicle has been leased in European countries and the leasing company has retained OWNER permissions. Unfortunately with the DRIVER permission you are unable to install the virtual key or configure Fleet Telemetry. Most of the Fleet API will still work except for commands, which depends on your vehicles Command Signing requirement. To fix this you will need to ask the owner to add the Virtual Key.
The short answer is, I don't know. Some things to check -
Have you linked the Virtual Key as pictured?
Your suspicion sounds correct though. Here's an excerpt out of the Teslemetry documentation under Topics / Access Type -
When a vehicle is shared by the OWNER to another account, you get DRIVER access. This is also common when the vehicle has been leased in European countries and the leasing company has retained OWNER permissions. Unfortunately with the DRIVER permission you are unable to install the virtual key or configure Fleet Telemetry. Most of the Fleet API will still work except for commands, which depends on your vehicles Command Signing requirement. To fix this you will need to ask the owner to add the Virtual Key.
Thank you ChutneyMary! I'm not able to setup a virtual key and I'm pretty sure also the leasing company won't do it for me. If it's true that even such "simple" commands like start charging are not supported without a virtual key, I'm in big trouble :( Since "Command Sign:REQUIRED" is displayed in the teslemetry console, I assume that's true :(
Does someone know which commands need a signing ? A list would be very helpful.
"..." Unfortunately with the DRIVER permission you are unable to install the virtual key or configure Fleet Telemetry. Most of the Fleet API will still work except for commands, which depends on your vehicles Command Signing requirement. To fix this you will need to ask the owner to add the Virtual Key. "..."
Read the Teslemetry documentation - https://teslemetry.com/docs/topics/commandsigning
While this lists all the commands that do not support signing, I can only assume all the rest do require it.
I suggest you investigate the post a few lines above by @Jeoffreybauvin. The Tesla Bluetooth Low Energy API appears to support an off-line method of interacting with the vehicle. I haven't experimented with it yet, but perhaps @Jeoffreybauvin could clarify whether there's any cloud-based authentication occuring?
Indeed @ChutneyMary , no internet access is needed to interact with the vehicle over BLE. The new key paired with the vehicle is seen as a "new car key" for controlling the vehicle.
I'm a bit smarter now: In the past it was necessary to be the owner of the car to be able to setup a virtual key. Since this is no good solution for all leased cars, Tesla changed it and it is now possible to setup a virtual key a Driver. You need to have the key card and you have to be in the car to do so. See also here:
https://github.com/teslamotors/vehicle-command/issues/45
In car main menu->locks teslemetry is now displayed as Fleet Key, which seems to be fine. However, on Teslemetry console still Access Type:DRIVER Command Sign:REQUIRED is displayed and the Node Red flow is still not working. Maybe Teslemetry did not fully implement the latest changes? Could be true since their documentation does also not mention them...
Hopefully I will find the last parts of this puzzle ;)
Hi, I have copied
Answering my own question... Here's a sample flow for Start Charge, Stop Charge and Set Charging Amps to 5 -
[ { "id": "ea0ef801d947afae", "type": "function", "z": "f18596704a26bc97", "name": "Charge Stop", "func": "let base_url = \"https://api.teslemetry.com/api/1/vehicles/\";\nlet token = \"Your_Teslemetry_Token_here\";\nlet vin = \"Your_VIN_here\";\n\n// POST /api/1/vehicles/{vehicle_tag}/vehicle_data\nlet scope = \"/command\";\nlet query = \"/charge_stop\";\n\nlet url = base_url + vin + scope + query;\n\n// Configure the msg object for the HTTP request\nmsg.method = \"POST\";\nmsg.url = url;\nmsg.headers = {\n 'Authorization': \"Bearer \" + token,\n 'Content-Type': 'application/json'\n};\n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 410, "y": 500, "wires": [ [ "e00e92c60aa1e6b6" ] ] }, { "id": "84e52d1abe17ad5a", "type": "inject", "z": "f18596704a26bc97", "name": "", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 240, "y": 500, "wires": [ [ "ea0ef801d947afae" ] ] }, { "id": "e00e92c60aa1e6b6", "type": "http request", "z": "f18596704a26bc97", "name": "Teslemetry POST", "method": "use", "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "91a33722c228e6f1", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [], "x": 670, "y": 500, "wires": [ [ "322dce8059e166de" ] ] }, { "id": "322dce8059e166de", "type": "debug", "z": "f18596704a26bc97", "name": "debug 20", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 860, "y": 500, "wires": [] }, { "id": "b8738ea936a56634", "type": "function", "z": "f18596704a26bc97", "name": "Charge Start", "func": "let base_url = \"https://api.teslemetry.com/api/1/vehicles/\";\nlet token = \"Your_Teslemetry_Token_here\";\nlet vin = \"Your_VIN_here\";\n\n// POST /api/1/vehicles/{vehicle_tag}/vehicle_data\nlet scope = \"/command\";\nlet query = \"/charge_start\";\n\nlet url = base_url + vin + scope + query;\n\n// Configure the msg object for the HTTP request\nmsg.method = \"POST\";\nmsg.url = url;\nmsg.headers = {\n 'Authorization': \"Bearer \" + token,\n 'Content-Type': 'application/json'\n};\n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 410, "y": 440, "wires": [ [ "febbe529f8d92091" ] ] }, { "id": "0b31a6e235d16557", "type": "inject", "z": "f18596704a26bc97", "name": "", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 240, "y": 440, "wires": [ [ "b8738ea936a56634" ] ] }, { "id": "febbe529f8d92091", "type": "http request", "z": "f18596704a26bc97", "name": "Teslemetry POST", "method": "use", "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "91a33722c228e6f1", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [], "x": 670, "y": 440, "wires": [ [ "7bd53abd0b45ca30" ] ] }, { "id": "7bd53abd0b45ca30", "type": "debug", "z": "f18596704a26bc97", "name": "debug 21", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 860, "y": 440, "wires": [] }, { "id": "bdcd206cecb33a1e", "type": "function", "z": "f18596704a26bc97", "name": "Set Charging Amps 5", "func": "let base_url = \"https://api.teslemetry.com/api/1/vehicles/\";\nlet token = \"Your_Teslemetry_Token_here\";\nlet vin = \"Your_VIN_here\";\n\n// POST /api/1/vehicles/{vehicle_tag}/vehicle_data\nlet scope = \"/command\";\nlet query = \"/set_charging_amps\";\n\nlet url = base_url + vin + scope + query;\n\n// Configure the msg object for the HTTP request\nmsg.method = \"POST\";\nmsg.url = url;\nmsg.headers = {\n 'Authorization': \"Bearer \" + token,\n 'Content-Type': 'application/json'\n};\n\nmsg.payload = {\"charging_amps\": \"5\"}; \n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 440, "y": 560, "wires": [ [ "9c11f1d5c1c00143" ] ] }, { "id": "55f10e8fd2475f49", "type": "inject", "z": "f18596704a26bc97", "name": "", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 240, "y": 560, "wires": [ [ "bdcd206cecb33a1e" ] ] }, { "id": "9c11f1d5c1c00143", "type": "http request", "z": "f18596704a26bc97", "name": "Teslemetry POST", "method": "use", "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "91a33722c228e6f1", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [], "x": 670, "y": 560, "wires": [ [ "d101e512cbe59c5a" ] ] }, { "id": "d101e512cbe59c5a", "type": "debug", "z": "f18596704a26bc97", "name": "debug 22", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 860, "y": 560, "wires": [] }, { "id": "91a33722c228e6f1", "type": "tls-config", "name": "", "cert": "", "key": "", "ca": "", "certname": "", "keyname": "", "caname": "", "servername": "", "verifyservercert": true, "alpnprotocol": "" } ]
hi, this is exactly what I was looking to do... unfortunately any attempt to make an API call ends with a message "invalid token" as shown below. I got the token from iOS app "Auth for Tesla" - tried Both listed on the app, no joy :-(((
{"status":401,"response":null,"error":"invalid_token","service":"auth"}
my flows are identical, imported from yours except for I have the token and vin in flow variables.
any idea what am I doing wrong? any advice much appreciated!
I got the token from iOS app "Auth for Tesla"
It won't work with the iOS app "Auth for Tesla". I think you've missed a major component required in the flow. Read a bit further back in the thread for more info. The Token comes from a new service provided by a website called Teslemetry -
I got the token from iOS app "Auth for Tesla"
It won't work with the iOS app "Auth for Tesla". I think you've missed a major component required in the flow. Read a bit further back in the thread for more info. The Token comes from a new service provided by a website called Teslemetry -
thanks! :-) still need to figure out why I get "invalid_respose" while trying to set the charging amps but I at least manage to get some info from my Tesla having the account setup correctly.
I got the token from iOS app "Auth for Tesla"
It won't work with the iOS app "Auth for Tesla". I think you've missed a major component required in the flow. Read a bit further back in the thread for more info. The Token comes from a new service provided by a website called Teslemetry - https://teslemetry.com/
thanks! :-) still need to figure out why I get "invalid_respose" while trying to set the charging amps but I at least manage to get some info from my Tesla having the account setup correctly.
Is your car a leased one? If yes and your Access Type ist "just" Driver and not owner, you have the same poblem as I have. See some post before...
I got the token from iOS app "Auth for Tesla"
It won't work with the iOS app "Auth for Tesla". I think you've missed a major component required in the flow. Read a bit further back in the thread for more info. The Token comes from a new service provided by a website called Teslemetry - https://teslemetry.com/
thanks! :-) still need to figure out why I get "invalid_respose" while trying to set the charging amps but I at least manage to get some info from my Tesla having the account setup correctly.
Is your car a leased one? If yes and your Access Type ist "just" Driver and not owner, you have the same poblem as I have. See some post before...
I am the owner so it won't be the case; I believe it has something to do with the proxy setting -- no understanding here but it feels like it has something to do with the following.
https://developer.tesla.com/docs/fleet-api#charge_start
Newest vehicles require Tesla Vehicle Command protocol (see details).
I do not undestand what's involved but my Model 3 is 2023 version
Interesting! Since I also get the "invalid response" error, maybe it's not because of the Access Type.
Are you able to read the status of the car (see flow from Lineflyer above)? I can read the status, but not send commands
Same thing here. Its the SDK solvee by usimg a proxy. I am trying HA now it may work
On Mon 17. 6. 2024 at 8:08, Underground56 @.***> wrote:
Interesting! Since I also get the "invalid response" error, maybe it's not because of the Access Type.
Are you able to read the status of the car (see flow from Lineflyer above)? I can read the status, but not send commands
— Reply to this email directly, view it on GitHub https://github.com/onokje/node-red-contrib-tesla/issues/67#issuecomment-2172362757, or unsubscribe https://github.com/notifications/unsubscribe-auth/A44RIBHL4DMXP3QJ2UTN4ZDZHZ4O7AVCNFSM6AAAAAA6BGRZ7SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZSGM3DENZVG4 . You are receiving this because you commented.Message ID: @.***>
Hello @Jeoffreybauvin. I've dropped a question over in your github repository in the issues section. Can you please clarify the device and/or build environment you're running the Tesla BLE interface on? I'm not having much success on a Raspberry Pi Zero W (and first time user with Docker).
Same thing here. Its the SDK solvee by usimg a proxy. I am trying HA now it may work … On Mon 17. 6. 2024 at 8:08, Underground56 @.> wrote: Interesting! Since I also get the "invalid response" error, maybe it's not because of the Access Type. Are you able to read the status of the car (see flow from Lineflyer above)? I can read the status, but not send commands — Reply to this email directly, view it on GitHub <#67 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A44RIBHL4DMXP3QJ2UTN4ZDZHZ4O7AVCNFSM6AAAAAA6BGRZ7SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZSGM3DENZVG4 . You are receiving this because you commented.Message ID: @.>
Were you able to solve this problem? I'm still hanging on this :( Teslemetry console also still tells me Access Type: DRIVER Command Sign: REQUIRED
However, in the car the virtual key seems to be installed correctly:
Very much appreciate every help...
I got it working on Home Assistant, can see all data, control the vehicle as needed.
On 26. 6. 2024, at 11:42, Underground56 @.***> wrote:
Same thing here. Its the SDK solvee by usimg a proxy. I am trying HA now it may work … <x-msg://25/#> On Mon 17. 6. 2024 at 8:08, Underground56 @.> wrote: Interesting! Since I also get the "invalid response" error, maybe it's not because of the Access Type. Are you able to read the status of the car (see flow from Lineflyer above)? I can read the status, but not send commands — Reply to this email directly, view it on GitHub <#67 (comment) https://github.com/onokje/node-red-contrib-tesla/issues/67#issuecomment-2172362757>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A44RIBHL4DMXP3QJ2UTN4ZDZHZ4O7AVCNFSM6AAAAAA6BGRZ7SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZSGM3DENZVG4 . You are receiving this because you commented.Message ID: @.>
Were you able to solve this problem? I'm still hanging on this :( Teslemetry console also still tells me Access Type: DRIVER Command Sign: REQUIRED
However, in the car the virtual key seems to be installed correctly: teslemetry.jpg (view on web) https://github.com/onokje/node-red-contrib-tesla/assets/172016531/9fe6ff3d-7a3b-45f2-81bb-7999d0a51e16 Very much appreciate every help...
— Reply to this email directly, view it on GitHub https://github.com/onokje/node-red-contrib-tesla/issues/67#issuecomment-2191263051, or unsubscribe https://github.com/notifications/unsubscribe-auth/A44RIBCU4S774FS3SQSNB43ZJKEHLAVCNFSM6AAAAAA6BGRZ7SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJRGI3DGMBVGE. You are receiving this because you commented.
Same here: I got everything running (reading and writing values) with Home Assistent and Teslemetry now, so the problem I had has to do with the Node Red Integration. To be honest, I don't want to rebuild my complete logic in HA since I'm used to Node Red and thing the capabilities are much better.
Does anyone know if/when this problem can be fixed in Node Red? Also, I'm wondering why some guys are doing ok in Node red and some don't with the same Code?
I use HA to communicate via API but all the automation is done in nodered which is a part of HA package anyway. Both handy to be a part of home”package”Sent from my iPhoneOn 29. 6. 2024, at 21:29, Underground56 @.***> wrote: Same here: I got everything running with Home Assistent, so the problem has to do with the Node Red Integration. To be honest, I don't want to rebuild my complete logic in HA since I'm used to Node Red and thing the capabilities are much better. Does anyone know if/when this problem can be fixed in Node Red? Also, I'm wondering why some guys are doing ok in Node red and some don't with the same Code?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
If someone is interested, I developed a tiny HTTP API to make BLE request to my Tesla :
https://github.com/Jeoffreybauvin/tesla-http-api-over-ble
Basically, you'll need a bluetooth dongle, and your Tesla in range. I did it last night, so, it's pretty fresh :D.
There's also this repo for a BLE Proxy: https://github.com/wimaha/TeslaBleHttpProxy
I've been using it for a week now, having migrated off first Telsa API to Tessie (paid service, though) and now off Tessie to local, no cloud involved. I've found I also need to use the Tesla wall connector API, but between that and the BLE proxy (and Node Red, of course), everything works as needed.
https://developer.tesla.com/docs/fleet-api#2023-10-09-rest-api-vehicle-commands-endpoint-deprecation-warning
Are there plans to revise node-red-contrib-tesla? Or do we have to assume that node-red-contrib-tesla will stop working at the beginning of 2024?