Skip to content

Fix stopAskingToStartCharging behaviour #589

Merged
ngardiner merged 4 commits intongardiner:mainfrom
RichieB2B:fix-starting
Jan 9, 2025
Merged

Fix stopAskingToStartCharging behaviour #589
ngardiner merged 4 commits intongardiner:mainfrom
RichieB2B:fix-starting

Conversation

@RichieB2B
Copy link
Copy Markdown

See discussion in #575

2nd fix: set stopAskingToStartCharging when a vehicle is not at home so it is allowed to sleep remotely.

Copy link
Copy Markdown
Owner

@ngardiner ngardiner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, agree with the direction re minimising unnecessary API calls

@MikeBishop
Copy link
Copy Markdown
Collaborator

Does setting this while not at home produce an actual behavior change? The lines as originally written will skip any car that's not at home already. Though since the car will attempt to charge when plugged in anyway, I suspect we don't lose anything by setting it here, either.

@RichieB2B
Copy link
Copy Markdown
Author

The change in behavior is that TWCManager stops trying to start a charge a car that is not at home. Right now it keeps polling the vehicle_data every minute, determines the location is not home, skips the car. Repeat.

I don't expect a change in the actual charges because stopAskingToStartCharging is reset when a car arrives home. And the charge will start when plugging in as you mentioned.

@RichieB2B
Copy link
Copy Markdown
Author

3rd fix: set vehicle lastErrorTime at 429 in wakeVehicle()
4th fix: increase cacheTime to 300 for vehicle_data

Comment thread lib/TWCManager/Vehicle/TeslaAPI.py
@MikeBishop
Copy link
Copy Markdown
Collaborator

This may interact with #571's statusDeferral, which reduces vehicle status checking to every hour if it's far away from home, and every half-hour if it's nearby but not actually driving. That said, assuming the vehicle will get plugged in upon arrival home and trigger a location update, completely muting vehicle_data checks when the car is away from home may be the more conservative solution.

@RichieB2B
Copy link
Copy Markdown
Author

RichieB2B commented Jun 13, 2024

5th fix: set carApiLastErrorTime at 429 in get_car_api()

Hopefully this all is enough to stay within the free API tier limits.

@RichieB2B
Copy link
Copy Markdown
Author

That said, assuming the vehicle will get plugged in upon arrival home and trigger a location update, completely muting vehicle_data checks when the car is away from home may be the more conservative solution.

I'm running the code in this PR since yesterday. My wife's MS started charging upon plugging in, my MY did not. Had to manually start the charge. Not good. The dashboard said "charging stopped" but there was no stop command in the TWCManager logs (simply no session start either). I'll keep testing this code.. my understanding is that a Tesla will always just start charing when plugged into a live charger. Might be a fluke. Otherwise #571 is a nice solution indeed.

Comment thread lib/TWCManager/Vehicle/TeslaAPI.py Outdated
Comment thread lib/TWCManager/Vehicle/TeslaAPI.py Outdated
@RichieB2B
Copy link
Copy Markdown
Author

RichieB2B commented Jan 9, 2025

@ngardiner Can you merge this? Without this patch, my vehicle_data requests go through the roof which becomes expensive after 2025-02-01
image

@ngardiner ngardiner merged commit 851b53f into ngardiner:main Jan 9, 2025
@RichieB2B RichieB2B deleted the fix-starting branch January 9, 2025 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants