Duke Energy smart meter config not working

Hello, I recently got my electric meter updated to a smart meter so now I can see daily consumption in their website. I have tried adding in the sensor to my config but it fails to run. Can anyone confirm it still works to start with and that its not broken, and any ideas from my logs below. Can find very little information on this when searching. Thank you

This is whats shown in my logs…

Error while setting up platform duke_energy
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py”, line 485, in wrap_socket
cnx.do_handshake()
File “/usr/local/lib/python3.7/site-packages/OpenSSL/SSL.py”, line 1934, in do_handshake
self._raise_ssl_error(self._ssl, result)
File “/usr/local/lib/python3.7/site-packages/OpenSSL/SSL.py”, line 1671, in _raise_ssl_error
_raise_current_error()
File “/usr/local/lib/python3.7/site-packages/OpenSSL/_util.py”, line 54, in exception_from_error_queue
raise exception_type(errors)
OpenSSL.SSL.Error: [(‘SSL routines’, ‘tls_process_server_certificate’, ‘certificate verify failed’)]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 672, in urlopen
chunked=chunked,
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 376, in _make_request
self._validate_conn(conn)
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 994, in validate_conn
conn.connect()
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 394, in connect
ssl_context=context,
File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl
.py", line 370, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File “/usr/local/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py”, line 491, in wrap_socket
raise ssl.SSLError(“bad handshake: %r” % e)
ssl.SSLError: (“bad handshake: Error([(‘SSL routines’, ‘tls_process_server_certificate’, ‘certificate verify failed’)])”,)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/requests/adapters.py”, line 449, in send
timeout=timeout
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 720, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File “/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py”, line 436, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘www.duke-energy.com’, port=443): Max retries exceeded with url: /form/Login/GetAccountValidationMessage (Caused by SSLError(SSLError(“bad handshake: Error([(‘SSL routines’, ‘tls_process_server_certificate’, ‘certificate verify failed’)])”)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 150, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File “/usr/local/lib/python3.7/asyncio/tasks.py”, line 442, in wait_for
return fut.result()
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/src/homeassistant/homeassistant/components/duke_energy/sensor.py”, line 28, in setup_platform
config[CONF_USERNAME], config[CONF_PASSWORD], update_interval=120
File “/usr/local/lib/python3.7/site-packages/pydukeenergy/api.py”, line 48, in init
if not self._login():
File “/usr/local/lib/python3.7/site-packages/pydukeenergy/api.py”, line 137, in _login
response = self.session.post(LOGIN_URL, data=data, headers=headers, timeout=10)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 581, in post
return self.request(‘POST’, url, data=data, json=json, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/adapters.py”, line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host=‘www.duke-energy.com’, port=443): Max retries exceeded with url: /form/Login/GetAccountValidationMessage (Caused by SSLError(SSLError(“bad handshake: Error([(‘SSL routines’, ‘tls_process_server_certificate’, ‘certificate verify failed’)])”)))
Connection lost. Reconnecting…

I am the original creator of the component, I haven’t used it in awhile, and I have moved since. I am not sure if my new meter works or not, but if it does I’ll try to check this issue out. If you haven’t heard from me in a couple days shoot me a reminder.

Thank you very much for responding

How are you running Home Assistant?

I am getting this same error and it looks like they changed their site somewhat so that has something to do with it, but the SSL errors don’t make sense. I have looked up the issue and everything I am reading is saying something about python3.6+ changing the way it handles certs. Not sure how to avoid it other than ignoring the SSL certificate which isn’t a great idea.

I’m using Hassio on a Pi 3

@w1ll1am23 did you ever manage to find the issue

Cheers
Matt

Sorry I did not. Been pretty busy lately. This component was officially removed. We could spin up a custom component that kinda fixes it, but I can’t figure out why the SSL errors are happening.

Is there still any hope to get this working again?

Noticed they have a mobile app now. I plan on trying to intercept the traffic from it and see if I can get a better component setup.

awesome, thanks man!

hey bud, have you had any luck pulling the data from their app?

I did take a look at it, it isn’t as straight forward as I was hoping it would be. I will have to dig in further and see what I can find.

1 Like

Is there any chance this might work in the future, or is there an alternative? I am using a SDR dongle and jdeath’s RTLAMR to MQTT Bridge addon from https://github.com/jdeath/RTLAMR2MQQT but it looks like rtlamr uses a bit more CPU than simply scraping their page would.

Not that it is a big deal, processor utilization is not a big issue, but the OCD in me wants things to be more efficient :wink: