Duke Energy Gateway - Realtime Smart Meter Readings

Mine is on it’s way, so I should be able to help out with the integration shortly.

2 Likes

I got mine yesterday. Setup was easy with the app. It shows the gateway and data in the Duke App.

When I setup everything in Home Assistant it doesn’t seem to find it. I get the following:

2021-09-04 19:14:17 ERROR (MainThread) [custom_components.duke_energy_gateway] Could not identify a smart meter on your account with gateway access.

Any thoughts?

What version of HA Core and what version of the Duke Energy integration are you using?

I wasn’t able to get v0.0.8 of the Duke Energy integration to work until I upgraded the core to the September release. If you are on a pre September release, try v0.0.7

Yeah Home Assistant has a breaking change in the 2021.9 update for how the measurements are tracked and the adjustments are in v0.0.8, so v0.0.8 is only compatible with 2021.9.

As for the issue finding the smart meter, it probably means there is something different with your account or the data coming back than is expected at the moment. To help debug through this in the past I’ve recommended getting the debug logs. You can do that by adding this to your configuration.yaml

logger:
  default: info
  logs:
    custom_components.duke_energy_gateway: debug

Then in your full home-assistant.log file you should see some more verbose logging.

Is it possible to pull the kw/h cost from the app? I’m entering it in manually, but it would be nice to pull it in automatically so that it’s adjusted whenever there is a rate change.

I couldn’t find the rates anywhere in the app. I had to pull my rate plan from a bill and then find a document with the rates.

I did create a template sensor for it as the rate is different for half the year. But if they ever change the rates themselves I’ll have to update manually.

template:
  # Rate is higher from July 1 - Oct 31.
  - sensor:
    - name: "Duke Energy Charge per kWh"
      unique_id: duke_energy_charge_per_kwh
      unit_of_measurement: USD/kWh
      icon: mdi:currency-usd
      device_class: monetary
      state: >
        {{ 0.10772 if now().month >= 7 or now().month <= 10 else 0.10271 }}
2 Likes

Thank you, that template will work nicely!

It took me a little while to get back to this. I updated to the latest 2021.9. Added the debug and got the following:

2021-09-08 05:21:37 DEBUG (MainThread) [custom_components.duke_energy_gateway] Failed to find meter on account 6143399001: Request failed with unexpected error [https://cust-pilot-api.duke-energy.com/smartmeter/v1/auth]: 500, message=‘Internal Server Error’, url=URL(‘https://cust-pilot-api.duke-energy.com/smartmeter/v1/auth’)

As I said before I can see the Gateway in the app. Unsure why it can’t find the meter.

Any thoughts?

I pushed out a new version this morning based on a similar issue report, 0.0.9. Try updating to that version and see if that fixes your issue.

That seems to have fixed it. Now to give it some time. Thanks.

I have this sensor working now. It is reporting 0.10772 as it should.

Under Configuration, Energy…

I selected “Use an entity with current price” and selected this sensor. No errors.

The cost has been setting at zero for days on the Energy page even though I do have kWh.

Got any thoughts? Bug? Or am I missing something?

Use a static price
enter your kWh cost

Gives me the same result $0.00 I was thinking it may be a problem in core-2021.9.6. Does the static price work for you? Really isn’t a huge deal either way.

Yes, you may have to wait some time (2hrs) before it starts reading.

I have no issues with that template price on 2021.9.6. Do you have any errors in the logs? For example, if your currency was ever something over than USD, it can break the cost sensor.

I did have a few errors when i first tried adding the sensor in the energy configuration. Something about not understanding it was USD/kWh. To fix it I removed the line in the yaml that had “unit_of_measurement: USD/kWh” pasted it right straight back in and that fixed it after a reboot. I couldn’t see that I did a thing. I kept the formatting exactly the same.

No errors are in the log now. Should I remove the sensor, reboot, and try again?

Sorry to sound thick. Learning as I go. Thanks.

I don’t know honestly. I did personally run into an issue with the statistic when I had my currency in HA set as EUR while the sensor was USD. The error was that since the unit of measure did not match, it would not record statistics anymore. This was my error message Generation of long term statistics will be suppressed unless the unit changes back - #3 by mjmeli. I went in and manually adjusted the UOM in the DB for that statistic. However that error showed in the logs.

Yes, I experienced this problem too. When currency was added to HA, the default was EUR. When you setup the Duke Energy integration HA automatically creates a cost entity that uses the currency you have set in Configurations / General. If you try to change the currency type after the cost entity is created it causes a currency error which prevents the Energy page from updating the cost (stays 0.00).

For now I have simply changed currency back to EUR under configurations / general. Cost shows properly, just in EUR rather than $.

I think when the cost entity is created, a second hidden cost entity is also created that is used on the energy page. Deleting and recreating the regular cost entity does not clear the history on the energy page. So there is an energy page cost entity with a currency set that can’t currently be updated.

I assume this bug will be fixed, I’ve seen a number of people having the same problem.

It is fixable in the DB if you are comfortable adjusting it. You can also just wipe out your DB but it will reset your history and long-term statistics.

Yeah I had seen that suggestion of deleting my DB elsewhere too lol, but I’m ok just leaving it as EUR until the HA devs fix it