tronikos / opower

A Python library for getting historical and forecasted usage/cost from utilities that use opower.com such as PG&E
Apache License 2.0
53 stars 49 forks source link

New provider: Southern Maryland Electric COoperative (SMECO) #55

Open sorendayton opened 7 months ago

sorendayton commented 7 months ago

Hi,

My provider, the Southern Maryland Electric COoperative (SMECO) uses OPOWER.

I looked through the source code for some of the other providers, and it looks like the user isn't directly using the OPOWER domain (although I am not quite tracking the subdomain use), but they are going through the utility's main website.

For example, when I am logged in, I am at a URL like:

https://dss-smcc.opower.com/dss/energy/use-details?ou-data-browser=/neighbors/electricity/year/2022-11-19?accountUuid%XXXXXXX

I have a screenshot below.

What would be the closest code to start with in trying to create something for this provider? Thanks!

Screenshot 2023-11-10 at 10 54 28 AM
tronikos commented 7 months ago

You best tool would be the web developer tools, network tab, in your browser. Navigate to the login page of your utility website and try to identify what endpoints you need to replicate in Python. Yours seems to use the opower domain itself which I haven't seen before. It posts to https://dss-smcc.opower.com/webcenter/edge/apis/identity-management-v1/cws/v1/smcc/login the following:

username: test
password: test
rememberMe: true

which is easy to replicate in Python. After that without access to your account you are on your own to figure out how to get the access token for opower. For your case since you are logging in directly to opower you likely don't need any access token and just the session cookie would be enough.

disforw commented 6 months ago

What does an access token look like? Is it named? My response has quite a few good looking options for an auth token

tronikos commented 6 months ago

If yours is using an access token you should be able to tell by the authorization HTTP header in requests to opower.com It will look like https://github.com/tronikos/opower/blob/addb89460e6b578250ee5ec6ca00a5f2a40b5b0d/src/opower/opower.py#L493C22-L493C68 e.g. authorization: Bearer <access-token>

If yours is using SAML you can tell if you see a request to opower.com/sp/ACS.saml2 https://github.com/tronikos/opower/blob/addb89460e6b578250ee5ec6ca00a5f2a40b5b0d/src/opower/utilities/helpers.py#L30C34-L30C57

disforw commented 6 months ago

Sweet! I found it. https://login.nationalgrid.com/loginnationalgridus.onmicrosoft.com/b2c_1a_nationalgrid_convert_merge_signin/oauth2/v2.0/token returns the access_token. But theres also a “scope url” of https://login.nationalgridus.com/opower-uwp/opower Looks the body of the request includes: signInName=xxx@email.com&password=xxxxxx&Signin-forgotPassword=FORGOT_PASSWORD_FALSE&request_type=RESPONSE

the opower subdomain after my succeeded login is: ngli.opower.com It looks like NationalGrid has many subdomains though for different areas.

what provider would you recommend I copy?

tronikos commented 6 months ago

Whichever you want.

sorendayton commented 6 months ago

I would love to compare notes as I develop mine. I have gotten distracted by other stuff, but this is something I want to do in the new year.

On Mon, Dec 25, 2023 at 11:42 AM disforw @.***> wrote:

Sweet! I found it.

https://login.nationalgrid.com/loginnationalgridus.onmicrosoft.com/b2c_1a_nationalgrid_convert_merge_signin/oauth2/v2.0/token returns the access_token. But theres also a “scope url” of https://login.nationalgridus.com/opower-uwp/opower Looks the body of the request includes: @.*** &password=xxxxxx&Signin-forgotPassword=FORGOT_PASSWORD_FALSE&request_type=RESPONSE

the opower subdomain after my succeeded login is: ngli.opower.com It looks like NationalGrid has many subdomains though for different areas.

what provider would you recommend I copy?

— Reply to this email directly, view it on GitHub https://github.com/tronikos/opower/issues/55#issuecomment-1869050464, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4MAX2NLY7YJDTD2L6PKWW3YLGUHJAVCNFSM6AAAAAA7GMBD6CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRZGA2TANBWGQ . You are receiving this because you authored the thread.Message ID: @.***>

disforw commented 6 months ago

@sorendayton awesome, I’m going to post my findings under a different opened thread that relates to my provider. There are othere people there that may be able to add some insight for me. Check out #45

atx32 commented 6 months ago

@sorendayton, City of Austin Utilities also uses Opower with a similar domain: dss-coa.opower.com I hope that any progress you make with your provider can help me as well.

sorendayton commented 6 months ago

A whole bunch more just dropped. I want to get back to this in the new year. It looks like a lot of the additions are part of AEP, but I want to experiment some.

On Wed, Jan 3, 2024 at 9:03 PM atx32 @.***> wrote:

@sorendayton https://github.com/sorendayton, City of Austin Utilities also uses Opower with a similar domain: dss-coa.opower.com I hope that any progress you make with your provider can help me as well.

— Reply to this email directly, view it on GitHub https://github.com/tronikos/opower/issues/55#issuecomment-1876208640, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4MAX2M5QPR6DNZD63ZSBO3YMYEVTAVCNFSM6AAAAAA7GMBD6CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZWGIYDQNRUGA . You are receiving this because you were mentioned.Message ID: @.***>

max2697 commented 5 months ago

Cool, another one DSS Opower provider. Hope my changes could help with this one too. Auth flow could be different but I hope that portals are similar.

tronikos commented 3 months ago

@sorendayton, @max2697 refers to their #64. City of Austin Utilities also uses DSS so their implementation should hopefully help you.