Replies: 2 comments
-
I would not do this:
Too many API calls in a short time period may trigger the Tesla WAF and it will rate limit or block you out. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the advice
I run the loop once a minute and call the API about 5 times each loop. It would run for maybe an hour before I got the hiccup. I don’t know if any exceptions are raised, or how to check, the code keeps running, just won’t respond to commands I send anymore.
I tried your code example so that should reduce the number of iterations on the API, I had tried it before but musta gotten the syntax wrong. I looked for get_vehicle_summary() in your example code and couldn’t find it either, but it sounds like a great way to keep tabs on the car when I am NOT asking it to start charging. I added it to my code and got it working-ish, but I don’t understand how to call available().
I am NOT a programmer, but have been forced to take it up as I have been unable to get a commercial solution. I got this working thru strict cut and paste w/o understanding what I am doing. So when I say what’s the syntax for available() I really mean how do I use it in a sentence. You say what it does, but not how to use it, is the optional parameter stuck in the () brackets? Or maybe [] brackets after the invocation?
Wish I knew what was important, I feel like those guys, the Pakleds in Star Trek, “We look for things to make us go”
Thanks SO MUCH for your help
-Randy
… On Feb 3, 2022, at 11:21 PM, Tim Dorssers ***@***.***> wrote:
I would not do this: if vehicles[0].get_vehicle_data()['charge_state']['charging_state'] == "Charging":, because each time you use get_vehicle_data() the API is called. Its better to do something like, in case you read more then one field from the vehicle dict:
data = vehicles[0].get_vehicle_data()
if data['charge_state']['charging_state'] == "Charging":
Too many API calls in a short time period may trigger the Tesla WAF and it will rate limit or block you out.
After how long a time does the connection drop? Are there any exceptions raised?
The available() method is used to quickly check if the car is online and it takes one optional parameter. This parameter specifies the age in seconds of the vehicle data that is allowed before running get_vehicle_summary() to refresh the state of the car.
—
Reply to this email directly, view it on GitHub <#57 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AFQ7F52X6GMGP65NFKSA6MLUZN5A5ANCNFSM5NQTNNLA>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.
|
Beta Was this translation helpful? Give feedback.
-
I am having issues with a script I have written that uses info from my solar and grid to determine if there is free power to charge my Tesla and cranks up the charging when there is. If my script loops for some time, each minute checking the charging status with the command:
Try:
if vehicles[0].get_vehicle_data()['charge_state']['charging_state'] == "Charging":
I will, after a long time, get no info from the car, even if the car is actively charging.
Is there a superior command above this command that will not drop the connection to the car? Maybe Available()? I see it's a function, but none of your example code seems to use it so I am having difficulty figuring out the syntax.
I even try
vehicles[0].sync_wake_up()
but once the connection is no longer returning data, even this statement won't do anything. The only fix I find is quitting the app and relaunching.
Beta Was this translation helpful? Give feedback.
All reactions