Skip to content

Commit 63ff80c

Browse files
Merge pull request #7 from thebradleysanders/thebradleysanders-patch-1
Update pyEvergy.py
2 parents 4f8535e + c848cea commit 63ff80c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

custom_components/evergy/pyEvergy.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, username, password):
4141
self.login_url = "https://www.evergy.com/log-in"
4242
self.logout_url = "https://www.evergy.com/logout"
4343
self.account_summary_url = (
44-
"https://www.evergy.com/ma/my-account/account-summary"
44+
"https://www.evergy.com/sc-api/account/getaccountpremiseselector?isWidgetPage=false&hasNoSelector=false"
4545
)
4646
self.account_dashboard_url = "https://www.evergy.com/api/account/{accountNum}/dashboard/current"
4747
self.usageDataUrl = "https://www.evergy.com/api/report/usage/{premise_id}?interval={interval}&from={start}&to={end}"
@@ -63,12 +63,11 @@ def login(self):
6363
)
6464
logging.debug("Login response: " + str(r.status_code))
6565
r = self.session.get(self.account_summary_url)
66-
soup = BeautifulSoup(r.text, "html.parser")
67-
account_data = soup.find_all("script", id="account-landing-data")
66+
account_data = r.json()
6867
if len(account_data) == 0:
6968
self.logged_in = False
7069
else:
71-
self.account_number = json.loads(account_data[0].contents[0])["accountNumber"]
70+
self.account_number = account_data[0]['accountNumber']
7271
self.dashboard_data = self.session.get(
7372
self.account_dashboard_url.format(accountNum=self.account_number)
7473
).json()

0 commit comments

Comments
 (0)