hcpy icon indicating copy to clipboard operation
hcpy copied to clipboard

multiple errors on login / trying to connect to TI9555X9 coffee maker

Open Morg42 opened this issue 1 year ago • 2 comments

Hi,

I've been running the singlekey branch for a while now without problems, owning a dishwasher which I can access over hcpy.

System is Devuan daedalus, Python 3.11.2

Now I added a coffee maker (S500 connect, TI9555X9DE/21) and hc-login goes awry...

First error is "missing scheme" on the fourth preauth URL, which I fixed by prepending singlekey_host. (inserting 2 lines before line 123.

Next error is "failed to fetch <Response [307]>", which I fixed by adding code 307 to line 127.

Next error is a relative url for the first return_url, which I again fixed by prepending singlekey_host (again inserting 2 lines before line 136.

The next error is (subtract 4 from linenumbers for inserted code lines):

return_url='https://singlekey-id.com/auth/connect/authorize/callback?client_id=[...]&redirect_uri=https%3A%2F%2Fapi.home-connect.com%2Fsecurity%2Foauth%2Fredirect_target&response_type=code&scope=openid%20email%20profile%20offline_access%20homeconnect.general&prompt=login&style_id=bsh_
hc_01&state=%7B%22session_id%22%3A%22[...]%22%7D&suppressed_prompt=login'
Traceback (most recent call last):
  File "/home/sh/src/hcpy/./hc-login", line 142, in <module>
    headers["RequestVerificationToken"] = r.cookies["X-CSRF-FORM-TOKEN"]
                                          ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/home/sh/.venvs/3.11/lib/python3.11/site-packages/requests/cookies.py", line 334, in __getitem__
    return self._find_no_duplicates(name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sh/.venvs/3.11/lib/python3.11/site-packages/requests/cookies.py", line 413, in _find_no_duplicates
    raise KeyError(f"name={name!r}, domain={domain!r}, path={path!r}")
KeyError: "name='X-CSRF-FORM-TOKEN', domain=None, path=None"

I'm guessing it's missing the X-CSRF-FORM-TOKEN cookie from the response. Response cookies include .AspNetCore.Antiforgery. and __Host-F8Mmt. Why? What can I do? What might I have done wrong?

Anyone able to help? As far as I could see, @CRTified has a similar machine already working...?

Morg42 avatar Mar 11 '24 09:03 Morg42

Hey @Morg42, please take a look at https://github.com/hcpy2-0/hcpy. We have forked this repo and continue to develop the software.

If you have any issues, your are welcome to create an issue in our repo.

pmagyar avatar Apr 16 '24 20:04 pmagyar

Hi, sorry for the lack of a response. I used to have this working with a coffee machine, but at that point the code was a mere PoC and not something that could be used productively. Since then, I didn't have time to dig into it any deeper, so I can't provide any recent insights.

CRTified avatar Apr 19 '24 17:04 CRTified