Skip to content
Merged
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
Binary file modified .coverage
Binary file not shown.
7 changes: 7 additions & 0 deletions src/solarlog_cli/solarlog_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self, host: str, session: ClientSession | None, password: str = "")

self._hashed_pwd: bool = False
self._close_session: bool = True
self._token = "" #required for older firmware, where cookie is not sufficient

async def test_connection(self) -> bool:
"""Test the connection to Solar-Log."""
Expand Down Expand Up @@ -114,6 +115,9 @@ async def login(self) -> bool:
self.session.cookie_jar.update_cookies(
{"SolarLog": response.cookies["SolarLog"].value})

if not self._hashed_pwd:
self._token = response.cookies["SolarLog"].value

_LOGGER.debug("response: %s", text)
_LOGGER.debug("cookies: %s", response.cookies)
_LOGGER.debug("Login successful, token: %s",
Expand All @@ -131,6 +135,9 @@ async def execute_http_request(self, body: str, path: str = "getjp", timeout: fl

header = {"Content-Type": "text/html", "X-SL-CSRF-PROTECTION": "1"}

if self._token != "":
body = f"token={self._token}; " + body

_LOGGER.debug("HTTP-request header: %s", header)
_LOGGER.debug("HTTP-request body: %s", body)

Expand Down
Loading