Control Tesla Cars

Test setting temp based on local weather.

driver_temp=

passenger_temp=

This is a delivery system. replace buses in cities with electrical cars. These cars run the same route as buses.

Going to change the radio

More indepth Tesla car stats. Returns the Raspberry Pi media system onboard that is used to stream media to the car. Pluhs in to the cars stero. Allows passangers in the bar to reclievve calls. Broadcast wifi. Each car has its own router that it uses to comm with the outside world. Canera t oo report how everything is goiing. If things are wrong realtime images of what is happening. The ability to for remote login and control. HAM Radio broadcast. Each car is broadcasting a media center that offers storage space and media. You are able to connect to any of these Tesla cars and access the services they offer. If for some reason they are not to total standards then you can retry.

Nux the

Switch between low and high heat.

passanger temp

config file with times to auto start the car. driverless commands. sync to meetup and drive to where the meetups are happening

{ "response": { "inside_temp": 17.0, // degC inside car "outside_temp": 9.5, // degC outside car or null "driver_temp_setting": 22.6, // degC of driver temperature setpoint "passenger_temp_setting": 22.6, // degC of passenger temperature setpoint "is_auto_conditioning_on": false, // apparently even if on "is_front_defroster_on": null, // null or boolean as integer? "is_rear_defroster_on": false, "fan_status": 0 // fan speed 0-6 or null } }


In [2]:
import json
#import nose
from cryptography.fernet import Fernet
import getpass
import pandas

In [ ]:
myusr = getpass.getuser()

In [7]:
tespas = getpass.getpass('PASSWORD ')


PASSWORD ········

In [9]:
mydict = ({ "response": { "df": False, "dr": False, "pf": False, "pr": False, "ft": False, "rt": False, "car_verson": "1.19.42", "locked": True, "sun_roof_installed": False, "sun_roof_state": "unknown", "sun_roof_percent_open": 0, "dark_rims": False, "wheel_type": "Base19", "has_spoiler": False, "roof_color": "Colored", "perf_config": "Base" } })

In [10]:
tespas


Out[10]:
'test'

In [11]:
pandas.DataFrame(mydict)


Out[11]:
response
car_verson 1.19.42
dark_rims False
df False
dr False
ft False
has_spoiler False
locked True
perf_config Base
pf False
pr False
roof_color Colored
rt False
sun_roof_installed False
sun_roof_percent_open 0
sun_roof_state unknown
wheel_type Base19

In [16]:
key = Fernet.generate_key()

f = Fernet(key)
token = f.encrypt(b'straz')
print(token)
'...'
f.decrypt(token)


b'gAAAAABX-5fRdIVRQf8vPSMZGEa7MW1Y9kxc5gv5XAUB9bHf0482Bk6vYuO-4Jy1zpfLTR7azjJew_JBh92cqrZ9Fw931daYaQ=='
Out[16]:
b'straz'

In [17]:
key


Out[17]:
b'z-FQnyhiZIL6ZWxd5tUCWxYaHQaEK4KFPlIshGKRgBM='

In [18]:
tesveh = 'https://owner-api.teslamotors.com/api/1/vehicles/1/command/remote_start_drive?password='

In [19]:
tesveh


Out[19]:
'https://owner-api.teslamotors.com/api/1/vehicles/1/command/remote_start_drive?password='

In [21]:
#from urllib2 import Request, urlopen

#headers = {
#  'Authorization': 'Bearer {access_token}'
#}
#request = Request('https://owner-api.teslamotors.com/api/1/vehicles/1/command/remote_start_drive?password=edisonsux', headers=headers)

#response_body = urlopen(request).read()
#print response_body

In [22]:
doorquen = (mydict['response']['df'], mydict['response']['dr'], mydict['response']['pf'], mydict['response']['pr'])

In [23]:
doorquen


Out[23]:
(False, False, False, False)

In [24]:
key


Out[24]:
b'z-FQnyhiZIL6ZWxd5tUCWxYaHQaEK4KFPlIshGKRgBM='

In [26]:
keyencr = f.encrypt(key)

In [27]:
keyencr


Out[27]:
b'gAAAAABX-5gkD9fwfYgaYhD3L-JLdwX9RTHr2cezBZTJ5zgyJCSzbJnNZznkB0DAY6ka5sfsbqoEZ5jOyryU_gXxvd38H3k5o_r1KRF7DecTPHb_wVspVd9XLw9q3jLr1NF_nVBxgBAW'

In [28]:
f.decrypt(token)


Out[28]:
b'straz'

In [29]:
TESLACONFIG = ('TESLA CONTROL BRUM BRUM')

In [30]:
print(TESLACONFIG)


TESLA CONTROL BRUM BRUM

In [ ]:


In [31]:
passwrdz = getpass.getpass("PASSWORD ENTER ")

askmileorkilo = input('AMERICAN SETTINGS Y/n ')

setlowtemp = input('DRIVER LOW TEMP SET AS: ')

sethightemp = input('DRIVER HIGH TEMP SET AS: ')


setpasslow = input('PASS LOW TEMP SET AS: ')

setpashight = input('PASS HIGH TEMP SET AS: ')

openDriversDoor = input('OPEN DRIVERS DOOR Y/n ')

unlockcar = input('UNLOCK CAR Y/n ')

valetmode = input('VALET MODE Y/n ')

valetpass = getpass.getpass('4 PIN NUMBER: ')


PASSWORD ENTER ········
AMERICAN SETTINGS Y/n Y
DRIVER LOW TEMP SET AS: 12
DRIVER HIGH TEMP SET AS: 15
PASS LOW TEMP SET AS: 10
PASS HIGH TEMP SET AS: 16
OPEN DRIVERS DOOR Y/n Y
UNLOCK CAR Y/n Y
VALET MODE Y/n Y
4 PIN NUMBER: ········

In [32]:
passwrdz


Out[32]:
'qwe'

In [33]:
valint = int(valetpass)

In [34]:
SETCURRENTZ = input('Current from -1 to 1: ')


Current from -1 to 1: 1

In [35]:
flsecur = float(SETCURRENTZ)

In [36]:
flsecur


Out[36]:
1.0

In [37]:
int(SETCURRENTZ)


Out[37]:
1

In [39]:
import cryptography

In [183]:
#fercypo = cryptography.fernet()

{ "portal_url": "https://owner-api.teslamotors.com/api/1/vehicles/", "stream_url": "https://streaming.vn.teslamotors.com/stream/", "username": "yourMyTeslaLogin@email.com", "password": "yourPassword", "output_file": "stream_output.txt" }


In [41]:
f.generate_key()


Out[41]:
b'Fy3UWE2Hg_dfPQMi34D3_3wsa5Fnxl0iTCXWHm3E5qs='

In [43]:
token = f.encrypt(bytes(valint))

In [44]:
print(token)


b'gAAAAABX-5iJmrFOHgUji6u3hkGCofgKBsmWq7p4Iftoxj7AHyf_SHAA_v7voz5NXOvqu2ptTeqmhkxaR3YWTBitoZVK47IxcdBRII_hb8JzileS9naLjnLuDjmmFSh0zGMmvFZELJdxOQeEBDDP6kl7UMiWkFTl_y3NK0hk_BsicG3kSqbRQvmuo7Yvz6wBb7LPMMOIpCFlMK5Xqyd4Eyv20_y2qTrdR7KwbPKyXeYSHS8DSp0JWO72rRqAfGUJehV9oI1JVeofLrakjHYiubOVHvDDcIs0H9HPulbyVUSrF1VDb-ct4WQPVdkrosuHfA2bJT_t5WtA6zr4kKSS6DpenC8G6-bAAfaLdLZ2qraZJlbCmDJ3C4zL7AgWDA98hmtDN3X-mR2NCcleHqM0X8reNxD8O-VJiTZOxUkOS2Piyo32lI4FpNgnSGrjFaIE3JAWjyyHHXWQBysTi5S8fkGX9Fc--szZnKaZ7FFu-7HHOSw4G1WwU4LVaG6ibfB43-qacA8B_EpV711AT_vmugjUk933eHH3IO4uJmFSap1nSwcaWzgEF41hsBDtPxxifDDBOclAz0aIwqJpq4PWmxMdL3iXsEEl6GHiTerbixHvBVqVoxbjMgEo2x6ULH9cJJW0Bv5wQEsJFAej-Uf2y4HgGLVrMJS1gcze7AYqGO5n5jsLB9KEbD3ZYg6xBm6mZe4eQbfizf7AGLJW_qLK_T22UohS-Wtt47wyFiZ2_NUEz5vm77f9UkfjQuOSJnJ52jpsUL9XBcjH4er_W61yMpaHU14lSJa5hjWiB15iq0Fah-fv_nmHdLS6v8u7nSnBsoNG5Z4paVn_joBFD7eERdWCCLl09Y7T8SLp9wq6M7_I6KOceJYht_6xIPImDcthtRg1G5nzQj52u4QMG0YioEfVxO9F7-ocbo3Irva_uhmoao23l0Mnt_YfrEr5erL_xxtFsfI1N1rs8V2Ki7yxrg2hFVTcXkv4z6v2ovfAHASJaWNSzw1406JveN-ZDCJBQvCI2kHqFDcsmN4zHktQnJmkG2TZteO3cJA30aD7EMqbGDYv5WWh0JQplNrqg-dg9ZOD1L8hqeVjmqv8_yOxFVm12e6TeW2LXADerdCML67DdfHh0kjhTyGMSPdaLoPwk3gRbXnADsz9VCIAGQMnpyEcbnFYnLO4eDs5KeT01cBqF_T_A1EfFjgFVM9daBKfewHyI19DDmOWKFHPgY5p-5pDpt2v5zrwjJ8wrBFsGrotyH_A7bkpC2p4p1KcRoqf5u2NwJlCB6CKzdPyWdHbm-f9JQ_tLwpKmm0X0Lt11t9sf0ApVNFGEp6T3rd5f8nwEH7bq7OmCbXeLV5xmvqI1hX84MuLu2ZoRSflO1osmOfEeRlse3qvE8j0Jk-K4gDUH2BDlkUrUv5ij3KMqSDVR2oiPKl2Za9dT6wWPWMhzefvGjgkXZATzkPM4hVjaCA-6M6NNAMxlRLgTvrXwQTu3J3HZQ-8HPGn-ntUzx_RBSbHmHV4q63piREC_9SswFthJYoMCL4jY5lkHnsH-zKGC2x20nCib9QyiKYGQsFcCVq37CqPfUDCx-CVK2qjRO89dn9seFXaPI4Jsr4dGNHOt1Q3MSTCaeoMsODnpzwgjv4dq1r_utrOG_bMMac3Bg0JMsC_KWo8gxf_mVMvhERmZCizapav2geJtbJM5234X3SoDmqnAfQHPZxR5FpWVvo_8xoms2okByh2'

In [45]:
f.decrypt(token)


Out[45]:
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

In [46]:
int.from_bytes((f.decrypt(token)), byteorder='big')


Out[46]:
0

In [47]:
byedecrpt = (f.decrypt(token))

In [48]:
int.from_bytes((byedecrpt), byteorder='big')


Out[48]:
0

In [50]:
if 'n' in valetmode:
    valeton = False
elif 'Y' in valetmode:
    valeton = True

In [52]:
if 'n' in askmileorkilo:
    miletru = False
elif 'Y' in askmileorkilo:
    miletru = True

In [53]:
askmileorkilo


Out[53]:
'Y'

In [54]:
miletru


Out[54]:
True

In [55]:
if miletru == True:
    guidisuni = "mi/hr"
elif miletru == False:
    guidisuni = "km/hr"

In [56]:
guidisuni


Out[56]:
'mi/hr'

In [57]:
if 'n' in unlockcar:
    opddor = False
elif 'Y' in unlockcar:
    opddor = True

In [58]:
opddor


Out[58]:
True

In [59]:
if 'n' in openDriversDoor:
    opddor = False
    
elif 'Y' in openDriversDoor:
    opddor = True

In [60]:
opddor


Out[60]:
True

In [61]:
import configparser

In [62]:
dfstat = (mydict['response']['df'])

In [63]:
pfstat = (mydict['response']['pf'])

In [64]:
prstat = (mydict['response']['pr'])

In [65]:
drstat = (mydict['response']['dr'])

In [66]:
drstat


Out[66]:
False

In [67]:
prstat


Out[67]:
False

In [68]:
dfstat


Out[68]:
False

In [69]:
pfstat


Out[69]:
False

In [70]:
import arrow

In [71]:
timnow = arrow.now()

In [72]:
print(timnow.datetime)


2016-10-11 02:34:18.627450+13:00

In [73]:
timnow.for_json()


Out[73]:
'2016-10-11T02:34:18.627450+13:00'

In [74]:
timnow.isoweekday()


Out[74]:
2

In [75]:
timnow.humanize()


Out[75]:
'just now'

In [76]:
timnow.isoweekday()


Out[76]:
2

In [77]:
timnow.isocalendar()


Out[77]:
(2016, 41, 2)

In [78]:
timnow.ceil


Out[78]:
<bound method Arrow.ceil of <Arrow [2016-10-11T02:34:18.627450+13:00]>>

In [79]:
timnow.clone()


Out[79]:
<Arrow [2016-10-11T02:34:18.627450+13:00]>

In [80]:
timnow.date()


Out[80]:
datetime.date(2016, 10, 11)

In [81]:
timnow.format()


Out[81]:
'2016-10-11 02:34:18+13:00'

In [82]:
timnow.floor


Out[82]:
<bound method Arrow.floor of <Arrow [2016-10-11T02:34:18.627450+13:00]>>

In [83]:
timnow.float_timestamp


Out[83]:
1476106458.62745

In [84]:
timz = timnow.for_json()

In [85]:
timz


Out[85]:
'2016-10-11T02:34:18.627450+13:00'

In [86]:
print(timz)


2016-10-11T02:34:18.627450+13:00

In [87]:
timz.upper()


Out[87]:
'2016-10-11T02:34:18.627450+13:00'

In [88]:
timz.split('-' and ':' and '.')


Out[88]:
['2016-10-11T02:34:18', '627450+13:00']

In [89]:
print(timnow)


2016-10-11T02:34:18.627450+13:00

In [90]:
timutc = timnow.utcnow()

In [ ]:


In [91]:
timnow.weekday()


Out[91]:
1

In [92]:
timnow.dst()


Out[92]:
datetime.timedelta(0, 3600)

In [93]:
timnow.ctime()


Out[93]:
'Tue Oct 11 02:34:18 2016'

In [95]:
arrow.util.total_seconds


Out[95]:
<function arrow.util._total_seconds_27>

In [96]:
arrow.api.factory


Out[96]:
<function arrow.api.factory>

In [97]:
artz = arrow.factory.tzinfo(timutc)

In [99]:
calcsee= arrow.locales.calendar.HTMLCalendar()

In [100]:
calcsee.formatmonth(2016, 5)


Out[100]:
'<table border="0" cellpadding="0" cellspacing="0" class="month">\n<tr><th colspan="7" class="month">May 2016</th></tr>\n<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>\n<tr><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="sun">1</td></tr>\n<tr><td class="mon">2</td><td class="tue">3</td><td class="wed">4</td><td class="thu">5</td><td class="fri">6</td><td class="sat">7</td><td class="sun">8</td></tr>\n<tr><td class="mon">9</td><td class="tue">10</td><td class="wed">11</td><td class="thu">12</td><td class="fri">13</td><td class="sat">14</td><td class="sun">15</td></tr>\n<tr><td class="mon">16</td><td class="tue">17</td><td class="wed">18</td><td class="thu">19</td><td class="fri">20</td><td class="sat">21</td><td class="sun">22</td></tr>\n<tr><td class="mon">23</td><td class="tue">24</td><td class="wed">25</td><td class="thu">26</td><td class="fri">27</td><td class="sat">28</td><td class="sun">29</td></tr>\n<tr><td class="mon">30</td><td class="tue">31</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td></tr>\n</table>\n'

In [101]:
arnow = arrow.now()

In [102]:
dayweekz = arnow.weekday()

In [103]:
dayweekz


Out[103]:
1

In [104]:
calcsee.getfirstweekday()


Out[104]:
0

In [105]:
calcsee.getfirstweekday()


Out[105]:
0

In [109]:
arnow.strftime('%M')


Out[109]:
'35'

In [110]:
arnow.strftime('%m')


Out[110]:
'10'

In [111]:
arnow.strftime('%Y %m')


Out[111]:
'2016 10'

In [ ]:


In [112]:
yrints = int(arnow.strftime('%Y'))

In [113]:
yrints


Out[113]:
2016

In [114]:
mondayfor = int(arnow.strftime('%m'))

In [115]:
mondayfor


Out[115]:
10

In [116]:
daydatye = int(arnow.strftime('%d'))

In [117]:
daydatye


Out[117]:
11

In [118]:
calcsee.formatday(2016, 1)


Out[118]:
'<td class="tue">2016</td>'

In [120]:
panread = pandas.read_html(calcsee.formatmonth(yrints, mondayfor))

In [121]:
panread[0]


Out[121]:
0 1 2 3 4 5 6
0 2016-10-11 NaT NaT NaT NaT NaT NaT
1 2016-10-17 2016-10-11 2016-10-12 2016-10-13 2016-10-14 2016-10-15 2016-10-16
2 NaT NaT NaT NaT NaT NaT NaT
3 NaT NaT NaT NaT NaT NaT NaT
4 NaT NaT NaT NaT NaT NaT NaT
5 NaT NaT NaT NaT NaT NaT NaT
6 NaT NaT NaT NaT NaT NaT NaT
7 NaT NaT NaT NaT NaT NaT NaT

In [122]:
calcsee.formatmonth(yrints, mondayfor)


Out[122]:
'<table border="0" cellpadding="0" cellspacing="0" class="month">\n<tr><th colspan="7" class="month">October 2016</th></tr>\n<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>\n<tr><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="sat">1</td><td class="sun">2</td></tr>\n<tr><td class="mon">3</td><td class="tue">4</td><td class="wed">5</td><td class="thu">6</td><td class="fri">7</td><td class="sat">8</td><td class="sun">9</td></tr>\n<tr><td class="mon">10</td><td class="tue">11</td><td class="wed">12</td><td class="thu">13</td><td class="fri">14</td><td class="sat">15</td><td class="sun">16</td></tr>\n<tr><td class="mon">17</td><td class="tue">18</td><td class="wed">19</td><td class="thu">20</td><td class="fri">21</td><td class="sat">22</td><td class="sun">23</td></tr>\n<tr><td class="mon">24</td><td class="tue">25</td><td class="wed">26</td><td class="thu">27</td><td class="fri">28</td><td class="sat">29</td><td class="sun">30</td></tr>\n<tr><td class="mon">31</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td></tr>\n</table>\n'

In [125]:
import os

In [126]:
import random

In [ ]:


In [127]:
calcday = calcsee.cssclasses

In [128]:
calcday


Out[128]:
['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']

In [129]:
calcfulday = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']

In [130]:
len(calcfulday)


Out[130]:
7

In [ ]:


In [131]:
random.choice(calcfulday)


Out[131]:
'Friday'

In [132]:
dayweekz


Out[132]:
1

In [133]:
calcfulday[dayweekz]


Out[133]:
'Tuesday'

In [ ]:


In [134]:
print(calcday[dayweekz])


tue

In [136]:
random.choice(calcday)


Out[136]:
'tue'

In [ ]:


In [137]:
calcsee.firstweekday


Out[137]:
0

In [138]:
calcsee.formatday


Out[138]:
<bound method HTMLCalendar.formatday of <calendar.HTMLCalendar object at 0xaeee90d0>>

In [139]:
calcsee.formatmonth


Out[139]:
<bound method HTMLCalendar.formatmonth of <calendar.HTMLCalendar object at 0xaeee90d0>>

In [140]:
calcsee.


  File "<ipython-input-140-511f2c07e020>", line 1
    calcsee.
            ^
SyntaxError: invalid syntax

In [141]:
passwrdz


Out[141]:
'qwe'

In [142]:
f.encrypt


Out[142]:
<bound method Fernet.encrypt of <cryptography.fernet.Fernet object at 0xaeff4f50>>

In [143]:
token = f.encrypt(passwrdz)


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-143-6d6ff1800471> in <module>()
----> 1 token = f.encrypt(passwrdz)

/usr/lib/python3/dist-packages/cryptography/fernet.py in encrypt(self, data)
     58         current_time = int(time.time())
     59         iv = os.urandom(16)
---> 60         return self._encrypt_from_parts(data, current_time, iv)
     61 
     62     def _encrypt_from_parts(self, data, current_time, iv):

/usr/lib/python3/dist-packages/cryptography/fernet.py in _encrypt_from_parts(self, data, current_time, iv)
     62     def _encrypt_from_parts(self, data, current_time, iv):
     63         if not isinstance(data, bytes):
---> 64             raise TypeError("data must be bytes.")
     65 
     66         padder = padding.PKCS7(algorithms.AES.block_size).padder()

TypeError: data must be bytes.

In [144]:
import hashlib

In [145]:
print(hashlib.algorithms_available)
print(hashlib.algorithms_guaranteed)


{'SHA1', 'MD5', 'sha', 'sha1', 'MD4', 'SHA', 'SHA384', 'dsaWithSHA', 'whirlpool', 'sha224', 'md5', 'ripemd160', 'ecdsa-with-SHA1', 'sha512', 'SHA512', 'SHA224', 'SHA256', 'sha256', 'sha384', 'md4', 'DSA-SHA', 'dsaEncryption', 'DSA', 'RIPEMD160'}
{'sha512', 'sha1', 'sha256', 'sha384', 'sha224', 'md5'}

In [146]:
#mystring = input('Enter String to hash: ')
# Assumes the default UTF-8
hash_object = hashlib.sha512(passwrdz.encode())
print(hash_object.hexdigest())


b5ba77af1f7bda735894e746a199acb1d2c836424da2fc46bebb55423dccbff871877a30fab77a31e47b0a29ea0154882e532e9a29b220a8f2958773313bbb2a

In [147]:
print(hash_object.name)


sha512

In [148]:
print(hash_object.block_size)


128

In [149]:
import subprocess

In [ ]:
tempchec = subprocess.check_output(["/opt/vc/bin/vcgencmd", "measure_temp"])

In [ ]:
print(float(tempchec.split(=)[1][:-3]))

In [ ]:
tempchec

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:
subprocess.check_output(o)

In [ ]:
s = subprocess.check_output([/opt/vc/bin/vcgencmd,measure_temp])
print(float(s.split(=)[1][:-3]))

In [152]:
import socket
socket.gethostbyname(socket.gethostname())


Out[152]:
'127.0.0.1'

In [153]:
socket.gethostname()


Out[153]:
'localhost'

In [154]:
import socket

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('8.8.8.8', 0))  # connecting to a UDP address doesn't send packets
local_ip_address = s.getsockname()[0]

In [155]:
local_ip_address


Out[155]:
'192.168.1.7'

In [156]:
s.getsockname()


Out[156]:
('192.168.1.7', 56084)

In [ ]:


In [157]:
socket.gethostbyaddr(socket.gethostname())


Out[157]:
('localhost', ['ip6-localhost', 'ip6-loopback'], ['::1'])

In [160]:
socket.getaddrinfo


Out[160]:
<function socket.getaddrinfo>

In [161]:
subup = subprocess.check_output(['uptime'])

In [162]:
loaspli = subup.split('load average: ')


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-162-156caad8bd35> in <module>()
----> 1 loaspli = subup.split('load average: ')

TypeError: Type str doesn't support the buffer API

In [ ]:


In [163]:
'''
import os
import subprocess

BAT_PATH = "/proc/acpi/battery/BAT%d"


def get_full_charge(batt_path):
    """Get the max capacity of the battery

    :param batt_path: The dir path to the battery (acpi) processes
    :type batt_path: string
    :returns: The max capacity of the battery
    :rtype: int
    """
    p1 = subprocess.Popen(["grep",
                            "last full capacity",
                            batt_path + "/info"],
                         stdout=subprocess.PIPE)
    p2 = subprocess.Popen(["awk",
                            "{print $4}"],
                            stdin=p1.stdout,
                            stdout=subprocess.PIPE)
    p1.stdout.close()
    return int(p2.communicate()[0])


def get_current_charge(batt_path):
    """Get the current capacity of the battery

    :param batt_path: The dir path to the battery (acpi) processes
    :type batt_path: string
    :returns: The current capacity of the battery
    :rtype: int
    """
    p1 = subprocess.Popen(["grep",
                            "remaining capacity",
                            batt_path + "/state"],
                         stdout=subprocess.PIPE)
    p2 = subprocess.Popen(["awk",
                            "{print $3}"],
                            stdin=p1.stdout,
                            stdout=subprocess.PIPE)
    p1.stdout.close()
    return int(p2.communicate()[0])


def guess_battery_path():
    """Gets the path of the battery (BAT0, BAT1...)

    :returns: The path to the battery acpi process information
    :rtype: string
    """
    i = 0
    while True:
        if os.path.exists(BAT_PATH % i):
            return BAT_PATH % i
        i += 1


def is_plugged(batt_path):
    """Returns a flag saying if the battery is plugged in or not

    :param batt_path: The dir path to the battery (acpi) processes
    :type batt_path: string
    :returns: A flag, true is plugged, false unplugged
    :rtype: bool
    """
    p = subprocess.Popen(["grep",
                            "charging state",
                            batt_path + "/state"],
                         stdout=subprocess.PIPE)
    return "discharging" not in p.communicate()[0]


def get_battery_percent(batt_path):
    """Calculates the percent of the battery based on the different data of
    the battery processes

    :param batt_path: The dir path to the battery (acpi) processes
    :type batt_path: string
    :returns: The percent translation of the battery total and current capacity
    :rtype: int
    """

    return get_current_charge(batt_path) * 100 / get_full_charge(batt_path)


def main():
    path = guess_battery_path()
    print("Current battery percent: %d" % get_battery_percent(path))
    print("Plugged in" if is_plugged(path) else "Not plugged in")

if __name__ == "__main__":
    main()
'''


Out[163]:
'\nimport os\nimport subprocess\n\nBAT_PATH = "/proc/acpi/battery/BAT%d"\n\n\ndef get_full_charge(batt_path):\n    """Get the max capacity of the battery\n\n    :param batt_path: The dir path to the battery (acpi) processes\n    :type batt_path: string\n    :returns: The max capacity of the battery\n    :rtype: int\n    """\n    p1 = subprocess.Popen(["grep",\n                            "last full capacity",\n                            batt_path + "/info"],\n                         stdout=subprocess.PIPE)\n    p2 = subprocess.Popen(["awk",\n                            "{print $4}"],\n                            stdin=p1.stdout,\n                            stdout=subprocess.PIPE)\n    p1.stdout.close()\n    return int(p2.communicate()[0])\n\n\ndef get_current_charge(batt_path):\n    """Get the current capacity of the battery\n\n    :param batt_path: The dir path to the battery (acpi) processes\n    :type batt_path: string\n    :returns: The current capacity of the battery\n    :rtype: int\n    """\n    p1 = subprocess.Popen(["grep",\n                            "remaining capacity",\n                            batt_path + "/state"],\n                         stdout=subprocess.PIPE)\n    p2 = subprocess.Popen(["awk",\n                            "{print $3}"],\n                            stdin=p1.stdout,\n                            stdout=subprocess.PIPE)\n    p1.stdout.close()\n    return int(p2.communicate()[0])\n\n\ndef guess_battery_path():\n    """Gets the path of the battery (BAT0, BAT1...)\n\n    :returns: The path to the battery acpi process information\n    :rtype: string\n    """\n    i = 0\n    while True:\n        if os.path.exists(BAT_PATH % i):\n            return BAT_PATH % i\n        i += 1\n\n\ndef is_plugged(batt_path):\n    """Returns a flag saying if the battery is plugged in or not\n\n    :param batt_path: The dir path to the battery (acpi) processes\n    :type batt_path: string\n    :returns: A flag, true is plugged, false unplugged\n    :rtype: bool\n    """\n    p = subprocess.Popen(["grep",\n                            "charging state",\n                            batt_path + "/state"],\n                         stdout=subprocess.PIPE)\n    return "discharging" not in p.communicate()[0]\n\n\ndef get_battery_percent(batt_path):\n    """Calculates the percent of the battery based on the different data of\n    the battery processes\n\n    :param batt_path: The dir path to the battery (acpi) processes\n    :type batt_path: string\n    :returns: The percent translation of the battery total and current capacity\n    :rtype: int\n    """\n\n    return get_current_charge(batt_path) * 100 / get_full_charge(batt_path)\n\n\ndef main():\n    path = guess_battery_path()\n    print("Current battery percent: %d" % get_battery_percent(path))\n    print("Plugged in" if is_plugged(path) else "Not plugged in")\n\nif __name__ == "__main__":\n    main()\n'

In [ ]:
s = subprocess.check_output([uptime])
    load_split = s.split(load average: )
    load_five = float(load_split[1].split(,)[1])
    up = load_split[0]
    up_pos = up.rfind(,,0,len(up)-4)
    up = up[:up_pos].split(up )[1]
    return ( up , load_five )

In [165]:
'''
import subprocess
import os
    
def get_ram():
    “Returns a tuple (total ram, available ram) in megabytes. See www.linuxatemyram.com”
    try:
        s = subprocess.check_output([“free”,”-m”])
        lines = s.split(‘\n’)
        return ( int(lines[1].split()[1]), int(lines[2].split()[3]) )
    except:
        return 0def get_process_count():
        “Returns the number of processes”
    try:
        s = subprocess.check_output([“ps”,”-e”])
        return len(s.split(‘\n’))
    except:
        return 0def get_up_stats():
    “Returns a tuple (uptime, 5 min load average)”
    try:
    s = subprocess.check_output([“uptime”])
    load_split = s.split(‘load average: ‘)
    load_five = float(load_split[1].split(‘,’)[1])
    up = load_split[0]
    up_pos = up.rfind(‘,’,0,len(up)-4)
    up = up[:up_pos].split(‘up ‘)[1]
    return ( up , load_five )
    except:
    return ( ” , 0 )def get_connections():
    “Returns the number of network connections”
    try:
    s = subprocess.check_output([“netstat”,”-tun”])
    return len([x for x in s.split() if x == ‘ESTABLISHED’])
    except:
    return 0def get_temperature():
    “Returns the temperature in degrees C”
    try:
    s = subprocess.check_output([“/opt/vc/bin/vcgencmd”,”measure_temp”])
    return float(s.split(‘=’)[1][:-3])
    except:
    return 0def get_ipaddress():
    “Returns the current IP address”
    arg=’ip route list’
    p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)
    data = p.communicate()
    split_data = data[0].split()
    ipaddr = split_data[split_data.index(‘src’)+1]
    return ipaddr

    def get_cpu_speed():
    “Returns the current CPU speed”
    f = os.popen(‘/opt/vc/bin/vcgencmd get_config arm_freq’)
    cpu = f.read()
    return cpu

    print ‘Free RAM: ‘+str(get_ram()[1])+’ (‘+str(get_ram()[0])+’)’
    print ‘Nr. of processes: ‘+str(get_process_count())
    print ‘Up time: ‘+get_up_stats()[0]
    print ‘Nr. of connections: ‘+str(get_connections())
    print ‘Temperature in C: ‘ +str(get_temperature())
    print ‘IP-address: ‘+get_ipaddress()
    print ‘CPU speed: ‘+str(get_cpu_speed())
'''


Out[165]:
'\nimport subprocess\nimport os\n    \ndef get_ram():\n    “Returns a tuple (total ram, available ram) in megabytes. See www.linuxatemyram.com”\n    try:\n        s = subprocess.check_output([“free”,”-m”])\n        lines = s.split(‘\n’)\n        return ( int(lines[1].split()[1]), int(lines[2].split()[3]) )\n    except:\n        return 0def get_process_count():\n        “Returns the number of processes”\n    try:\n        s = subprocess.check_output([“ps”,”-e”])\n        return len(s.split(‘\n’))\n    except:\n        return 0def get_up_stats():\n    “Returns a tuple (uptime, 5 min load average)”\n    try:\n    s = subprocess.check_output([“uptime”])\n    load_split = s.split(‘load average: ‘)\n    load_five = float(load_split[1].split(‘,’)[1])\n    up = load_split[0]\n    up_pos = up.rfind(‘,’,0,len(up)-4)\n    up = up[:up_pos].split(‘up ‘)[1]\n    return ( up , load_five )\n    except:\n    return ( ” , 0 )def get_connections():\n    “Returns the number of network connections”\n    try:\n    s = subprocess.check_output([“netstat”,”-tun”])\n    return len([x for x in s.split() if x == ‘ESTABLISHED’])\n    except:\n    return 0def get_temperature():\n    “Returns the temperature in degrees C”\n    try:\n    s = subprocess.check_output([“/opt/vc/bin/vcgencmd”,”measure_temp”])\n    return float(s.split(‘=’)[1][:-3])\n    except:\n    return 0def get_ipaddress():\n    “Returns the current IP address”\n    arg=’ip route list’\n    p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)\n    data = p.communicate()\n    split_data = data[0].split()\n    ipaddr = split_data[split_data.index(‘src’)+1]\n    return ipaddr\n\n    def get_cpu_speed():\n    “Returns the current CPU speed”\n    f = os.popen(‘/opt/vc/bin/vcgencmd get_config arm_freq’)\n    cpu = f.read()\n    return cpu\n\n    print ‘Free RAM: ‘+str(get_ram()[1])+’ (‘+str(get_ram()[0])+’)’\n    print ‘Nr. of processes: ‘+str(get_process_count())\n    print ‘Up time: ‘+get_up_stats()[0]\n    print ‘Nr. of connections: ‘+str(get_connections())\n    print ‘Temperature in C: ‘ +str(get_temperature())\n    print ‘IP-address: ‘+get_ipaddress()\n    print ‘CPU speed: ‘+str(get_cpu_speed())\n'

In [ ]:
#import ConfigParser

config = configparser.RawConfigParser()

# When adding sections or items, add them in the reverse order of
# how you want them to be displayed in the actual file.
# In addition, please note that using RawConfigParser's and the raw
# mode of ConfigParser's respective set functions, you can assign
# non-string values to keys internally, but will receive an error
# when attempting to write to a file or when you get it in non-raw
# mode. SafeConfigParser does not allow such assignments to take place.

config.add_section('userinfo')
config.set('userinfo', 'username', myusr)

config.set('userinfo', 'password', (hash_object.hexdigest()))
config.add_section('tempsetting')
config.set('tempsetting', 'drivertemphigh', sethightemp)
config.set('tempsetting', 'drivertemplow', setlowtemp)
config.set('tempsetting', 'passtemphigh', sethightemp)
config.set('tempsetting', 'passtemplow', setlowtemp)


config.add_section('dooropenstatus')

#config.set('doorstatus', 'drifronop', )
config.set('dooropenstatus', 'driversfront', dfstat)

config.set('dooropenstatus', 'passfront', pfstat)

config.set('dooropenstatus', 'passrear', prstat)

config.set('dooropenstatus', 'driversrear', drstat)

config.add_section('doorlockstatus')

config.set('doorlockstatus', 'driversfont', opddor)

config.set('doorlockstatus', 'passfront', opddor)

config.set('doorlockstatus', 'passrear', opddor)

config.set('doorlockstatus', 'driverrear', opddor)

config.add_section('chargestatus')

config.set('chargestatus', 'charging', 'complete')

config.set('chargestatus', "battcurrent", flsecur)

config.set('chargestatus', 'chargvolt', 2.5)

config.set('chargestatus', 'timecharge', 60)
#config.set('charges')

#Set Valet Mode
config.add_section('valetmode')

config.set('valetmode', 'valeton', valeton)

config.set('valetmode', 'timenow', (timnow))

config.set('valetmode', 'traveltime', 40)

config.set('valetmode', 'dayname', calcfulday[dayweekz])

config.set('valetmode', 'timehuman', timnow.humanize())

#config.set('templow', 'an_int', setlowtemp)
#config.set('drivefront', 'an_int', '3')
#config.set('passfront', 'baz', 'fun')
#config.set('passback', 'bar', 'Python')
#config.set('driveback', 'foo', '%(bar)s is %(baz)s!')

# Writing our configuration file to 'example.cfg'
with open('tesla.cfg', 'w') as configfile:
    config.write(configfile)

In [ ]:
crea = config.read

In [ ]:
with open('tesla.cfg', 'r') as configfile:
    print(config.read(configfile))

In [ ]:
temphi = 32
templo = 17

tempstr = ("{'temphi' :  " + str(temphi) + '}')

In [ ]:
templow = ("{'templow' :  " + str(templo) + '}')

In [ ]:
templow

{ "response": { "gui_distance_units": "mi/hr", "gui_temperature_units": "F", "gui_charge_rate_units": "mi/hr", "gui_24_hour_time": false, "gui_range_display": "Rated" } }tempstr

{ "response": { "charging_state": "Complete", // "Charging", ?? "charge_to_max_range": false, // current std/max-range setting "max_range_charge_counter": 0, "fast_charger_present": false, // connected to Supercharger? "battery_range": 239.02, // rated miles "est_battery_range": 155.79, // range estimated from recent driving "ideal_battery_range": 275.09, // ideal miles "battery_level": 91, // integer charge percentage "battery_current": -0.6, // current flowing into battery "charge_starting_range": null, "charge_starting_soc": null, "charger_voltage": 0, // only has value while charging "charger_pilot_current": 40, // max current allowed by charger & adapter "charger_actual_current": 0, // current actually being drawn "charger_power": 0, // kW (rounded down) of charger "time_to_full_charge": null, // valid only while charging "charge_rate": -1.0, // float mi/hr charging or -1 if not charging "charge_port_door_open": true } }

https://owner-api.teslamotors.com/api/1/vehicles/1/command/set_temps?driver_temp=23.7&passenger_temp=18.1

Returns the current temperature and climate control state.

var TEMP_HI = 32; var TEMP_LO = 17; function set_temperature( params, cb ) { var dtemp = params.dtemp; var ptemp = params.ptemp; var vid = params.id; var error = false;

//var temp_str = "";
if ( dtemp !== undefined && dtemp <= TEMP_HI && dtemp >= TEMP_LO) {
    //temp_str = 'driver_temp=' + dtemp; // change from string to JSON form data
} else {
    error = true;
}
// if no passenger temp is passed, the driver temp is also used as the passenger temp
if ( ptemp !== undefined && ptemp <= TEMP_HI && ptemp >= TEMP_LO) {
    //temp_str = temp_str +'&passenger_temp=' + ptemp; // change from string to JSON form data
} else if ( ptemp === undefined ) {
    ptemp = dtemp;
} else {
    error = true;
}
if (!error) {
    request( {
        method: 'POST',
        url: portal + '/vehicles/' + vid + '/command/set_temps',
        gzip: true,
        headers: http_header,
        form: {
            "driver_temp" : dtemp.toString(),
            "passenger_temp" : ptemp.toString(),
        }
    }, function (error, response, body) { 
        if ((!!error) || (response.statusCode !== 200)) return report(error, response, body, cb);
        try {
            var data = JSON.parse(body); 
            if (typeof cb == 'function') return cb( data.response );  
            else return true;
        } catch (err) {
            return report2('set_temps', body, cb);
        }
    });
} else {
    if (typeof cb == 'function') return cb( new Error('Invalid temperature setting (' + dtemp + 'C), Passenger (' + ptemp + 'C)'));  
    else return false;
}

} exports.set_temperature = set_temperature; exports.TEMP_HI = TEMP_HI; exports.TEMP_LO = TEMP_LO;

{ "response": { "df": false, // driver's side front door open "dr": false, // driver's side rear door open "pf": false, // passenger's side front door open "pr": false, // passenger's side rear door open "ft": false, // front trunk is open "rt": false, // rear trunk is open "car_verson": "1.19.42", // car firmware version "locked": true, // car is locked "sun_roof_installed": false, // panoramic roof is installed "sun_roof_state": "unknown", "sun_roof_percent_open": 0, // null if not installed "dark_rims": false, // gray rims installed "wheel_type": "Base19", // wheel type installed "has_spoiler": false, // spoiler is installed "roof_color": "Colored", // "None" for panoramic roof "perf_config": "Base" } }

{ "response": { "charging_state": "Complete", // "Charging", ?? "charge_to_max_range": false, // current std/max-range setting "max_range_charge_counter": 0, "fast_charger_present": false, // connected to Supercharger? "battery_range": 239.02, // rated miles "est_battery_range": 155.79, // range estimated from recent driving "ideal_battery_range": 275.09, // ideal miles "battery_level": 91, // integer charge percentage "battery_current": -0.6, // current flowing into battery "charge_starting_range": null, "charge_starting_soc": null, "charger_voltage": 0, // only has value while charging "charger_pilot_current": 40, // max current allowed by charger & adapter "charger_actual_current": 0, // current actually being drawn "charger_power": 0, // kW (rounded down) of charger "time_to_full_charge": null, // valid only while charging "charge_rate": -1.0, // float mi/hr charging or -1 if not charging "charge_port_door_open": true } }

More car info

What music is being played.

Is my car unlocked? Unlock when device within certain distance.

Checks that all the doors are shut

https://owner-api.teslamotors.com/api/1/vehicles/vehicle_id/command/door_unlock

https://owner-api.teslamotors.com/api/1/vehicles/vehicle_id/command/door_lock


In [166]:
for doorq in doorquen:
    if doorq == True:
        print('Warning Door Open')

In [167]:
for doorq in doorquen:
    #print(doorq)
    if doorq == False:
        #for inz in range():
        print('Warning Door Close')


Warning Door Close
Warning Door Close
Warning Door Close
Warning Door Close

In [ ]:


In [168]:
mydict['response']['dr']


Out[168]:
False

In [169]:
mydict['response']['pf']


Out[169]:
False

In [170]:
mydict['response']['pr']


Out[170]:
False

In [172]:
def testdoorlock():
    assert mydict['response']['locked'] == 'True'
    
def testdoorunlock():
    assert mydict['response']['locked'] == 'False'

In [ ]:


In [173]:
mydict['response']['locked']


Out[173]:
True

In [174]:
mydict['response']['df']


Out[174]:
False

In [ ]:


In [175]:
mydict['response']['dr']


Out[175]:
False

In [176]:
mydict['response']['pf']


Out[176]:
False

In [177]:
mydict['response']['pr']


Out[177]:
False

In [178]:
vechj = open('/home/wcm/git/vech.json', 'r')

In [179]:
rdvechj = vechj.read()

In [180]:
rdvechj


Out[180]:
'{\n  "response": [\n    {\n      "color": null,\n      "display_name": null,\n      "id": 321,\n      "option_codes": "MS01,RENA,TM00,DRLH,PF00,BT85,PBCW,RFPO,WT19,IBMB,IDPB,TR00,SU01,SC01,TP01,AU01,CH00,HP00,PA00,PS00,AD02,X020,X025,X001,X003,X007,X011,X013",\n      "user_id": 123,\n      "vehicle_id": 1234567890,\n      "vin": "5YJSA1CN5CFP01657",\n      "tokens": [\n        "x",\n        "x"\n      ],\n      "state": "online"\n    }\n  ],\n  "count": 1\n}\n'

In [181]:
json.loads(rdvechj)


Out[181]:
{'count': 1,
 'response': [{'color': None,
   'display_name': None,
   'id': 321,
   'option_codes': 'MS01,RENA,TM00,DRLH,PF00,BT85,PBCW,RFPO,WT19,IBMB,IDPB,TR00,SU01,SC01,TP01,AU01,CH00,HP00,PA00,PS00,AD02,X020,X025,X001,X003,X007,X011,X013',
   'state': 'online',
   'tokens': ['x', 'x'],
   'user_id': 123,
   'vehicle_id': 1234567890,
   'vin': '5YJSA1CN5CFP01657'}]}