Skip to content

Instantly share code, notes, and snippets.

@hjespers
Created October 15, 2014 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hjespers/48778e2b3c2f90c155b8 to your computer and use it in GitHub Desktop.
Save hjespers/48778e2b3c2f90c155b8 to your computer and use it in GitHub Desktop.
simple flow which controls a Tesla Model S electric car and honks the horn

This flow controls a Tesla Model S electric car. It uses the TeslaMS javascript libraries so you need to npm install node-red-contrib-teslams from the root of your node-red installation (or download from github at https://github.com/hjespers/node-red-contrib-teslams). Configure the login node in the flow with your Tesla Motors login and password so you are controlling your own car. The login node sets the tokens and cookies required to enable all other controls and it returns an array of vehicle data associated with your account. These tokens are not stored so the flow must authenticate each time you restart node-red. All the other nodes require a JSON version of this vehicle array as input (specifically the "id" of your car).

[{"id":"74c71a60.8b38e4","type":"debug","name":"lock result","active":true,"console":"false","complete":"false","x":632.0001525878906,"y":310.020263671875,"z":"1961a857.e69e58","wires":[]},{"id":"a0f9122a.5f06f","type":"debug","name":"flash result","active":true,"console":"false","complete":"false","x":639.5252532958984,"y":56.8181095123291,"z":"1961a857.e69e58","wires":[]},{"id":"2de8221b.d217de","type":"command","name":"flash lights","command":"flash","x":475.39394760131836,"y":66.23225975036621,"z":"1961a857.e69e58","wires":[["a0f9122a.5f06f"]]},{"id":"e9ca3752.1635c8","type":"command","name":"honk horn","command":"honk","x":472.8384094238281,"y":181.19927978515625,"z":"1961a857.e69e58","wires":[["a856e3df.57a92"]]},{"id":"a856e3df.57a92","type":"debug","name":"horn result","active":true,"console":"false","complete":"false","x":648.7778015136719,"y":167.97703552246094,"z":"1961a857.e69e58","wires":[]},{"id":"e3c505ab.1c3af8","type":"inject","name":"auth","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"","once":false,"x":91.2828369140625,"y":37.97704315185547,"z":"1961a857.e69e58","wires":[["1f9403ae.e06bfc"]]},{"id":"1f9403ae.e06bfc","type":"login","name":"","x":194.6287841796875,"y":128.2523193359375,"z":"1961a857.e69e58","wires":[["42966591.bd699c"]]},{"id":"42966591.bd699c","type":"json","name":"","x":277.2550926208496,"y":232.6794147491455,"z":"1961a857.e69e58","wires":[["e9ca3752.1635c8","2de8221b.d217de","dda43a8c.225bc8"]]},{"id":"dda43a8c.225bc8","type":"sunroof","name":"","state":"vent","x":463.0909118652344,"y":312.0909118652344,"z":"1961a857.e69e58","wires":[["74c71a60.8b38e4"]]},{"id":"5700b815.a8ff48","type":"comment","name":"remember to add your Tesla login/password to the login node","info":"","x":222.09091186523438,"y":370.99999237060547,"z":"1961a857.e69e58","wires":[]},{"id":"1d65df2b.e29a21","type":"comment","name":"add a command node configured to wake_up the car (and a delay node) to handle a sleeping car","info":"","x":334,"y":417.09092712402344,"z":"1961a857.e69e58","wires":[]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment