Control charging for Tesla

The solution was in the mailbox today: M5Stack ESP32 Core Ink
It offers:

  • acceptable casing
  • low power
  • ESP32 (I know how to program this with the Arduino IDE)
  • Magnet (makes it easy to mount it at the wall)
  • readable screen
  • a wheel for up/down/push on the right side (makes the UI easy)

So I'm going to migrate my code from the ESP32 OLED to the M5Stack device.
In parallel I have to adapt some of the node-red flows, but this is the easy part.
This might take another month. We'll see. Stay tuned.

Good day
I would like to ask if it would still be possible to insert flow data here.
I plan to follow the charging of my vw e-golf like this. If that doesn't matter I would use your pattern.
Thank you, Zoul

Hello Zoul
From the posts I make you can use whatever fits your needs.

I stopped working on that project since my wife uses the car now very often to go to work. This means it needs to charge during the night when she is back with the car. Since the sun is down anyway, there is not a lot I can do to make the charging more cost effective.

In addition Tesla changed the authorization in the API and the node-red-contrib-tesla node did not work anymore.
This is fixed and I tested it a few days ago.

It is possible now to set not only the charging limit, but also the charging power in Ampere. That way I could almost exactly use the excess power generated by the solar panels. But since the car is usually not here when the sun shines, this remains just a nice programming exercise.
And for exercise only, I do not have the motivation currently. This might change. So stay tuned.

Thank you for the quick reply.
It would be more convenient for me if you still have access to the same flow and you could export and paste it here.
Thank you, Zoul

https://nodered.org/docs/user-guide/editor/workspace/import-export

OK, now I understand what you wanted. Here is the current state of my work.
I did work at some stage, but I did not get it to work as I wanted. See my note above.
This is part 1:

[{"id":"de192bd0.332e","type":"ui_button","z":"4e139d26.c717a4","name":"95%","group":"63da9348.d1c924","order":2,"width":0,"height":0,"passthru":false,"label":"95%","tooltip":"","color":"","bgcolor":"{{background}}","icon":"","payload":"95","payloadType":"num","topic":"data/tesla/chargeLevel","topicType":"str","x":690,"y":280,"wires":[["14b6e44a.f3ee3c"]]},{"id":"6c57ae0d.8bc56","type":"ui_button","z":"4e139d26.c717a4","name":"90%","group":"63da9348.d1c924","order":1,"width":0,"height":0,"passthru":false,"label":"90%","tooltip":"","color":"","bgcolor":"{{background}}","icon":"","payload":"90","payloadType":"num","topic":"data/tesla/chargeLevel","topicType":"str","x":690,"y":240,"wires":[["14b6e44a.f3ee3c"]]},{"id":"2b4617ef.a625c8","type":"ui_button","z":"4e139d26.c717a4","name":"100%","group":"63da9348.d1c924","order":3,"width":0,"height":0,"passthru":false,"label":"100%","tooltip":"","color":"","bgcolor":"{{background}}","icon":"","payload":"100","payloadType":"num","topic":"data/tesla/chargeLevel","topicType":"str","x":690,"y":320,"wires":[["14b6e44a.f3ee3c"]]},{"id":"dc88c03c.cdeb6","type":"ui_button","z":"4e139d26.c717a4","name":"cheap","group":"68636887.0bf5a8","order":2,"width":0,"height":0,"passthru":false,"label":"cheap","tooltip":"","color":"","bgcolor":"{{background}}","icon":"","payload":"cheap","payloadType":"str","topic":"data/tesla/chargeGoal","topicType":"str","x":690,"y":400,"wires":[["a6bde8a.ee4c618"]]},{"id":"45e6bcfd.0dedfc","type":"ui_button","z":"4e139d26.c717a4","name":"fast","group":"68636887.0bf5a8","order":3,"width":0,"height":0,"passthru":false,"label":"fast","tooltip":"","color":"","bgcolor":"{{background}}","icon":"","payload":"fast","payloadType":"str","topic":"data/tesla/chargeGoal","topicType":"str","x":690,"y":440,"wires":[["a6bde8a.ee4c618"]]},{"id":"a6bde8a.ee4c618","type":"link out","z":"4e139d26.c717a4","name":"","links":["907c80c1.54e128"],"x":835,"y":400,"wires":[]},{"id":"5e82fa3.c67c904","type":"comment","z":"4e139d26.c717a4","name":"set & display Charge Goal","info":"","x":130,"y":360,"wires":[]},{"id":"22a8fe90.8269da","type":"mqtt in","z":"4e139d26.c717a4","name":"chargeLevel","topic":"data/tesla/chargeLevel","qos":"2","datatype":"auto","broker":"478a3533.38d8ac","nl":false,"rap":true,"rh":0,"inputs":0,"x":130,"y":280,"wires":[["3c9e726b.979d8e"]]},{"id":"14b6e44a.f3ee3c","type":"link out","z":"4e139d26.c717a4","name":"","links":["907c80c1.54e128"],"x":835,"y":280,"wires":[]},{"id":"ea2d47c2.2f1d3","type":"comment","z":"4e139d26.c717a4","name":"Set charge level, show feedback on button","info":"","x":190,"y":240,"wires":[]},{"id":"acd62160.78a53","type":"ui_button","z":"4e139d26.c717a4","name":"charging [kw]","group":"a778a4f8.f945f8","order":4,"width":0,"height":0,"passthru":false,"label":"{{payload}}","tooltip":"","color":"","bgcolor":" {{background}}","icon":"","payload":"100","payloadType":"num","topic":"data/Tesla/charge-config","topicType":"str","x":720,"y":820,"wires":[[]]},{"id":"8565cabe.0e8de8","type":"ui_button","z":"4e139d26.c717a4","name":"batteryLevel","group":"a778a4f8.f945f8","order":2,"width":0,"height":0,"passthru":false,"label":"Battery Level: {{payload}}%","tooltip":"","color":"","bgcolor":" {{background}}","icon":"","payload":"100","payloadType":"num","topic":"data/tesla/batteryLevel","topicType":"str","x":710,"y":620,"wires":[[]]},{"id":"3c9e726b.979d8e","type":"function","z":"4e139d26.c717a4","name":"bg color","func":"var msg1 = {};\nvar msg2 = {};\nvar msg3 = {};\n\nmsg1.topic = \"data/tesla/chargeLevelFeedback\";\nmsg2.topic = \"data/tesla/chargeLevelFeedback\";\nmsg3.topic = \"data/tesla/chargeLevelFeedback\";\n\nswitch (msg.payload) {\n    case \"90\" :\n        msg1.background = \"#87A980\";\n        msg2.background = \"#3FADB5\";\n        msg3.background = \"#3FADB5\";\n        break;\n    case \"95\" :\n        msg1.background = \"#3FADB5\";\n        msg2.background = \"#87A980\";\n        msg3.background = \"#3FADB5\";\n        break;\n    case \"100\" :\n        msg1.background = \"#3FADB5\";\n        msg2.background = \"#3FADB5\";\n        msg3.background = \"#87A980\";\n        break;\n}\nreturn [msg1,msg2,msg3];","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":280,"wires":[["6c57ae0d.8bc56"],["de192bd0.332e"],["2b4617ef.a625c8"]]},{"id":"a153a136.ca2428","type":"mqtt in","z":"4e139d26.c717a4","name":"batteryLevel","topic":"data/tesla/batteryLevel","qos":"2","datatype":"auto","broker":"478a3533.38d8ac","nl":false,"rap":true,"rh":0,"inputs":0,"x":130,"y":620,"wires":[["90faccbb.8cb99"]]},{"id":"90faccbb.8cb99","type":"switch","z":"4e139d26.c717a4","name":"charged?","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"#:(storeInFile)::tesla.chargeLevel","vt":"global"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":320,"y":620,"wires":[["557a5481.28eeb4"],["8e014b54.1ff278"]]},{"id":"557a5481.28eeb4","type":"change","z":"4e139d26.c717a4","name":"charged","rules":[{"t":"set","p":"background","pt":"msg","to":"#3FADB5","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":600,"wires":[["8565cabe.0e8de8"]]},{"id":"8e014b54.1ff278","type":"change","z":"4e139d26.c717a4","name":"not yet","rules":[{"t":"set","p":"background","pt":"msg","to":"#87A980","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":640,"wires":[["8565cabe.0e8de8"]]},{"id":"9032a64e.def5a","type":"comment","z":"4e139d26.c717a4","name":"display battery level, using a button, show different background color if charged","info":"","x":310,"y":560,"wires":[]},{"id":"f50693da.cacb","type":"function","z":"4e139d26.c717a4","name":"bg color","func":"var msg1 = {};\nvar msg2 = {};\nvar msg3 = {};\n\nmsg1.topic = \"data/tesla/chargeGoalFeedback\";\nmsg2.topic = \"data/tesla/chargeGoalFeedback\";\nmsg3.topic = \"data/tesla/chargeGoalFeedback\";\n\nswitch (msg.payload) {\n    case \"solar\" :\n        msg1.background = \"#87A980\";\n        msg2.background = \"#3FADB5\";\n        msg3.background = \"#3FADB5\";\n        break;\n    case \"cheap\" :\n        msg1.background = \"#3FADB5\";\n        msg2.background = \"#87A980\";\n        msg3.background = \"#3FADB5\";\n        break;\n    case \"fast\" :\n        msg1.background = \"#3FADB5\";\n        msg2.background = \"#3FADB5\";\n        msg3.background = \"#87A980\";\n        break;\n    case \"stop\" :\n        msg1.background = \"#3FADB5\";\n        msg2.background = \"#3FADB5\";\n        msg3.background = \"#3FADB5\";\n        break;\n}\nreturn [msg1,msg2,msg3];","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":400,"wires":[["edc00f47.55f78"],["dc88c03c.cdeb6"],["45e6bcfd.0dedfc"]]},{"id":"f68fd811.79a308","type":"mqtt in","z":"4e139d26.c717a4","name":"chargeGoal","topic":"data/tesla/chargeGoal","qos":"2","datatype":"auto","broker":"478a3533.38d8ac","nl":false,"rap":true,"rh":0,"inputs":0,"x":130,"y":400,"wires":[["f50693da.cacb"]]},{"id":"4ffa64b.14e5c9c","type":"comment","z":"4e139d26.c717a4","name":"display charge state, similar to battery level","info":"","x":190,"y":780,"wires":[]},{"id":"3ae3f262.b5d886","type":"mqtt in","z":"4e139d26.c717a4","name":"chargeState","topic":"data/tesla/chargeState","qos":"2","datatype":"auto","broker":"478a3533.38d8ac","nl":false,"rap":true,"rh":0,"inputs":0,"x":130,"y":820,"wires":[["e8cc13f7.87493"]]},{"id":"e8cc13f7.87493","type":"switch","z":"4e139d26.c717a4","name":"charging?","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":330,"y":820,"wires":[["4fbb7098.cd952"],["2ae32679.d0f1ca"]]},{"id":"4fbb7098.cd952","type":"change","z":"4e139d26.c717a4","name":"yes","rules":[{"t":"set","p":"background","pt":"msg","to":"#87A980","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"charging","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":800,"wires":[["acd62160.78a53"]]},{"id":"2ae32679.d0f1ca","type":"change","z":"4e139d26.c717a4","name":"no","rules":[{"t":"set","p":"background","pt":"msg","to":"#3FADB5","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"stopped","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":840,"wires":[["acd62160.78a53"]]},{"id":"6eaac720.b68cb","type":"comment","z":"4e139d26.c717a4","name":"display battery charge limit","info":"","x":140,"y":680,"wires":[]},{"id":"9cee8d68.96e83","type":"mqtt in","z":"4e139d26.c717a4","name":"chargeLimit","topic":"data/tesla/chargeLimit","qos":"2","datatype":"auto","broker":"478a3533.38d8ac","nl":false,"rap":true,"rh":0,"inputs":0,"x":130,"y":720,"wires":[["455737be.000b2"]]},{"id":"455737be.000b2","type":"change","z":"4e139d26.c717a4","name":"bg color","rules":[{"t":"set","p":"background","pt":"msg","to":"#3FADB5","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":720,"wires":[["a48d22db.66cf5"]]},{"id":"a48d22db.66cf5","type":"ui_button","z":"4e139d26.c717a4","name":"chargeLimit","group":"a778a4f8.f945f8","order":1,"width":0,"height":0,"passthru":false,"label":"Charge Limit: {{payload}}%","tooltip":"","color":"","bgcolor":" {{background}}","icon":"","payload":"100","payloadType":"num","topic":"data/tesla/chargeLimit","topicType":"str","x":710,"y":720,"wires":[[]]},{"id":"8a06232c.8d7e08","type":"comment","z":"4e139d26.c717a4","name":"Initialize values","info":"","x":100,"y":20,"wires":[]},{"id":"edc00f47.55f78","type":"ui_button","z":"4e139d26.c717a4","name":"solar","group":"68636887.0bf5a8","order":1,"width":0,"height":0,"passthru":false,"label":"solar","tooltip":"","color":"","bgcolor":"{{background}}","icon":"","payload":"solar","payloadType":"str","topic":"data/tesla/chargeGoal","topicType":"str","x":690,"y":360,"wires":[["a6bde8a.ee4c618"]]},{"id":"de7503dd.578ec","type":"comment","z":"4e139d26.c717a4","name":"fetch PV forecast 1/h and fill array with 48h worth of estimates","info":"and store 12 hours as an array in global variable 'pv_estimates'.","x":250,"y":120,"wires":[]},{"id":"5472339.d14b14c","type":"config","z":"4e139d26.c717a4","name":"Solcast API","properties":[{"p":"APIkey","pt":"flow","to":"kr4xMBTh9cMrToNnYNs0yZkTMHsQ-h4J","tot":"str"},{"p":"ResourceID","pt":"flow","to":"1bcd-81cf-8823-ac4f","tot":"str"}],"active":true,"x":130,"y":60,"wires":[]},{"id":"6e20a51.b1db8dc","type":"config","z":"4e139d26.c717a4","name":"AEW Tariff","properties":[{"p":"#:(storeInFile)::dataStatus.grid.importTariff1","pt":"global","to":"21.89","tot":"num"},{"p":"#:(storeInFile)::dataStatus.grid.importTariff2","pt":"global","to":"16.75","tot":"num"},{"p":"#:(storeInFile)::dataStatus.grid.exportTariff1","pt":"global","to":"6.75","tot":"num"},{"p":"#:(storeInFile)::dataStatus.grid.exportTariff2","pt":"global","to":"5.4","tot":"num"}],"active":true,"x":330,"y":60,"wires":[]},{"id":"af1f50a5.152818","type":"inject","z":"4e139d26.c717a4","name":"@start","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":160,"wires":[["c0154659.c1cec"]]},{"id":"c0154659.c1cec","type":"function","z":"4e139d26.c717a4","name":"set tariff","func":"var tariffZone = [];\nvar i,j;\nfor (i=0; i<7*24; i++) {\n    tariffZone[i] = 2;        // initialize with low tariff\n}\nfor (i=0;i<5;i++) {\n    for (j=7;j<20;j++) {\n        tariffZone[24*i+j]=1;  // set high tariff hours on weekdays\n    }\n}\nfor (j=7;j<13;j++){\n    tariffZone[5*24+j]=1;     // set high tariff hours on Saturday\n}\nmsg.payload = tariffZone;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":160,"wires":[["b615f4ef.63f7a8"]]},{"id":"b615f4ef.63f7a8","type":"change","z":"4e139d26.c717a4","name":"store","rules":[{"t":"set","p":"#:(storeInFile)::dataStatus.grid.tariffZone","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":160,"wires":[[]]},{"id":"80d79fb.eb5e4e","type":"mqtt in","z":"4e139d26.c717a4","name":"chargeControl","topic":"data/tesla/chargeControl","qos":"2","datatype":"auto","broker":"478a3533.38d8ac","nl":false,"rap":true,"rh":0,"inputs":0,"x":130,"y":480,"wires":[["ed05c707.b9ac68"]]},{"id":"c6ae18da.8bf0b","type":"ui_button","z":"4e139d26.c717a4","name":"chargeControl","group":"68636887.0bf5a8","order":4,"width":0,"height":0,"passthru":false,"label":"{{payload}}","tooltip":"","color":"","bgcolor":" {{background}}","icon":"","payload":"pressed","payloadType":"str","topic":"data/tesla/chargeControl","topicType":"str","x":720,"y":480,"wires":[["2ec8e2e7.99155e"]]},{"id":"2ec8e2e7.99155e","type":"switch","z":"4e139d26.c717a4","name":"previous state?","property":"#:(storeInFile)::dataStatus.tesla.chargeControl","propertyType":"global","rules":[{"t":"eq","v":"enabled","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":940,"y":480,"wires":[["c321618d.affaf8"],["d999d2d8.47aec8"]]},{"id":"c321618d.affaf8","type":"change","z":"4e139d26.c717a4","name":"set disabled","rules":[{"t":"set","p":"payload","pt":"msg","to":"disabled","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1150,"y":460,"wires":[["ac6458b7.6be9d8"]]},{"id":"d999d2d8.47aec8","type":"change","z":"4e139d26.c717a4","name":"set enabled","rules":[{"t":"set","p":"payload","pt":"msg","to":"enabled","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1150,"y":500,"wires":[["ac6458b7.6be9d8"]]},{"id":"ac6458b7.6be9d8","type":"link out","z":"4e139d26.c717a4","name":"","links":["907c80c1.54e128"],"x":1295,"y":480,"wires":[]},{"id":"ed05c707.b9ac68","type":"switch","z":"4e139d26.c717a4","name":"enabled?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"enabled","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":320,"y":480,"wires":[["322724d3.cf8034"],["61c75851.1ff658"]]},{"id":"322724d3.cf8034","type":"change","z":"4e139d26.c717a4","name":"yes","rules":[{"t":"set","p":"background","pt":"msg","to":"#87A980","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"press to disable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":460,"wires":[["c6ae18da.8bf0b"]]},{"id":"61c75851.1ff658","type":"change","z":"4e139d26.c717a4","name":"no","rules":[{"t":"set","p":"background","pt":"msg","to":"#3FADB5","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"press to enable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":500,"wires":[["c6ae18da.8bf0b"]]},{"id":"63da9348.d1c924","type":"ui_group","name":"Charge Level","tab":"cc41f24f.2ab028","order":2,"disp":true,"width":"4","collapse":false},{"id":"68636887.0bf5a8","type":"ui_group","name":"Charge Goal","tab":"cc41f24f.2ab028","order":3,"disp":true,"width":"4","collapse":false},{"id":"478a3533.38d8ac","type":"mqtt-broker","name":"central1","broker":"central1.local","port":"1883","clientid":"","usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"a778a4f8.f945f8","type":"ui_group","name":"Charge State","tab":"cc41f24f.2ab028","order":4,"disp":true,"width":"4","collapse":false},{"id":"cc41f24f.2ab028","type":"ui_tab","name":"Tesla","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

And this is part 2:

[{"id":"44b73686.20b328","type":"function","z":"4e139d26.c717a4","name":"create request","func":"APIkey = flow.get('APIkey');\nvar auth = APIkey+':';\nmsg.ResourceID = flow.get('ressourceID');\nmsg.headers = {\n    \"Authorization\": 'Basic ' + new Buffer(auth).toString('base64')\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is started.\n\nflow.set('APIkey',\"kr4xMBTh9cMrToNnYNs0yZkTMHsQ-h4J\");\nflow.set('ressourceID',\"1bcd-81cf-8823-ac4f\");","finalize":"","libs":[],"x":340,"y":980,"wires":[["560ddd10.f28bfc","624210f6782e5609"]]},{"id":"be9ab89.9edd3c8","type":"inject","z":"4e139d26.c717a4","d":true,"name":"now","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":90,"y":1180,"wires":[["c3bc5a73.b7e838"]]},{"id":"560ddd10.f28bfc","type":"http request","z":"4e139d26.c717a4","name":"fetch solcast","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.solcast.com.au/rooftop_sites/{{{ResourceID}}}/forecasts?format=json","tls":"","persist":false,"proxy":"","authType":"","x":540,"y":980,"wires":[["decd550.b8ce6a8","c1c7663590e07e5a"]]},{"id":"decd550.b8ce6a8","type":"function","z":"4e139d26.c717a4","name":"extract 49h forecast values","func":"// fill array solCast with 49 hours worth of energy forecasts in kWh\n// Input: from solcast.com array with 30min forecast elements in kW\n// Output: array[0..48] with 60min forecast elements in kW (corresponds to produced kWh during that hour)\n\nvar solCastMsg = {};\nvar solCast=[];\nvar statusColour;\nvar statusCode = msg.statusCode;\n\nif (msg.statusCode == 200) {\n    statusColour = \"green\";\n    for (i=0; i<=48; i++) {\n        solCast[i] = (msg.payload.forecasts[2*i].pv_estimate + msg.payload.forecasts[2*i+1].pv_estimate)/2;\n    }\n    solCastMsg.solCast = solCast;\n    node.send(solCastMsg);\n} else {\n    statusColour = \"red\";\n}\nnode.status({fill:statusColour,shape:\"dot\",text:statusCode});\n\nreturn;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":980,"wires":[["47e84efa.a7094","b8e15b9c1693ad04","1cd2863e.55dfa2"]]},{"id":"518f9ab2.e6568c","type":"link out","z":"4e139d26.c717a4","name":"","links":["907c80c1.54e128"],"x":1195,"y":960,"wires":[]},{"id":"bc8b503c.d34fe8","type":"function","z":"4e139d26.c717a4","name":"set tariff48","func":"// fill an array with the tariff information for the next 48h\n\n//msg.payload contains a string \"weekday hour\"\nconst temp = msg.payload.split(' ');\n//node.warn(temp);\nconst weekday = parseInt(temp[0])-1;\n//node.warn(weekday);\nconst hour = parseInt(temp[1]);\n//node.warn(hour);\nvar baseTime = weekday * 24 + hour;\n//node.warn(baseTime);\n\nvar i;\nvar tariff48=[];\nfor (i=0;i<48;i++) {\n    if (baseTime + i > 167)  baseTime = 0;\n    tariff48[i] = msg.tariff[baseTime + i];\n}\nmsg.tariff48 = tariff48;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":1100,"wires":[["ab86107.aa9d27"]]},{"id":"cab3dc94.91a388","type":"moment","z":"4e139d26.c717a4","name":"weekday hour","topic":"","input":"time","inputType":"msg","inTz":"Europe/Zurich","adjAmount":0,"adjType":"days","adjDir":"add","format":"E H","locale":"en-GB","output":"payload","outputType":"msg","outTz":"Europe/Zurich","x":460,"y":1100,"wires":[["d2da9e67.4702d8"]]},{"id":"ab86107.aa9d27","type":"change","z":"4e139d26.c717a4","name":"store","rules":[{"t":"set","p":"#:(storeInFile)::dataStatus.grid.tariff48","pt":"global","to":"tariff48","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1030,"y":1100,"wires":[["bb1aaa50.966c7","c697d7ab.d7b858"]]},{"id":"d2da9e67.4702d8","type":"change","z":"4e139d26.c717a4","name":"get tariff","rules":[{"t":"set","p":"tariff","pt":"msg","to":"#:(storeInFile)::dataStatus.grid.tariffZone","tot":"global"},{"t":"set","p":"solCast","pt":"msg","to":"#:(storeInFile)::dataStatus.solar.solCast","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":1100,"wires":[["bc8b503c.d34fe8"]]},{"id":"bb1aaa50.966c7","type":"debug","z":"4e139d26.c717a4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":1100,"wires":[]},{"id":"47e84efa.a7094","type":"change","z":"4e139d26.c717a4","name":"-> data/solar/solCast","rules":[{"t":"set","p":"payload","pt":"msg","to":"solCast","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"data/solar/solCast","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1040,"y":960,"wires":[["518f9ab2.e6568c"]]},{"id":"4b6c9be7.3be0cc","type":"comment","z":"4e139d26.c717a4","name":"msg.* documentation","info":"at this stage the msg contains\nmsg.solCast with 48h solar energy forecast\nmsg.tariff48 with 48h of tariff zone information\nmsg.chargeState with Tesla battery data\nmsg.chargeLevel : the battery should be charged to this level\nmsg.chargeNeeded : difference between chargeLevel and actual batteryLevel in kWh\nmsg.chargeTime : time it takes to charge with 2 kW to the chargeLevel requested by the chargeGoal selected. If the value is 48 hours then there is a good chance, that the goal can't be reached.\nmsg.chargeAvailable : usually corresponds to chargeNeeded. It might be lower than that if two days are not enough to reach the desired level with the selected goal\nmsg.chargeNow : 1 to enable charging, 0 to stop it.","x":300,"y":1940,"wires":[]},{"id":"c697d7ab.d7b858","type":"tesla-api","z":"4e139d26.c717a4","teslaConfig":"cca88314.8bcf68","command":"chargeState","name":"getChargeState","x":280,"y":1260,"wires":[["9dd20cd8.39a0b","d9b6574b.b51ea8"]]},{"id":"8e92651a.d83678","type":"debug","z":"4e139d26.c717a4","name":"not chargeable","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":500,"y":1340,"wires":[]},{"id":"6724007f.4b733","type":"switch","z":"4e139d26.c717a4","name":"plugged in?","property":"payload.charging_state","propertyType":"msg","rules":[{"t":"eq","v":"Disconnected","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":270,"y":1400,"wires":[["8e92651a.d83678","dc59f574.d9aed"],["542838fd.c2a42"]]},{"id":"cfa0473.e578fb8","type":"change","z":"4e139d26.c717a4","name":"-> batteryLevel","rules":[{"t":"set","p":"payload","pt":"msg","to":"chargeState.battery_level","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"data/tesla/batteryLevel","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":1220,"wires":[["90b5900f.e9dd68"]]},{"id":"90b5900f.e9dd68","type":"link out","z":"4e139d26.c717a4","name":"","links":["907c80c1.54e128"],"x":895,"y":1260,"wires":[]},{"id":"4fb8a85e.6c33d","type":"change","z":"4e139d26.c717a4","name":"-> chargeState","rules":[{"t":"set","p":"payload","pt":"msg","to":"chargeState.charger_power","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"data/tesla/chargeState","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":1260,"wires":[["90b5900f.e9dd68"]]},{"id":"570ce501.d8c1c4","type":"change","z":"4e139d26.c717a4","name":"-> chargeLimit","rules":[{"t":"set","p":"payload","pt":"msg","to":"chargeState.charge_limit_soc","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"data/tesla/chargeLimit","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":1300,"wires":[["90b5900f.e9dd68"]]},{"id":"a53a73bc.53a5f","type":"switch","z":"4e139d26.c717a4","name":"charge needed?","property":"chargeState.battery_level","propertyType":"msg","rules":[{"t":"gte","v":"chargeLevel","vt":"msg"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":750,"y":1420,"wires":[["fe45fca9.dc1a58","c4553f26.900888"],["3c6f9bbf.4a6d4c"]]},{"id":"9dd20cd8.39a0b","type":"change","z":"4e139d26.c717a4","name":"msg.chargeState","rules":[{"t":"move","p":"payload","pt":"msg","to":"chargeState","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":1260,"wires":[["cfa0473.e578fb8","4fb8a85e.6c33d","570ce501.d8c1c4","6724007f.4b733"]]},{"id":"fe45fca9.dc1a58","type":"debug","z":"4e139d26.c717a4","name":"no charge needed","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1010,"y":1400,"wires":[]},{"id":"3c6f9bbf.4a6d4c","type":"function","z":"4e139d26.c717a4","name":"msg.chargeNeeded","func":"// msg.chargeLevel and msg.chargeState.battery_level ar in %\n// 3% correspond roughly to 2 kWh\n// msg.chargeNeeded is in kWh\n\nmsg.chargeNeeded = (msg.chargeLevel - msg.chargeState.battery_level) / 3 * 2;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":1580,"wires":[["b68345c3.7198b8","3c5f605d.3450b8"]]},{"id":"542838fd.c2a42","type":"change","z":"4e139d26.c717a4","name":"chargeLevel","rules":[{"t":"set","p":"chargeLevel","pt":"msg","to":"#:(storeInFile)::dataStatus.tesla.chargeLevel","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":1420,"wires":[["a53a73bc.53a5f"]]},{"id":"b68345c3.7198b8","type":"switch","z":"4e139d26.c717a4","name":"chargeGoal?","property":"#:(storeInFile)::dataStatus.tesla.chargeGoal","propertyType":"global","rules":[{"t":"eq","v":"solar","vt":"str"},{"t":"eq","v":"cheap","vt":"str"},{"t":"eq","v":"fast","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":4,"x":500,"y":1580,"wires":[["2934f72a.be205"],["6945cd83.0db554"],["54fc0948.ffc2f8"],[]]},{"id":"2934f72a.be205","type":"function","z":"4e139d26.c717a4","name":"msg.chargeTime (solar)","func":"// calculate needed charging time based on solar forecast\n// if more than 2.5 kWh are produced in the next hour,\n// then 2kWh are used to charge the car.\n\nvar chargeAvailable = 0;\nvar chargeTime = 0;\n\nwhile (chargeAvailable < msg.chargeNeeded){\n    if (msg.solCast[chargeTime] > 2.5) {\n        chargeAvailable += 2;\n    }\n    chargeTime++;\n    if (chargeTime >= 48) break;\n}\nif (msg.solCast[0]>2.5) {\n    msg.chargeNow = 1;\n} else {\n    msg.chargeNow = 0;\n}\n\nmsg.chargeAvailable = chargeAvailable;\nmsg.chargeTime = chargeTime;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":1540,"wires":[["b79ba3c5.a4c3b"]]},{"id":"6945cd83.0db554","type":"function","z":"4e139d26.c717a4","name":"msg.chargeTime (cheap)","func":"// calculate needed charging time based on solar forecast\n// if more than 2.5 kWh are produced in the next hour,\n// then 2kWh are used to charge the car.\n// If this is not the case, but the grid offers the power to a low tariff, then this is used instead\n\nvar chargeAvailable = 0;\nvar chargeTime = 0;\n\nwhile (chargeAvailable < msg.chargeNeeded){\n    if ((msg.solCast[chargeTime] > 2.5) || (msg.tariff48[chargeTime] == 2)) {\n        chargeAvailable += 2;\n    }\n    chargeTime++;\n    if (chargeTime >= 48) break;\n}\n\nif ((msg.solCast[0]>2.5) || (msg.tariff48[0] == 2)) {\n    msg.chargeNow = 1;\n} else {\n    msg.chargeNow = 0;\n}\n\nmsg.chargeAvailable = chargeAvailable;\nmsg.chargeTime = chargeTime;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":1580,"wires":[["b79ba3c5.a4c3b"]]},{"id":"54fc0948.ffc2f8","type":"function","z":"4e139d26.c717a4","name":"msg.chargeTime (fast)","func":"// charging starts immediately with 2 kW\n\nmsg.chargeAvailable = msg.chargeNeeded;\nmsg.chargeTime = parseInt(msg.chargeNeeded / 2 + 1);\nmsg.chargeNow = 1;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":1620,"wires":[["b79ba3c5.a4c3b"]]},{"id":"9769d5f5.d2ee1","type":"comment","z":"4e139d26.c717a4","name":"check every hour if charge is needed and act according settings","info":"","x":250,"y":1060,"wires":[]},{"id":"b79ba3c5.a4c3b","type":"change","z":"4e139d26.c717a4","name":"bg color","rules":[{"t":"set","p":"background","pt":"msg","to":"#3FADB5","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":1580,"wires":[["55aac22e.2a9204","d03245a4.e7a21","6e1eb9c1.7605d","8256768b.1d5108"]]},{"id":"55aac22e.2a9204","type":"ui_button","z":"4e139d26.c717a4","name":"chargeTime","group":"a778a4f8.f945f8","order":3,"width":0,"height":0,"passthru":false,"label":"Charge Time: {{chargeTime}}h","tooltip":"","color":"","bgcolor":" {{background}}","icon":"","payload":"100","payloadType":"num","topic":"data/tesla/chargeTime","topicType":"str","x":1170,"y":1540,"wires":[[]]},{"id":"d03245a4.e7a21","type":"change","z":"4e139d26.c717a4","name":"-> data/tesla/chargeTime","rules":[{"t":"set","p":"payload","pt":"msg","to":"chargeTime","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"data/tesla/chargeTime","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1220,"y":1580,"wires":[["eb4163a0.aebe6"]]},{"id":"eb4163a0.aebe6","type":"link out","z":"4e139d26.c717a4","name":"","links":["70cb46f0.581f68","f8d7f4303cd3f838"],"x":1385,"y":1580,"wires":[]},{"id":"996f3d90.908f58","type":"tesla-api","z":"4e139d26.c717a4","teslaConfig":"cca88314.8bcf68","command":"setChargeLimit","name":"setChargeLimit","x":280,"y":1800,"wires":[["8ddf6bf5.1e6708"]]},{"id":"6e1eb9c1.7605d","type":"change","z":"4e139d26.c717a4","name":"set commandArgs","rules":[{"t":"set","p":"commandArgs.amt","pt":"msg","to":"chargeLevel","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":1760,"wires":[["996f3d90.908f58"]]},{"id":"8ddf6bf5.1e6708","type":"switch","z":"4e139d26.c717a4","name":"charge now?","property":"chargeNow","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":280,"y":1840,"wires":[["b3780dd4.f6aa88"],["3bec4b1f.b844f4"]]},{"id":"b3780dd4.f6aa88","type":"tesla-api","z":"4e139d26.c717a4","teslaConfig":"cca88314.8bcf68","command":"startCharge","name":"startCharge","x":490,"y":1820,"wires":[["4146c684.33a318"]]},{"id":"3bec4b1f.b844f4","type":"tesla-api","z":"4e139d26.c717a4","teslaConfig":"cca88314.8bcf68","command":"stopCharge","name":"stopCharge","x":490,"y":1860,"wires":[["4146c684.33a318"]]},{"id":"68125061.82b16","type":"change","z":"4e139d26.c717a4","name":"-> batteryLevel","rules":[{"t":"set","p":"payload","pt":"msg","to":"chargeState.battery_level","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"data/tesla/batteryLevel","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":1800,"wires":[["152b0c83.6c0f3b"]]},{"id":"152b0c83.6c0f3b","type":"link out","z":"4e139d26.c717a4","name":"","links":["907c80c1.54e128"],"x":1275,"y":1840,"wires":[]},{"id":"9348144e.495758","type":"change","z":"4e139d26.c717a4","name":"-> chargeState","rules":[{"t":"set","p":"payload","pt":"msg","to":"chargeState.charger_power","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"data/tesla/chargeState","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":1840,"wires":[["152b0c83.6c0f3b"]]},{"id":"570f53e9.acf364","type":"change","z":"4e139d26.c717a4","name":"-> chargeLimit","rules":[{"t":"set","p":"payload","pt":"msg","to":"chargeState.charge_limit_soc","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"data/tesla/chargeLimit","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":1880,"wires":[["152b0c83.6c0f3b"]]},{"id":"9b8a2e4a.7937f","type":"change","z":"4e139d26.c717a4","name":"msg.chargeState","rules":[{"t":"move","p":"payload","pt":"msg","to":"chargeState","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":1840,"wires":[["68125061.82b16","9348144e.495758","570f53e9.acf364","cc8c4e1a.05efd"]]},{"id":"4146c684.33a318","type":"tesla-api","z":"4e139d26.c717a4","teslaConfig":"cca88314.8bcf68","command":"chargeState","name":"getChargeState","x":680,"y":1840,"wires":[["9b8a2e4a.7937f"]]},{"id":"3c5f605d.3450b8","type":"debug","z":"4e139d26.c717a4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":470,"y":1520,"wires":[]},{"id":"8256768b.1d5108","type":"debug","z":"4e139d26.c717a4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1150,"y":1620,"wires":[]},{"id":"cc8c4e1a.05efd","type":"debug","z":"4e139d26.c717a4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":1920,"wires":[]},{"id":"d9b6574b.b51ea8","type":"debug","z":"4e139d26.c717a4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":470,"y":1220,"wires":[]},{"id":"c3bc5a73.b7e838","type":"switch","z":"4e139d26.c717a4","name":"enabled?","property":"#:(storeInFile)::dataStatus.tesla.chargeControl","propertyType":"global","rules":[{"t":"eq","v":"enabled","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":1120,"wires":[["cab3dc94.91a388"],["4ffb8a3e.31065c"]]},{"id":"e7a96fad.96c508","type":"comment","z":"4e139d26.c717a4","name":"fetch solar forecast 1/h and store values","info":"","x":180,"y":940,"wires":[]},{"id":"f11b864.3858c78","type":"comment","z":"4e139d26.c717a4","name":"TODOs !!!","info":"Farbe charge time auf hell setzen\n\nganzer Status auf n.a. o.Ƥ. setzen falls nicht verbunden oder unbekannt","x":660,"y":1940,"wires":[]},{"id":"c4553f26.900888","type":"change","z":"4e139d26.c717a4","name":"set disabled","rules":[{"t":"set","p":"payload","pt":"msg","to":"disabled","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"data/tesla/chargeControl","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":990,"y":1440,"wires":[["d1977d99.31a4a"]]},{"id":"d1977d99.31a4a","type":"link out","z":"4e139d26.c717a4","name":"","links":["907c80c1.54e128"],"x":1115,"y":1440,"wires":[]},{"id":"dc59f574.d9aed","type":"change","z":"4e139d26.c717a4","name":"set disabled","rules":[{"t":"set","p":"payload","pt":"msg","to":"disabled","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"data/tesla/chargeControl","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":1380,"wires":[["5fe4daf8.84d124"]]},{"id":"5fe4daf8.84d124","type":"link out","z":"4e139d26.c717a4","name":"","links":["907c80c1.54e128"],"x":675,"y":1380,"wires":[]},{"id":"4ffb8a3e.31065c","type":"debug","z":"4e139d26.c717a4","name":"disabled","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":440,"y":1140,"wires":[]},{"id":"1cd2863e.55dfa2","type":"function","z":"4e139d26.c717a4","name":"->influxdb","func":"// input: msg.colCast array with 60min forecast elements in kW\n// output: 49 messages for the influxdb\n// msg.payload = {\"solCast24\":'estimation in 24h'}\n\nfor (i=0; i<=48; i++) {\n    var nTag = \"solCast\" + i.toString();\n    var newMsg = {};\n    newMsg.measurement = \"solar\";\n    newMsg.payload = [\n        {\n            value:msg.solCast[i],\n            time:Date.now() + i*3600\n        },{\n            tag1:nTag\n            \n        }\n        ];\n    node.send(newMsg);\n}\n\nreturn;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1010,"y":1000,"wires":[["82756beb.91e8d8"]]},{"id":"82756beb.91e8d8","type":"debug","z":"4e139d26.c717a4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":1040,"wires":[]},{"id":"b8e15b9c1693ad04","type":"debug","z":"4e139d26.c717a4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":920,"wires":[]},{"id":"0e5507e186ba20f7","type":"cronplus","z":"4e139d26.c717a4","d":true,"name":"1/h","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"schedule1","payloadType":"default","payload":"","expressionType":"cron","expression":"1 0 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":90,"y":980,"wires":[["44b73686.20b328"]]},{"id":"85cc4509673705fa","type":"cronplus","z":"4e139d26.c717a4","d":true,"name":"1/h","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"schedule1","payloadType":"default","payload":"","expressionType":"cron","expression":"10 0 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":90,"y":1120,"wires":[["c3bc5a73.b7e838"]]},{"id":"e6220b02a572c179","type":"inject","z":"4e139d26.c717a4","d":true,"name":"now","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":90,"y":1020,"wires":[["44b73686.20b328"]]},{"id":"c1c7663590e07e5a","type":"debug","z":"4e139d26.c717a4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":710,"y":920,"wires":[]},{"id":"624210f6782e5609","type":"debug","z":"4e139d26.c717a4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":510,"y":920,"wires":[]},{"id":"cca88314.8bcf68","type":"tesla-config","email":"urs.eppenberger@maremonti.ch"},{"id":"a778a4f8.f945f8","type":"ui_group","name":"Charge State","tab":"cc41f24f.2ab028","order":4,"disp":true,"width":"4","collapse":false},{"id":"cc41f24f.2ab028","type":"ui_tab","name":"Tesla","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

I had to put the flow into two parts, since the board limits me to 32k-characters per posting.

Hi Urs,

have you ever tried setChargingAmps with success?
I tried with now success because of the following error message:

result: false
reason: "missing charging_amps param"

Any ideas?

Thanks
Chris

Yes, for me it worked. In the Tesla API node you set the 'setChargingAmps' option and in the incoming message you need to set

msg.commandArgs.amps

to an Integer value. Here is an Inject node which sets the maximum charging power to 10 ampere. Just feed this into the Tesla API node with the settings as mentioned above and it should work.

[{"id":"6d1577b73768837c","type":"inject","z":"4e139d26.c717a4","name":"Charge Amps","props":[{"p":"commandArgs.amps","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":2220,"wires":[["5edb4b8f0e8f20e7"]]}]

Kind regards,
Urs.

1 Like

Hi Urs,

many thanks for your quick answer.
Where can I find a List of all the parameter for all commands?
Within the Tesls API Docu I found nothing about "amps".

Thanks
Chris

I had to reverse engineer this. The various web sites for the unofficial Tesla API do not help.

I looked into the code here:
~/.node-red/node_modules/node-red-contrib-tesla/src

I have no clue about Javascript programming and I'm certainly not able to write my own node-red node. But if you go into the code and look for the huge 'case' statement, you see all the supported commands and on the next line all arguments with their names. Without understanding the code I just used what I found there and it worked.

The question is, how the heck did the author figure this out. But since it worked for me, I noted this down as a success and moved on.

Kind regards,

Urs.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.