Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commands Hanging On New Ubuntu Installation #78

Closed
Haselmaier opened this issue May 25, 2022 · 3 comments
Closed

Commands Hanging On New Ubuntu Installation #78

Haselmaier opened this issue May 25, 2022 · 3 comments

Comments

@Haselmaier
Copy link

I've been using Teslapy for about 6 months. Awesome. I use it to adjust charging based on solar panel output.

I recently built up an Ubuntu machine. The code hangs when executing a command. See the attached output when I stop the code. This code runs on other machines (e.g. Windows) but won't run on this Ubuntu machine.

All the packages identified in requirements.txt seem to be up to minimum versions required.

Any guidance on what I need to do to rectify this?

Thanks.

Jim Haselmaier
Suncatcher

@tdorssers
Copy link
Owner

Are you using different versions of TeslaPy on your machines? This requests exception probably occurs because the Tesla instance is accessed outside of the context manager. Recent versions of TeslaPy destroy the connection adapter when the context manager exits.

@Haselmaier
Copy link
Author

Haselmaier commented May 25, 2022

Thanks Tim.

The other machines were on 2.2.0 and the Ubuntu machine was running 2.5.0.

I put 2.2.0 on the Ubuntu machine and all seems fine now.

Thanks so much!

Jim

@tdorssers
Copy link
Owner

tdorssers commented May 26, 2022

Maybe these two examples help. A context manager automatically closes the requests session. TeslaPy 2.5.0 also closes the connection adapter. This has been done because the requests module doesn't reconnect on network failures once it has been closed. So for long running scripts TeslaPy 2.5.0 is the recommended version.

With context manager:

with teslapy.Tesla('elon@tesla.com') as tesla:
	vehicles = tesla.vehicle_list()
	vehicles[0].command('FLASH_LIGHTS')
vehicles[0].command('FLASH_LIGHTS')  # Causes exception

Without context manager:

tesla = teslapy.Tesla('elon@tesla.com')
vehicles = tesla.vehicle_list()
vehicles[0].command('FLASH_LIGHTS')
tesla.close()
vehicles[0].command('FLASH_LIGHTS')  # Causes exception

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

No branches or pull requests

2 participants