onokje / node-red-contrib-tesla

Node red nodes to control Tesla vehicles and devices
MIT License
20 stars 11 forks source link

Wake up #2

Closed Hassefar closed 2 years ago

Hassefar commented 4 years ago

The node works great when the car is awake. However, I cannot seem to get it to wake up and then run a command. Is it required to use the wake-up command at all times to ensure that the car is awake when a flow is activated?

onokje commented 4 years ago

Actually, a wakeup command is send automatically if needed. You have to wake up the car every time you send a command, except for "vehicle" or "vehicles". The car will stay awake for a certain amount of minutes (about 10 to 15 minutes I believe) before it goes to sleep again.

However, I also noticed that a lot of times it just doesn't work, or results in timeouts. This is not really something that I can fix, sometimes it just takes a few tries to wakeup your car. However, i can create an auto-retry mechanism. Also, i am planning on making the auto-wakeup feature configurable.

Christiandk1986 commented 4 years ago

It would be awsome with a retry function. As I am using the node with a flic-button, it would be great if one press would always perform the action. Is there a way that I can configure a retry automatically?

Most often when the car i sleeping, there is no response - if I then press the button again, I get the message "Error: connect ETIMEDOUT 205.234.31.120:443" and the car will only perform the action after the second press.

Christiandk1986 commented 4 years ago

This has solved the problem for me - it would, however, be cool with an integrated function. :-)

[ { "id": "8d8bdbc2.7f9658", "type": "tesla-api", "z": "8d0266e0.cec888", "teslaConfig": "", "command": "openChargePort", "name": "openChargePort", "x": 1020, "y": 60, "wires": [ [ "649ccb68.f8cee4", "c38af7e2.3ab188" ] ] }, { "id": "ab0ad58e.713978", "type": "delay", "z": "8d0266e0.cec888", "name": "", "pauseType": "delay", "timeout": "3", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "x": 480, "y": 160, "wires": [ [ "c7944e13.06708" ] ] }, { "id": "bee3c7d6.cd8348", "type": "switch", "z": "8d0266e0.cec888", "name": "", "property": "confirmed", "propertyType": "flow", "rules": [ { "t": "true" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 830, "y": 200, "wires": [ [ "9c5ef4.d73b111" ], [ "8d8bdbc2.7f9658", "c83c7d3c.76646" ] ] }, { "id": "c7944e13.06708", "type": "trigger", "z": "8d0266e0.cec888", "op1": "true", "op2": "true", "op1type": "bool", "op2type": "bool", "duration": "-3", "extend": false, "units": "s", "reset": "", "bytopic": "all", "name": "", "x": 660, "y": 200, "wires": [ [ "bee3c7d6.cd8348" ] ] }, { "id": "9c5ef4.d73b111", "type": "change", "z": "8d0266e0.cec888", "name": "", "rules": [ { "t": "set", "p": "reset", "pt": "msg", "to": "true", "tot": "bool" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 740, "y": 360, "wires": [ [ "c7944e13.06708" ] ] }, { "id": "d02e482e.7c4848", "type": "switch", "z": "8d0266e0.cec888", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "7", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 1170, "y": 320, "wires": [ [ "9c5ef4.d73b111" ] ] }, { "id": "649ccb68.f8cee4", "type": "change", "z": "8d0266e0.cec888", "name": "", "rules": [ { "t": "set", "p": "confirmed", "pt": "flow", "to": "true", "tot": "bool" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1230, "y": 60, "wires": [ [] ] }, { "id": "3934f6f.3f9980a", "type": "change", "z": "8d0266e0.cec888", "name": "", "rules": [ { "t": "set", "p": "confirmed", "pt": "flow", "to": "false", "tot": "bool" }, { "t": "set", "p": "toggleNext", "pt": "flow", "to": "0", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 300, "y": 100, "wires": [ [ "ab0ad58e.713978" ] ] }, { "id": "d3df50fa.fc4b9", "type": "tesla-api", "z": "8d0266e0.cec888", "teslaConfig": "", "command": "openChargePort", "name": "openChargePort", "x": 1500, "y": 460, "wires": [ [ "6e1e42b0.5aa65c" ] ] }, { "id": "2d296ea8.778f92", "type": "delay", "z": "8d0266e0.cec888", "name": "", "pauseType": "delay", "timeout": "3", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "x": 500, "y": 560, "wires": [ [ "4951917b.b906" ] ] }, { "id": "d9f9ae4e.45e51", "type": "switch", "z": "8d0266e0.cec888", "name": "", "property": "confirmed", "propertyType": "flow", "rules": [ { "t": "true" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 850, "y": 600, "wires": [ [ "7261d30.15ae92c" ], [ "2ca900eb.e387", "e9184219.d7c44" ] ] }, { "id": "4951917b.b906", "type": "trigger", "z": "8d0266e0.cec888", "op1": "true", "op2": "true", "op1type": "bool", "op2type": "bool", "duration": "-3", "extend": false, "units": "s", "reset": "", "bytopic": "all", "name": "", "x": 680, "y": 600, "wires": [ [ "d9f9ae4e.45e51" ] ] }, { "id": "7261d30.15ae92c", "type": "change", "z": "8d0266e0.cec888", "name": "", "rules": [ { "t": "set", "p": "reset", "pt": "msg", "to": "true", "tot": "bool" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 740, "y": 800, "wires": [ [ "4951917b.b906" ] ] }, { "id": "23ab32dc.95882e", "type": "switch", "z": "8d0266e0.cec888", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "7", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 1190, "y": 720, "wires": [ [ "7261d30.15ae92c" ] ] }, { "id": "7a8a06bc.93ebf8", "type": "change", "z": "8d0266e0.cec888", "name": "", "rules": [ { "t": "set", "p": "confirmed", "pt": "flow", "to": "true", "tot": "bool" }, { "t": "set", "p": "payload", "pt": "msg", "to": "true", "tot": "bool" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1240, "y": 460, "wires": [ [ "d3df50fa.fc4b9" ] ] }, { "id": "2ca900eb.e387", "type": "tesla-api", "z": "8d0266e0.cec888", "teslaConfig": "", "command": "stopCharge", "name": "stopCharge", "x": 1010, "y": 460, "wires": [ [ "7a8a06bc.93ebf8", "d0e27e28.ac196" ] ] }, { "id": "c83c7d3c.76646", "type": "function", "z": "8d0266e0.cec888", "name": "Cycle actions", "func": "var Actions = flow.get(\"toggleNext\") + 1||1;\n\nif (Actions >= 7){\n flow.set(\"toggleNext\",0);\n msg.payload = 7;\n }\nelse{\n flow.set(\"toggleNext\", Actions);\n msg.payload = Actions\n }\nreturn msg;", "outputs": 1, "noerr": 0, "x": 1010, "y": 280, "wires": [ [ "d02e482e.7c4848", "c63d3cbb.11c0e" ] ] }, { "id": "2dc42393.74944c", "type": "change", "z": "8d0266e0.cec888", "name": "", "rules": [ { "t": "set", "p": "confirmed", "pt": "flow", "to": "false", "tot": "bool" }, { "t": "set", "p": "toggleNext", "pt": "flow", "to": "0", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 320, "y": 500, "wires": [ [ "2d296ea8.778f92" ] ] }, { "id": "e9184219.d7c44", "type": "function", "z": "8d0266e0.cec888", "name": "Cycle actions", "func": "var Actions = flow.get(\"toggleNext\") + 1||1;\n\nif (Actions >= 7){\n flow.set(\"toggleNext\",0);\n msg.payload = 7;\n }\nelse{\n flow.set(\"toggleNext\", Actions);\n msg.payload = Actions\n }\nreturn msg;", "outputs": 1, "noerr": 0, "x": 1030, "y": 680, "wires": [ [ "23ab32dc.95882e", "f548cc97.74161" ] ] }, { "id": "d0e27e28.ac196", "type": "debug", "z": "8d0266e0.cec888", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 1200, "y": 540, "wires": [] }, { "id": "6e1e42b0.5aa65c", "type": "debug", "z": "8d0266e0.cec888", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 1660, "y": 540, "wires": [] }, { "id": "f548cc97.74161", "type": "debug", "z": "8d0266e0.cec888", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 1280, "y": 660, "wires": [] }, { "id": "c63d3cbb.11c0e", "type": "debug", "z": "8d0266e0.cec888", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 1220, "y": 240, "wires": [] }, { "id": "c38af7e2.3ab188", "type": "debug", "z": "8d0266e0.cec888", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 1220, "y": 140, "wires": [] }, { "id": "359949b8.4d0e76", "type": "inject", "z": "8d0266e0.cec888", "name": "", "topic": "", "payload": "", "payloadType": "date", "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "x": 120, "y": 60, "wires": [ [ "8d8bdbc2.7f9658", "3934f6f.3f9980a" ] ] }, { "id": "d3949a74.bf4318", "type": "inject", "z": "8d0266e0.cec888", "name": "", "topic": "", "payload": "", "payloadType": "date", "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "x": 120, "y": 460, "wires": [ [ "2ca900eb.e387", "2dc42393.74944c" ] ] } ]

LudwigWen commented 4 years ago

Info Wake_up problem may be caused by:

File: /node_modules/teslams/teslams.js function wake_up -- url: portal + '/vehicles/' + vid + '/command/wake_up', ++ url: portal + '/vehicles/' + vid + '/wake_up',

Model 3, will only wakeup without "/command".

see https://github.com/hjespers/teslams/issues/138

Christiandk1986 commented 4 years ago

Info Wake_up problem may be caused by:

File: /node_modules/teslams/teslams.js function wake_up -- url: portal + '/vehicles/' + vid + '/command/wake_up', ++ url: portal + '/vehicles/' + vid + '/wake_up',

Model 3, will only wakeup without "/command".

see hjespers/teslams#138

It actually manages to wake up the car - it just times out before executing the command if the car is sleeping. With the above I have set it to retry 7 times thereby making the likelhood that the command is sent when the car is awake greater.

TomNijsen commented 4 years ago

I cannot deploy the example flow with my own credentials configured in the api node. Always getting an error: "Credential type 'tesla-config' is not registered" when trying to deploy my flow. If I then reopen the tesla-api node, my credentials are blank. Tried to re-insert and redeploy a dozen of times... I also get a warning next to deploy option: "Flows stopped due to missing node types. tesla-config tesla-api" => Sorry this should have been a New Issue, fixed it.

onokje commented 2 years ago

check the version 2.0.0 update. It comes with build-in auto-wakeup retry.