kellerza / pysma

Async library for SMA Solar's WebConnect interface
MIT License
59 stars 51 forks source link

example.py: set verify_ssl=False, since SMA Inverters use invalid certs #41

Closed jeremyvisser closed 3 years ago

jeremyvisser commented 3 years ago

SMA Inverters use self-signed certificates which are untrusted by default on Python.

Without this change, attempting to use example.py with HTTPS fails with:

$ python example.py https://sma.local user 1234
DEBUG:asyncio:Using selector: EpollSelector
ERROR:pysma:Could not start session, Could not connect to SMA at https://sma.local (timeout), got {}
INFO:__main__:No session ID

With this change, connecting works as expected.

In an ideal world, using a trusted TLS certificate would be the best fix. However, I'm unaware of a way to upload a trusted TLS cert to an SMA inverter. As such, setting verify_ssl=False seems to be the only practical way to use HTTPS with this hardware.

kellerza commented 3 years ago

Thanks @jeremyvisser! The library is mainly used with homeassistant, where the aiohttp session has verify_ssl false.

But this should make the example work on its own as well

Does this have any negative impact on http:// requests?

jeremyvisser commented 3 years ago

My Sunny Boy 5.0 inverter appears to force HTTPS (it redirects HTTP to HTTPS) and I don’t see any options within the interface to allow HTTP access, so testing it isn’t really possible with my inverter.

(I tested against a HTTP interface and it made actual requests, but those requests weren’t to a real inverter. Based on that I’d say it’ll probably work, but I’d recommend additionally testing yourself.)

kellerza commented 3 years ago

I dont have the inverter myself any longer, but if you made successful requests to http it should be ok.