Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Home assistant integration error "Connection to Aqua IOT API not possible" #17

Closed
miguelpissarra opened this issue Oct 29, 2021 · 12 comments

Comments

@miguelpissarra
Copy link

I've a Cadel Tile3 Plus stove that is controlled by Easy connect Plus app. I've the stove configured in the app and everything is working.
I'm trying to use this great work in Home Assistant, and i'm stuck in configuration page. It seems that the API URL has changed because i'm sure that the user and password are correct but i always receive the error "Connection to Aqua IOT API not possible".
Is there a way to know what URL API the APP is calling?
Any help would be appreciate.
Thanks in advance.
Miguel

@miguelpissarra miguelpissarra changed the title Home assistant integration error error "Connection to Aqua IOT API not possible" Home assistant integration error "Connection to Aqua IOT API not possible" Oct 29, 2021
@marc-cizeron
Copy link

Could you have more precision to your issue ? What your logs are saying (In HA, configuration > logs) ?

I encounter some issuer when login and i have to apply this PR #15

See this issue : #16

@miguelpissarra
Copy link
Author

Sorry i didn't said that i've already did apply PR #15 before i posted my problem.

When using HA, the only file that need to be changed to apply this PR is the manifest.json, right ?

In HA i don't have any log messages beside this one:
2021-10-29 20:04:23 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration aguaiot which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

@marc-cizeron
Copy link

There is the manifest.json AND the requirement.txt file. The PyJWT should be upgraded i think.

But, in my case there was log with explicite error about JWT.

I have the same warning which is completly normal is this case.

@miguelpissarra
Copy link
Author

Hi Marc,
Maybe I’m doing something wrong but in case of home assistant the documentation says to copy the aguaiot folder to custom_components and that’s what I did (with the manifest fikexakready updated) and the requirements.txt is outside that folder. If it is necessary where should I put it?
I’ve several integrations in my home assistant installation and even the ones that are not “official” the installation is straight forward. This one is the only that is a bit more tricky, I suppose.
Thanks for help

@marc-cizeron
Copy link

There is something i don't realy understand but here what i did :

  1. I put the directory py_agua_iot in custom_components
  2. I put the directory py-agua-iot/examples/home-assistant/custom_components/aguaiot/ into custom_components

So this is my tree :
-> custom_components
|_ py_agua_iot
|_ aguaiot

Capture d’écran 2021-11-02 à 16 19 45

Am I clear ?

@miguelpissarra
Copy link
Author

Yes you were clear and that's what i have also:

image

And in aguaiot and py_agua_iot i have this files:

aguaiot:
image

py_agua_iot:
image

Thanks for trying to help me solve this issue.

@marc-cizeron
Copy link

Hi ! My config is little bit different from yours.

First of all i git clone the repo :

Capture d’écran 2021-11-04 à 08 53 09

In the repos I edited requirements.txt and setup.py. Here a copy of setup.py (see install_requires):

import setuptools

with open("README.md", "r") as fh:
    long_description = fh.read()

setuptools.setup(
    name="py-agua-iot",
    version="0.0.8",
    author="Frederic Van Linthoudt",
    author_email="frederic.van.linthoudt@gmail.com",
    description="py-agua-iot provides controlling heating devices connected via the IOT Agua platform of Micronova",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://github.com/fredericvl/py-agua-iot",
    packages=setuptools.find_packages(),
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: Apache Software License",
        "Operating System :: OS Independent",
    ],
    install_requires=[
        "PyJWT==2.3.0",
        "requests==2.25.1",
    ],
)

Then from this directory copied/pasted the folder examples/home-assistant/custom_components/aguaiot to the root of custom_components

So in conclusion here the aguaiot directory :

Capture d’écran 2021-11-04 à 08 52 13

And to finish the installation I restarted Home Assistant.

As far as I understand py-agua-iot is the library how communicate with aguat clood platforme. aguaiot is Home Assistant component for the climat. It use the py-agua-iot library as an external library.

Hope you'll get more success this time :)

@miguelpissarra
Copy link
Author

Hi did a small script to call this service via home assistant and i think the problem is a certificate issue.
The home-assistant.log show this (email and password are masked):

2021-11-17 18:54:39 ERROR (SyncWorker_3) [custom_components.python_script] Error executing script: Connection to https://remote.mcz.it/appSignup not possible
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1010, in validate_conn
conn.connect()
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 416, in connect
self.sock = ssl_wrap_socket(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/ssl
.py", line 449, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/ssl
.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/local/lib/python3.9/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/usr/local/lib/python3.9/ssl.py", line 1040, in _create
self.do_handshake()
File "/usr/local/lib/python3.9/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='remote.mcz.it', port=443): Max retries exceeded with url: /appSignup (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/py_agua_iot/init.py", line 126, in register_app_id
response = requests.post(url,
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 117, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='remote.mcz.it', port=443): Max retries exceeded with url: /appSignup (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: una

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/config/custom_components/python_script/init.py", line 81, in execute_script
exec(code)
File "/config/custom_components/python_script/teste.py", line 4, in
connection = agua_iot("https://remote.mcz.it", "746318", "**************@gmail.com", "*************", "1c3be3cd-360c-4c9f-af15-1f79e9ccbc2a", brand_id="1")
File "/usr/local/lib/python3.9/site-packages/py_agua_iot/init.py", line 92, in init
self._login()
File "/usr/local/lib/python3.9/site-packages/py_agua_iot/init.py", line 95, in _login
self.register_app_id()
File "/usr/local/lib/python3.9/site-packages/py_agua_iot/init.py", line 133, in register_app_id
raise ConnectionError(str.format(
py_agua_iot.ConnectionError: Connection to https://remote.mcz.it/appSignup not possible

Another test that returns a certificate problem is:

[core-ssh python_script]$ curl https://remote.mcz.it
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
[core-ssh python_script]$

And if i bypass server certificate it returns a answer:

[core-ssh python_script]$ curl -k https://remote.mcz.it

<title>Agua</title>
<link rel="icon" href="/images/favicon.ico" type="image/x-icon">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700&subset=latin,cyrillic-ext" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" type="text/css">
<link href="/stylesheets/loginstyle.css" rel="stylesheet">
                    <a href="/">Agua Platform</a>
            </div>

            <div class="input-group align-center footerLogin">
                    <p>
                            Made with <i class="material-icons md-18" style="color: #ee4545; vertical-align: sub;">favorite</i> by <a href="h                                                                                            ttp://www.micronovasrl.com/" target="_blank">micronovasrl.com</a>
                            <br>Copyright &copy; 2017 - 2021
                            <br>Version 1.5.0.0
                    </p>
            </div>
    </div>
[core-ssh python_script]$

Is there anything that i can do to solve this issue?

Thanks.

@marc-cizeron
Copy link

marc-cizeron commented Nov 18, 2021

Hi, i think you have to check this error :

curl: (60) SSL certificate problem: unable to get local issuer certificate

Hear some information i found :

Relating to 'SSL certificate problem: unable to get local issuer certificate' error. It is important to note that this applies to the system sending the CURL request, and NOT the server receiving the request.

The issue comes from some certificate on your machine. The certificate might be corrupt, outdated...

What is your system ? OS, Is Home Assistant up to date ? Dockers ? Update/upgrade your machine ? Maybe you could purge curl and reinstall it ?

try to Update the certificates : sudo update-ca-certificates -f

-- another idea, you could try this :

  1. try to get root certificate of the serveur : openssl s_client -showcerts -servername remote.mcz.it -connect remote.mcz.it:443 > cacert-mcz-it.pem
  2. Then try to connect to remote.mcz.it : curl --cacert cacert-mcz-it.pem https://remote.mcz.it
  3. If it's ok, that mean you get the right root cacert. You can copy it to /etc/ssl/certs/
  4. Then curl -I https://remote.mcz.it should gives you HTTP/1.1 200 OK
  5. Try to log with Home Assistant

Let me know if it's working :)

EDIT: source => https://stackoverflow.com/questions/24611640/curl-60-ssl-certificate-problem-unable-to-get-local-issuer-certificate, https://daniel.haxx.se/blog/2018/11/07/get-the-ca-cert-for-curl/

@miguelpissarra
Copy link
Author

Hi,
My Home Assistant installation is on a linux VM (running on a Virtualbox environment) and its supervised, so it runs on a docker container. Home Assistant is on last version available.
I follow your instructions and now curl is working but when in home assistant calling the python script or when configuring the Micronova Agua IOT integration, both give the same certificate error.
I notice also that every time i reboot the server the certificate disappears.
I will keep investigating this issue.
Thanks for your help.

@marc-cizeron
Copy link

Hi,
My installation is a VM inside Proxmox environment (qemu) without docker. You have to update your certificate form docker container who execute the python script. Thus if you restart your docker container you will lose your modification.

With docker and home assistant, i don't how to add persistent data.

@vincentwolsink
Copy link
Collaborator

Closing this issue for now. Please re-open if still relevant

@vincentwolsink vincentwolsink closed this as not planned Won't fix, can't repro, duplicate, stale Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants