Page 1 of 1

Python script for Tesla actions

Posted: Sunday 28 April 2019 0:02
by Knibor
Hi,

Could this python script work in Domoticz?
This is an exported script from "postman program" to Python.

My goal is to do some actions with a virtual switch in Domoticz to control a Tesla.

********************************************************************************************************************************

import requests

url = "https://owner-api.teslamotors.com/api/1 ... /honk_horn"

payload = ""
headers = {
'Authorization': "Bearer 1234567890",
'User-Agent': "PostmanRuntime/7.11.0",
'Accept': "*/*",
'Cache-Control': "no-cache",
'Postman-Token': "abcde",
'Host': "owner-api.teslamotors.com",
'accept-encoding': "gzip, deflate",
'content-length': "",
'Connection': "keep-alive",
'cache-control': "no-cache"
}

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)

*********************************************************************************************************************************
Thanks

Re: Python script for Tesla actions

Posted: Sunday 28 April 2019 14:39
by FireWizard
Hi,

Are you aware that there exist a node for Tesla in Node Red? You need an account and it is for Tesla Model S. From there you can use the same approach as I did for Volvo.
See "Connected Cars"

Regards

Re: Python script for Tesla actions

Posted: Monday 29 April 2019 6:33
by MasMat
After more than ten searches for connected cars or cars or Tesla, can someone who knows it point to the thread in question? :(
Looking for a Tesla S API for Domoticz.

Re: Python script for Tesla actions

Posted: Monday 29 April 2019 13:30
by FireWizard
As I do not own a Tesla, I'm not able to test anything, as I don't have the account.

As said Node-Red has a node for Tesla Model S. You need an account.
You have to take the following steps:

1. Install NodeJS
2. Install Node-Red
3. Install MQTT broker, e.g Mosquitto and Mosquitto-clients

For details see my post at:
viewtopic.php?f=38&t=26549

Of course you can skip the Volvo part.

If you have installed the programs above you can create virtual sensors in Domoticz.
With MQTT you can push the desired data to Domoticz.
If the node in Node-Red supports it you can send commands to your Tesla.
Do not hesitate to ask.

Regards,

Re: Python script for Tesla actions

Posted: Monday 29 April 2019 13:42
by Knibor
Hi, thanks for the information. I will try this week to install these programs on my Rasp Pi.

Re: Python script for Tesla actions

Posted: Monday 04 November 2019 20:10
by sincze
Knibor wrote: Monday 29 April 2019 13:42 Hi, thanks for the information. I will try this week to install these programs on my Rasp Pi.
And did it work??? ;-)

Re: Python script for Tesla actions

Posted: Wednesday 08 January 2020 11:29
by magicduck
Hello there.
Working on a Tesla Plugin for Domoticz.
I am open to any contributions and test... (currently started work, so it does not work yet...).
See : https://www.domoticz.com/forum/viewtopi ... 65&t=30812
Regards

Re: Python script for Tesla actions

Posted: Friday 07 February 2020 11:11
by MrHobbes74
See
https://www.domoticz.com/forum/viewtopi ... 38&t=31244

for a working first version of native Tesla support in Domoticz.

Re: Python script for Tesla actions

Posted: Friday 21 February 2020 19:47
by MrHobbes74
The coming beta will have Tesla support! Please try it! Comments and tips are welcome for a next version!

Re: Python script for Tesla actions

Posted: Tuesday 03 March 2020 15:07
by magicduck
Really nice work. Better than mine... (was out of time).
So I can delete my start of work, and rely on native domoticz Tesla support :)
Many thanks :p

Re: Python script for Tesla actions

Posted: Wednesday 04 March 2020 19:58
by MrHobbes74
Thanks! Didn’t mean to overrule your work, but I recently got a Model 3, and at the same time wanted to get to know the Domoticz internal c++ code. 1+1=2. Hope you enjoy using it😉, if you have additional requirements or bugs, please let me know!