Tesla Integration to Query Status and Send Commands to Your Car

works fine for me.. you need to set it on the device not the app

its off on the devices, I even tried turning it on and off again, it still logs. I cant see the lines in the driver code that honor the debug preference.

post a pictuer of the lines you are talking about.

the debug on off pref gets set here

def logsOff() {
    log.info "${app.label} - Debug logging auto disabled"
    app?.updateSetting("logEnable",[value:"false",type:"bool"])
}

But the logEnable setting string appears nowhere in the code. Its never checked.

Throughout the driver and app code, the code uses log.debug along with log.info and log.warn which are the system log functions that dont honor any preference setting that disables logging afaik. im no groovy expert but shouldn't logging be handled by a private function that checks the preference setting? See this thread Toggle Logging in an app

logs off is called automatically from the system (i believe), and it doesn't matter anyway just turn the logs off manually if you don't like it.. it does the same thing..

one i did not write that code.. if you don't like it change it

two there are like 4 lines coming out when it runs.. -

ev:4642020-12-10 11:26:51.193 pm debugprocessData: [state:online, motion:inactive, speed:0, vin:5xxxxxx7593, thermostatMode:off, chargeState:[battery:80, batteryRange:239.49, chargingState:Complete], driveState:[latitude:42.908381, longitude:-71.398105, method:wgs, heading:93, lastUpdateTime:Thu Dec 10 23:26:39 EST 2020], vehicleState:[presence:present, lock:locked, odometer:15383.881989], climateState:[temperature:39.38, thermostatSetpoint:69.08]]

app:4892020-12-10 11:26:50.438 pm debugauthorizedHttpRequest GET /api/1/vehicles/76/vehicle_data attempt 0

dev:4642020-12-10 11:26:49.885 pm debugExecuting 'refresh'

and the debug is NOT set there it is set here.. just change the code if you dont like it

preferences
{
   input "refreshTime", "enum", title: "How often to refresh?",options: ["Disabled","1-Hour", "30-Minutes", "15-Minutes", "10-Minutes", "5-Minutes"],  required: true, defaultValue: "15-Minutes"
   input "AllowSleep", "bool", title: "Schedule a time to disable/reenable to allow the car to sleep?", required: true, defaultValue: false
   input "fromTime", "time", title: "From", required:false, width: 6, submitOnChange:true
   input "toTime", "time", title: "To", required:false, width: 6 
   input "debug", "bool", title: "Turn on Debug Logging?", required:true, defaultValue: false   
}

}

the default is false, so you must have turned it on at some point, so turn it back off

There's a variable available to the Driver called "debug" which is the setting you picked, on or off.

Every time you click Save Preferences (in a driver) the update() method is called. Inside the update() method a test of that variable can be made and if it's true, then a 30 minute timer can be started. At the end of 30 minutes, logsOff() is called.

The critical part is getting the spelling right :slight_smile:

If the Input line has "debug" then throughout the rest of the driver, a test for 'debug" must be made. The Example I wrote about has a different spelling. I wrote "debugOutput" because that's how it was spelled in the Hubitat driver I took it from. "logsOff" will be found exactly twice in my example. Once in the timer line:

if (debugOutput) runIn(1800,logsOff)

and again, to define the method. --> def logsOff(){

I guess I was expecting the package maintainer to care about things in his package not working right. Call me crazy...

i dont agree that it is not working right.. so sue me.. i like a couple of log lines to come out when it runs. if you dont change it for your own needs.. i dont like your attitude about it either.

there are plenty of apps and device handlers (even built in ones) that even with debug off put out a few lines in the log.. so this is by no means a hard and fast rule that you cannot have anything come out. i asked you to post what lines you didnt like and i may have taken a look till you started getting sanctimonous and posting links to stuff telling me how I MUST code the device handler.. as i said if you can read code you can change it yourself.. i was happy enough to make changes for myself and share with others to a device handler i did not write. But if this is the thanks i get i may just stop sharing my work.

1 Like

@kahn-hubitat I had some time this past weekend so I decided to try making some updates to your App and Driver to include some more Tesla attributes (outside temp, minutes_to_full_charge, and seat heater status. I've got them all reporting correctly which is great. Reading API data was the easy part as I was able to make sense of the App and Driver code. My next goal is to be able to actually send API commands to the car like turning the seat heaters from off to level 1-3. That appears to be more challenging but as time permits I'm willing to give it try. Please let me know if you want me to send you any of the code that has already been completed so you can update the master in Github for others to benefit. I don't have Github account so if you want the code I will just store it on Google Drive and share out. Let me know how you want to proceed. BTW the Thermostat tile is able to turn the Climate control off and Auto fine but changing the temp does not work which I'm guessing is because the Tile has Heat up/down and Cool up/down but the tesla API only has one temp setting so we need to map the tile controls to the actual API command. That is lower priority right now as I'm working around it by using Virtual Thermostat and setting a rule to update Telsa Set Thermostat Setpoint = Virtual SetTemp but it would be cool if Thermostat tile worked mapped to Tesla driver without the need for rule.

sounds good i will take a look and try to integrate what you have done.

1 Like

@kahn-hubitat here you go

Driver: https://docs.google.com/document/d/1r32AaG7orzeZD8iuuEx-dTQJjNHO0XLHQk8gzxWMCf4/edit?usp=sharing

App: https://docs.google.com/document/d/1g5fgbkCtnJsJEwzqbr_nCNm2DSZsRe0-3GHtuyQn64c/edit?usp=sharing

acess denied.. take a couple of days skiing tomorrow unless too crowded.. thanks for the enhancements..

1 Like

I approved your access request. Enjoy the fresh snow

1 Like

Hi. just got my Hubitat. Can I try these please?
just requested for access

@kahn-hubitat I had the day off work so added several more attributes and commands to the App & Driver (Sentry Mode, Seat Heaters, Vent) Basically key commands that I can use to write Hubitat Rule Engines e.g. If car is at home and HSM set to Armed than turn Sentry Mode On. If inside temp of car is > 100 than Vent windows, etc. I've also got this integrated with my Amazon Echo so I can now say "Alexa prepare car for departure" and climate is activated and once temp is reached Alexa announces "Your Tesla is at desired temperature and ready for departure"

The updated App and drivers are available at:

Hopefully you post this code to your GitHub so others can benefit.

It has been years since I wrote any code so this was a fun project to leverage off the original work done by @trentfoley and you.

Here is what what people should see after installing this version of the app/driver

My next goal would be to update the Seat Heater commands to be a drop down menu so you don't have to remember what number each seat is.

1 Like

See below for link to code that I've made public viewable on Google Drive

merry Christmas. brilliant
thank you
is it possible if have the temp to be displayed in celsius please?

i integrated your code for windows, sentry etc status

Thanks.

I also added a new option in the driver to select either F or C and display the current temp and setpoint based on that value.. Also when setting the temp i use that value to decide on conversion.

I did not copy verbatim but integrated changes and added the new temp scale changes. So let me know if you see any issues.

Also converted temp to integer before setting the setpoint.
change in the github. and also via hubitat package manager..

1 Like

slight change .. add unit to sendevent for temp so it displays on dashboard either F or C

1 Like

Thanks everything is working great with the new version and I'm sure the Tesla users outside the U.S. appreciate the option to display F or C. Next week I might find time to create a drop down menu list for the seat heaters. The only other enhancement I can think of is updating the driver to take full advantage of the Thermostat Dashboard Template to avoid having to create a virtual Thermostat driver and rule to fully control the Tesla climate and get proper status being returned to Dashboard. Again, low priority for me as I've got virtual drivers and rules create to get around all this.