Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions custom_components/rohlikcz/rohlik_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down