Python script for Tesla actions

Python and python framework

Moderator: leecollings

Post Reply
Knibor
Posts: 112
Joined: Sunday 20 May 2018 12:56
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: NL
Contact:

Python script for Tesla actions

Post 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
User avatar
FireWizard
Posts: 1863
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Python script for Tesla actions

Post 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
MasMat
Posts: 17
Joined: Saturday 09 March 2019 20:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Helsinki
Contact:

Re: Python script for Tesla actions

Post 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.
User avatar
FireWizard
Posts: 1863
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Python script for Tesla actions

Post 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,
Last edited by FireWizard on Friday 03 May 2019 17:18, edited 1 time in total.
Knibor
Posts: 112
Joined: Sunday 20 May 2018 12:56
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: NL
Contact:

Re: Python script for Tesla actions

Post by Knibor »

Hi, thanks for the information. I will try this week to install these programs on my Rasp Pi.
User avatar
sincze
Posts: 1300
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Python script for Tesla actions

Post 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??? ;-)
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
magicduck
Posts: 36
Joined: Sunday 11 February 2018 13:25
Target OS: -
Domoticz version:
Location: Longwy, France
Contact:

Re: Python script for Tesla actions

Post 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
MrHobbes74
Posts: 115
Joined: Sunday 19 January 2020 22:29
Target OS: Raspberry Pi / ODroid
Domoticz version: latest B
Location: Netherlands
Contact:

Re: Python script for Tesla actions

Post by MrHobbes74 »

See
https://www.domoticz.com/forum/viewtopi ... 38&t=31244

for a working first version of native Tesla support in Domoticz.
MrHobbes74
Posts: 115
Joined: Sunday 19 January 2020 22:29
Target OS: Raspberry Pi / ODroid
Domoticz version: latest B
Location: Netherlands
Contact:

Re: Python script for Tesla actions

Post by MrHobbes74 »

The coming beta will have Tesla support! Please try it! Comments and tips are welcome for a next version!
magicduck
Posts: 36
Joined: Sunday 11 February 2018 13:25
Target OS: -
Domoticz version:
Location: Longwy, France
Contact:

Re: Python script for Tesla actions

Post 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
MrHobbes74
Posts: 115
Joined: Sunday 19 January 2020 22:29
Target OS: Raspberry Pi / ODroid
Domoticz version: latest B
Location: Netherlands
Contact:

Re: Python script for Tesla actions

Post 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!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest