you’re welcome! Looking forward to your simplified integration.
I think this might be an even easier implementation for the device “Homey” (which is also some kind of HA). This is done directly by the manufacturer Bosch-Siemens, so they might have some other tricks for the integration:
Unfortunately, I didn’t find a Python library supporting the Device Flow, since it’s a very new OAuth feature. There is an issue on this in oauthlib. Until this is implemented, I’m afraid this cannot be used (I can’t write a client for this from scratch).
Trying to get this to work but gett the following error while starting up HA:
‘Error during setup of component homeconnect
Traceback (most recent call last):
File “/usr/src/app/homeassistant/setup.py”, line 156, in _async_setup_component
component.setup, hass, processed_config) # type: ignore
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/homeconnect/init.py”, line 49, in setup
from homeconnect import HomeConnect
File “/usr/local/lib/python3.7/site-packages/homeconnect/init.py”, line 1, in
from .api import HomeConnect
File “/usr/local/lib/python3.7/site-packages/homeconnect/api.py”, line 1, in
from requests_oauthlib import OAuth2Session
File “/usr/local/lib/python3.7/site-packages/requests_oauthlib/init.py”, line 3, in
from .oauth1_auth import OAuth1
File “/usr/local/lib/python3.7/site-packages/requests_oauthlib/oauth1_auth.py”, line 10, in
from requests.utils import to_native_string
File “/usr/local/lib/python3.7/site-packages/requests/utils.py”, line 24, in
from . import certs
File “/usr/local/lib/python3.7/site-packages/requests/init.py”, line 114, in
from .models import Request, Response, PreparedRequest
File “/usr/local/lib/python3.7/site-packages/requests/models.py”, line 28, in
from .auth import HTTPBasicAuth
File “/usr/local/lib/python3.7/site-packages/requests/auth.py”, line 22, in
from .utils import parse_dict_header
ImportError: cannot import name ‘parse_dict_header’ from ‘requests.utils’ (/usr/local/lib/python3.7/site-packages/requests/utils.py)’
I have registered and have edited configuration.yaml with Client_ID and Client_Secret
I sometimes get this error, too, and it doesn’t make any sense to me as the file in question does contain that name. I have no idea so far what is causing it. But usually when I restart HA the problem is gone. Sorry, not a very good solution…
I hope someone can help me here, I’ve been trying it since hours to get it to work… My authorization fails when I click on the “Link Home Connect account” link in HA.
I’m getting this error message:
{
“error”: “unauthorized_client”,
“error_description”: “client or redirection URI not authorized”,
“state”: “M0mHJobp7FPs4Xv5vyoOwh0vnu5n0j”
}
the duckdns URL is working as I can access it over https://xxx.duckdns.org:8123 and it is showing up as secure. only when I access it local with https://hassio.local:8123 it is showing as non secure. Don’t know if this is normal…
Managed to get the connection to work now. But after reboot I get errors. And it is looking for Python3.7 which is not installed (running Docker on Synology).
Error during setup of component homeconnect
Traceback (most recent call last):
File “/usr/src/app/homeassistant/setup.py”, line 156, in _async_setup_component
component.setup, hass, processed_config) # type: ignore
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/homeconnect/init.py”, line 49, in setup
from homeconnect import HomeConnect
File “/usr/local/lib/python3.7/site-packages/homeconnect/init.py”, line 1, in
from .api import HomeConnect
File “/usr/local/lib/python3.7/site-packages/homeconnect/api.py”, line 1, in
from requests_oauthlib import OAuth2Session
File “/usr/local/lib/python3.7/site-packages/requests_oauthlib/init.py”, line 3, in
from .oauth1_auth import OAuth1
File “/usr/local/lib/python3.7/site-packages/requests_oauthlib/oauth1_auth.py”, line 10, in
from requests.utils import to_native_string
File “/usr/local/lib/python3.7/site-packages/requests/utils.py”, line 24, in
from . import certs
File “/usr/local/lib/python3.7/site-packages/requests/init.py”, line 114, in
from .models import Request, Response, PreparedRequest
File “/usr/local/lib/python3.7/site-packages/requests/models.py”, line 28, in
from .auth import HTTPBasicAuth
File “/usr/local/lib/python3.7/site-packages/requests/auth.py”, line 22, in
from .utils import parse_dict_header
ImportError: cannot import name ‘parse_dict_header’ from ‘requests.utils’ (/usr/local/lib/python3.7/site-packages/requests/utils.py)
It is working now for me and I don’t even know the reason, because I haven’t changed anything. I think there was just an issue with the authorization server there…
Great component! However, my connection to the backend seems to be lost silently after about a day. If I restart Home Assistant, everything is fine again. For about a day.
What can I do?
There is nothing in the home assistant log about this, apart from Unexpected value for HomeConnect door state: {} which I get at startup, and I guess is unrelated since it works for a while.
Interesting, this probably means that the token refresh fails since tokens have a lifetime of 24h. This is supposed to be taken care of automatically by the requests_oauthlib library and in my case works. Does anybody else have this problem? Can you check if the homeconnect-token-cache file appears in your HA config dir when you log in?
The expires_at is already passed by more than a day now. It reads 2019-07-22 20:14 UTC, and right now we have 2019-07-23 21:39 UTC. The fil was last touched at 2019-07-21 20:14 UTC. HA was restarted about 2019-07-21 11:31 UTC.
I run the latest and greatest HA in a Docker.