diff --git a/custom_components/rohlikcz/rohlik_api.py b/custom_components/rohlikcz/rohlik_api.py index 4cad2e3..5520d95 100644 --- a/custom_components/rohlikcz/rohlik_api.py +++ b/custom_components/rohlikcz/rohlik_api.py @@ -128,10 +128,22 @@ async def login(self, session): login_response: dict = login_response.json() if login_response["status"] != 200: + messages = login_response.get("messages", []) + error_detail = messages[0]["content"] if messages else None + _LOGGER.error(f"Login failed with status {login_response['status']}. Response: {mask_data(login_response)}") if login_response["status"] == 401: - raise InvalidCredentialsError(login_response["messages"][0]["content"]) + if error_detail: + raise InvalidCredentialsError(error_detail) + raise InvalidCredentialsError( + "Login failed. Please check your credentials. " + "If your password contains special characters (e.g. `, $, +, etc.), " + "try changing it to use only standard characters — " + "Rohlik.cz may not handle them correctly." + ) else: - raise RohlikczError(f"Unknown error occurred during login: {login_response["messages"][0]["content"]}") + if not error_detail: + error_detail = f"status code {login_response['status']}" + raise RohlikczError(f"Unknown error occurred during login: {error_detail}") if not self._user_id: self._user_id = login_response.get("data", {}).get("user", {}).get("id", None) diff --git a/readme.md b/readme.md index cf8b009..4937d28 100644 --- a/readme.md +++ b/readme.md @@ -36,10 +36,13 @@ From the Home Assistant front page go to **Configuration** and then select **Int Use the "plus" button in the bottom right to add a new integration called **Rohlik.cz**. Fill in: - + - Email (your Rohlik.cz account email) - Password (your Rohlik.cz account password) +> [!NOTE] +> If your password contains special characters (e.g. `` ` ``, `$`, `+`), login may fail due to a Rohlik.cz server-side limitation. If you experience login issues, try changing your Rohlik.cz password to use only standard alphanumeric characters and common symbols. + The integration will connect to your Rohlik.cz account and set up the entities. ## Features