RobertD502 / home-assistant-iocare

Home Assistant custom component for monitoring and controlling Coway Airmega Purifiers
MIT License
52 stars 8 forks source link

Can't login: coway servers did not return a valid login URL #22

Closed gdudek closed 1 year ago

gdudek commented 1 year ago

This was working great when I configured it 2 days ago (and continued to work). Then I power cycled everything today and now I cannot connect, but I can still connect via the phone-based app.

I see: Failed setup: will retry. On hovering over the error I see: Can't login: coway servers did not return a valid login URL

RobertD502 commented 1 year ago

Power cycled your purifier(s) or Home Assistant?

That error just means that the Coway servers aren't returning a login URL which is needed to proceed with logging in. I'd reload the integration and see if you can get it go. Aside from that, we don't have any control over what the coway servers return.

RobertD502 commented 1 year ago

Let me know if it starts behaving again.

gdudek commented 1 year ago

Thanks. Power cycled the purifier (which seemed unlikely to help), removed the integration and re-added it (without success since I cant login and now it's not loaded at all), power cycled HA. I am out of debugging actions. I'd try the URL manually, but didn't find it in the code -- my bad, as it's obviously in there somewhere!

I even try the pypi iocareapi.py package as a debugging step, but it's old and doesn't seem to the use the same API.

Around the time this all fell apart, I did register the purifier at coway.com via my browser as well. Is there any way that might have interfered?

RobertD502 commented 1 year ago

@gdudek Send me a message on Discord @robertd502 since this may take a bit of troubleshooting.

Regarding the Login url:

The url is different during every visit. When a query is made to the main login page, a HTML file is returned. Within that file, is a form with an ID of kc-form-login and action attribute that contains the Login URL that the username and password need to be sent to. The URL is in the form of https://id.coway.com/auth/realms/cw-account/login-actions/authenticate?session_code=VARIABLE_SESSION_CODE_HERE&execution=EXECUTION_CODE&client_id=cwid-prd-iocare-20220930&tab_id=wlOaTJhbA8k. With the authentication method that was introduced to their API at the end of last year, there is no single Login URL, so, we have to grab it from the HTML file returned.

Side note: The integration uses the cowayaio library.

gdudek commented 1 year ago

Well, it started to work again. I presume there was a glitch on the Coway end of pipeline. Thanks for your help. I will think about some method to intercept via the router and do fully local control, but thats a big undertaking. Thanks!

RobertD502 commented 1 year ago

Well, it started to work again. I presume there was a glitch on the Coway end of pipeline. Thanks for your help. I will think about some method to intercept via the router and do fully local control, but thats a big undertaking. Thanks!

Some work has already been done here, but it stops short of actually controlling it.