tschamm / boschshc-hass

Home Assistant component for accessing Bosch Smart Home Controller using boschshcpy python library.
Other
172 stars 27 forks source link

HA unregistered after upgrade - registration leads to "Ungültige Authentifizierung" #102

Closed wsirhc closed 1 year ago

wsirhc commented 1 year ago

During the past week both the SHC (1st gen) was upgraded to 10.16.2982-28962 and the HA-Server was upgraded to 2023.8.0. Since then the HA-Server was required to register again to the SHC. When following the registration process in the UI, it only came to the response "Ungültige Authentifizierung". But in the Bosch Mobile App I can see the device registered as "oss_HomeAssistant_Binding".

Following the registration guide with postman I could successfully register a new device.

wsirhc commented 1 year ago

here's the log snippet:

Logger: root Source: deps/lib/python3.11/site-packages/boschshcpy/api.py:133 First occurred: 15:29:03 (1 occurrences) Last logged: 15:29:03 Failed to get information from SHC controller: SHC Error (message: API call returned non-OK result (code 400)!: b'')

armin-gh commented 1 year ago

Which version of the integration are you running and which type of installation? the integration being part of HA? HACS? Custom component manually installed?

vordenken commented 1 year ago

I have the same problem and also opened an issue here -> https://github.com/home-assistant/core/issues/98181 because I just found this repo here. I did not upgrade my homeassistant (OS-Version) but the SHC upgraded itself, after that the issue started. I get the same response as OP stating "Ungültige Authentifizierung". homeassistant logs:

Logger: root
Source: components/bosch_shc/config_flow.py:70 
First occurred: 18:41:29 (4 occurrences) 
Last logged: 18:41:29

Body: None
Headers: {'User-Agent': 'python-requests/2.28.2', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive', 'api-version': '2.1', 'Content-Type': 'application/json'}
URL: https://192.168.178.74:8444/smarthome/information
Failed to get information from SHC controller: SHC Error (message: API call returned non-OK result (code 400)!: b'')

I use homeassistant core version: 2023.4.6 and homeassistant OS version: 10.1 - The Bosch SHC integration comes from homeassistant itself, I did not install it myself.

armin-gh commented 1 year ago

I guess you an need an update to either your core version (2023.4.6 is about 4 month old) or instead use the custom component installed via HACS. This was one of the recent updates to the SHC Controller, all client software needs to use API-version 3.x and your request is for api-version 2.1, hence the controller does not accept it. Not sure with which version of Home Assistant the update for this integration took place, the latest version of HA includes the updated library boschshcpy ( using API version 3.2)

vordenken commented 1 year ago

Thanks for your input! Unfortunately I cannot update atm because it breaks another integration I really need. For now (the idea came after my last post) I just use the homekit integration to connect SHC to HA. If this works the reliably it's fine for me.

armin-gh commented 1 year ago

If you have HACS installed and use this integration from HACS it overlays the SHC integration from core, you might be able to keep your current core version and still use the newest integration for SHC.

wsirhc commented 1 year ago

Which version of the integration are you running and which type of installation? the integration being part of HA? HACS? Custom component manually installed?

I am using the Docker Build of Home Assistant 2023.8.0 on my Raspi 4 with podman 4.3.1. So no HACS integration. The SHC Integration is the latest master branch of this repo. The SH Controller is running on 10.16.2982-28962.

I am curious that the integration still seems to call API v 2.1 even after upgrade all relevant libs:

2023-08-04 10:41:49.292 ERROR (SyncWorker_4) [root] Body: None 2023-08-04 10:41:49.293 ERROR (SyncWorker_4) [root] Headers: {'User-Agent': 'python-requests/2.31.0', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive', 'api-version': '2.1', 'Content-Type': 'application/json'} 2023-08-04 10:41:49.296 ERROR (SyncWorker_4) [root] URL: https://192.168.180.103:8444/smarthome/information 2023-08-04 10:41:49.299 ERROR (SyncWorker_4) [root] Failed to get information from SHC controller: SHC Error (message: API call returned non-OK result (code 400)!: b'') [10:47:26] INFO: Home Assistant Core finish process exit code 100

Could this be some kind of caching issue? But what cache should be cleared then?

armin-gh commented 1 year ago

hmm... not sure, when I started with HA I choose a core installation in a Python VEnv as my preferred method of installation ( which requires some knowledge about Linux administration )

the code to build the request is not in the integration itself, this is in the library boschshcpy, but the latest version of this integration should automatically use the library in the required version. Here Python checks the dependencies of the integration as per file manifest.json and downloads the library automatically if it is missing or has an older version. Not sure how this works in docker.

if you are able to locate the boschshcpy folder in your installation, there is a file api.py and this Python code contains the class for the request, the version for the header is defined around line 53

Armin

wsirhc commented 1 year ago

hmm... not sure, when I started with HA I choose a core installation in a Python VEnv as my preferred method of installation ( which requires some knowledge about Linux administration )

the code to build the request is not in the integration itself, this is in the library boschshcpy, but the latest version of this integration should automatically use the library in the required version. Here Python checks the dependencies of the integration as per file manifest.json and downloads the library automatically if it is missing or has an older version. Not sure how this works in docker.

if you are able to locate the boschshcpy folder in your installation, there is a file api.py and this Python code contains the class for the request, the version for the header is defined around line 53

Armin

Seems this was the right advice. Thanks for that! The corrsponding line in /config/deps/lib/python3.11/site-packages/boschshcpy/api.py refered to API Version 2.1. So I've decidec to delete the folder manually and used the https://github.com/tschamm/boschshcpy Repo instead. Now the authentication works without any errors. But not sure what happens on next HA Image Upgrade...

wsirhc commented 1 year ago

Closed due to it seems a custom problem of a specific HA installation.