Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Could not identify a smart meter on your account with gateway access #10

Closed
slappula opened this issue Aug 23, 2021 · 8 comments
Closed
Assignees
Milestone

Comments

@slappula
Copy link

I'm receiving this message in the logs:

Could not identify a smart meter on your account with gateway access

Any idea on how to address this one? Version 0.0.6. Details from log:

_This error originated from a custom integration.

Logger: custom_components.duke_energy_gateway
Source: custom_components/duke_energy_gateway/init.py:82
Integration: Duke Energy Gateway (documentation, issues)
First occurred: 10:09:06 AM (2 occurrences)
Last logged: 10:11:53 AM

Could not identify a smart meter on your account with gateway access._

@mjmeli
Copy link
Owner

mjmeli commented Aug 23, 2021

I would guess there is some difference in your API responses from mine that is causing it to get filtered out. The code tries to filter down to supported meters but the logic could be bad

account_list = await client.get_account_list()
for account in account_list:
try:
_LOGGER.debug(f"Checking account {account.src_acct_id} for gateway")
account_details = await client.get_account_details(
account.src_acct_id, account.src_sys_cd
)
for meter in account_details.meter_infos:
_LOGGER.debug(f"Checking meter {meter.serial_num} for gateway")
if (
meter.meter_type.upper() == "ELECTRIC"
and meter.is_certified_smart_meter
):
client.select_meter(meter.serial_num, meter.agreement_active_date)
gw_status = await client.get_gateway_status()
if gw_status is not None:
_LOGGER.debug(
f"Found meter {meter.serial_num} with gateway {gw_status.id}"
)
selected_meter = meter
selected_gateway = gw_status
break

A couple of ideas to help track it down

  1. Enable debug logging for the integration by adding below to your configuration.yaml. Then in your full home-assistant.log file you will see some logs tagged custom_components.duke_energy_gateway. Unfortunately it might not give much insight because it only logs happy path right now.
logger:
  default: info
  logs:
    custom_components.duke_energy_gateway: debug
  1. If you are able to, you could run the example.py script in the API library (https://github.com/mjmeli/pyduke-energy/blob/main/example.py). This will dump out the API payloads so it might be more straightforward and insightful. Instructions are in the repo README.

@slappula
Copy link
Author

Thanks for the quick reply! Also, I forgot to say earlier- thanks for developing this!

I turned on the logging and I see this:

2021-08-23 14:15:22 DEBUG (MainThread) [custom_components.duke_energy_gateway] Setup Duke Energy API client
2021-08-23 14:15:23 DEBUG (MainThread) [custom_components.duke_energy_gateway] Checking account 9100xxxxxx for gateway
2021-08-23 14:15:27 DEBUG (MainThread) [custom_components.duke_energy_gateway] Failed to find meter on account 910021843313: Request failed with unexpected error [https://cust-api.duke-energy.com/gep/v2/auth/account-details]: 500, message='Internal Server Error', url=URL('https://cust-api.duke-energy.com/gep/v2/auth/account-details?email=dummy@dummy.com&srcSysCd=ISU&srcAcctId=9100xxxxxx')
2021-08-23 14:15:27 ERROR (MainThread) [custom_components.duke_energy_gateway] Could not identify a smart meter on your account with gateway access.

My Python install is borked (or I'm not running something right). Either way- I can't get example.py to run. I tried to use the URI from the logs and run it via Postman but I'm getting an authentication error. Is there a way to do that? If yes, what auth method would I use that would allow me to plug in my email address/password?

@mjmeli
Copy link
Owner

mjmeli commented Aug 23, 2021

At first glance the only difference I notice is that your srcSysCd value is different. I'm not sure what that actually is but mine is "CIM" and yours is "ISU".

And just to make sure, that account number matches the account number on the account with the gateway?

You can definitely query these via Postman.

To do authentication, you need to POST to https://cust-api.duke-energy.com/gep/v2/auth/oauth2/token with header Authorization: Basic UzdmNXFQR2MwcnpVZkJmcVNPak9ycGczZWtSZ3ZHSng6bW1nS2pyY1RQRHptOERtVw== (this is a hard-coded value in the app) and a request body as x-www-form-encoded of grant_type=password (the actual word password, not your password), username={email}, and password={password}.

That will return an access_token which you use for the other call with as a Bearer token. You might also save the cdp_internal_user_id value.

To get your sysSysCd value, you can GET to https://cust-api.duke-energy.com/gep/v2/auth/account-list using that access_token and parameters email={email} and internalUserId={cdp_internal_user_id}

Maybe there is something in your responses that gives insight into what is different between us.

@mjmeli
Copy link
Owner

mjmeli commented Aug 23, 2021

Here's something to try if you get Postman up and running

On that account-details call that is logged, you can see there are 3 parameters: email, srcSysCd, and srcAcctId.

However I suspect there are 2 more possible parameters, bpNumber and srcAcctId2. Both are available on that account-list call (I think maybe primaryBpNumber and srcAcctId2 on that response). For me, both are null or empty, so maybe me not providing them is fine. Can you check if you have values for those?

@amancyh
Copy link

amancyh commented Aug 23, 2021

Thanks for the integration; mine is giving error "failed to set up"

This error originated from a custom integration.

Logger: custom_components.duke_energy_gateway
Source: custom_components/duke_energy_gateway/init.py:82
Integration: Duke Energy Gateway (documentation, issues)
First occurred: 5:07:43 PM (1 occurrences)
Last logged: 5:07:43 PM

Could not identify a smart meter on your account with gateway access.

@slappula
Copy link
Author

Good info Michael! I think that helped find the solution. When I follow your Postman setup directions and query the Account Details using just email, SrcSysCd & SrcAcctId- I get an error. First one said something about my account not being setup. When I tried it just now, I get an internal server error:
{
"timestamp": 1629753749628,
"status": 500,
"error": "Internal Server Error",
"message": "",
"path": "/account-details"
}

However, if I add the bpNumber that was returned by the sysSysCd call, I get a good result (shows a bunch of details about the account). I won't post it here because it has a lot of identifying information. If you want me to PM it to you, I can.

@mjmeli mjmeli closed this as completed in be2934e Aug 23, 2021
@mjmeli mjmeli self-assigned this Aug 23, 2021
@mjmeli
Copy link
Owner

mjmeli commented Aug 23, 2021

I believe this is fixed in the newest release 0.0.7. I've also added some more logging in the event we need to debug this again in the future.

Try updating in HACS and let me know if there are still issues

@mjmeli mjmeli added this to the 0.0.7 milestone Aug 23, 2021
@slappula
Copy link
Author

Seems to be working great after updating to 0.0.7. Thanks again!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants