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

v0.7.3 - Cloud Mode Setup #62

Merged
merged 4 commits into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add authpath to cloud mode setup
  • Loading branch information
mcbirse committed Dec 31, 2023
commit d016e9f34d52ff2cddb15aa697303b28cdc42774
2 changes: 1 addition & 1 deletion proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.10-alpine
WORKDIR /app
RUN pip3 install pypowerwall==0.7.2 bs4
RUN pip3 install pypowerwall==0.7.3 bs4
COPY . .
CMD ["python3", "server.py"]
EXPOSE 8675
2 changes: 1 addition & 1 deletion pypowerwall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
from . import tesla_pb2 # Protobuf definition for vitals
from . import cloud # Tesla Cloud API

version_tuple = (0, 7, 2)
version_tuple = (0, 7, 3)
version = __version__ = '%d.%d.%d' % version_tuple
__author__ = 'jasonacox'

Expand Down
4 changes: 3 additions & 1 deletion pypowerwall/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
# Modules
import pypowerwall
import sys
import os
from . import scan
from . import cloud

# Global Variables
AUTHFILE = ".pypowerwall.auth"
authpath = os.getenv("PW_AUTH_PATH", "")
timeout = 1.0
state = 0
color = True
Expand Down Expand Up @@ -46,7 +48,7 @@
if(state == 1):
print("pyPowerwall [%s] - Cloud Mode Setup\n" % (pypowerwall.version))
# Run Setup
c = cloud.TeslaCloud(None)
c = cloud.TeslaCloud(None, authpath=authpath)
if c.setup():
print("Setup Complete. Auth file %s ready to use." % (AUTHFILE))
else:
Expand Down
20 changes: 10 additions & 10 deletions pypowerwall/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
SITE_CONFIG_TTL = 59 # Site config cache TTL in seconds

# pypowerwall cloud module version
version_tuple = (0, 0, 3)
version_tuple = (0, 0, 4)
version = __version__ = '%d.%d.%d' % version_tuple
__author__ = 'jasonacox'

Expand Down Expand Up @@ -813,9 +813,9 @@ def setup(self):
print("-" * 60)
tuser = ""
# Check for .pypowerwall.auth file
if os.path.isfile(AUTHFILE):
print(" Found existing Tesla Cloud setup file ({})".format(AUTHFILE))
with open(AUTHFILE) as json_file:
if os.path.isfile(self.authfile):
print(" Found existing Tesla Cloud setup file ({})".format(self.authfile))
with open(self.authfile) as json_file:
try:
data = json.load(json_file)
tuser = list(data.keys())[0]
Expand All @@ -824,7 +824,7 @@ def setup(self):
response = input("\n Overwrite existing file? [y/N]: ").strip()
if response.lower() == "y":
tuser = ""
os.remove(AUTHFILE)
os.remove(self.authfile)
else:
self.email = tuser
except Exception as err:
Expand All @@ -844,7 +844,7 @@ def setup(self):
self.email = tuser

# Create Tesla instance
tesla = Tesla(self.email, cache_file=AUTHFILE)
tesla = Tesla(self.email, cache_file=self.authfile)

if not tesla.authorized:
# Login to Tesla account and cache token
Expand All @@ -860,7 +860,7 @@ def setup(self):
print("\nAfter login, paste the URL of the 'Page Not Found' webpage below.\n")

tesla.close()
tesla = Tesla(self.email, state=state, code_verifier=code_verifier, cache_file=AUTHFILE)
tesla = Tesla(self.email, state=state, code_verifier=code_verifier, cache_file=self.authfile)

if not tesla.authorized:
try:
Expand All @@ -885,8 +885,8 @@ def setup(self):
print("-"*60)

# Check for existing site file
if os.path.isfile(SITEFILE):
with open(SITEFILE) as file:
if os.path.isfile(self.sitefile):
with open(self.sitefile) as file:
try:
self.siteid = int(file.read())
except:
Expand Down Expand Up @@ -922,7 +922,7 @@ def setup(self):
self.site = sites[self.siteindex]
print("\nSelected site %d - %s (%s)" % (self.siteindex+1, sites[self.siteindex]["site_name"], self.siteid))
# Write the site id to the sitefile
with open(SITEFILE, "w") as f:
with open(self.sitefile, "w") as f:
f.write(str(self.siteid))

return True
Expand Down