sockless-coding / panasonic_cc

Panasonic Comfort Cloud - Home Assistant Component
MIT License
137 stars 35 forks source link

Account login aborted with no error message #29

Closed EmjayGitHub closed 3 years ago

EmjayGitHub commented 3 years ago

Hi,

I am trying to add the integration to my HA setup: Operating System: Home Assistant OS 5.12 Core Version: core-2021.3.0

The HACS repository has been installed OK. But when trying to log in wuth my Panasonic account, I just get a popup with the title "Aborted", but no further info as to a reason for aborting the setup. I have been looking through various logs, but haven't been able to find anything related to this.

Are there any known issues with the latest release of this component, and the above versions of HA?

sockless-coding commented 3 years ago

Hi @EmjayGitHub I haven't tried to set up a new device on 2021.3 yet, but the integration works. Has it logged anything under logs in HA? And you have a Panasonic Comfort Cloud account and not a Panasonic Aquarea Cloud Account, the latter doesn't work with this integration.

EmjayGitHub commented 3 years ago

Hi @sockless-coding, Thanks for your response. When logging into HA, and going to Configuration -> Logs, I see no recorded incidents in the log, after a failed login. It is correctly understood that I am using a PCC account to login (tried 2 different ones), and NOT a PAC account. I am using the same account as I log into my Android Panasonic Comfort Cloud app.

sockless-coding commented 3 years ago

Hmm ok, Activate debug log for panasonic_cc component by adding the following to your configuration.yaml

logger:
  default: info
  logs:
    custom_components.panasonic_cc: debug

That will enable more detail logs for this component. You need to click the Load Full Home Assistant Log button under logs to load the entire log and see the debug info.

EmjayGitHub commented 3 years ago

Just to be sure. There is only 1 configuration.yaml, right? The one located at: config/configuration.yaml If yes, it now looks like this:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# panasonic logging
logger:
  default: info
  logs:
    custom_components.panasonic_cc: debug

After saving that yaml file, I reloaded the server and tried adding the integration again. It failed and I found no new data in my HA log, even after clicking Load Full Home Assistant Log.

sockless-coding commented 3 years ago

Ok, the only abort that doesn't write an entry to the log is the time-out. Can you verify that your HA can access https://accsmart.panasonic.com/auth/login

EmjayGitHub commented 3 years ago

I opened a web terminal and ran the command curl -X GET https://accsmart.panasonic.com/auth/login and got the following result back: {"message":"Unknown Request","code":4401}. This is the same result as when I just enter the address into any given browser on any of my PCs.

AndriesS82 commented 3 years ago

I follow this thread. I have the same issue.

sockless-coding commented 3 years ago

@EmjayGitHub that is the expected response... I've released v1.0.27 it contains some additional logging in the setup process. So it should create log entries for timed out and if no device is returned from PCC.

One thing that could help to determine the issue is if you could try using the standalone python script... It can be found over at lostfields repo: https://github.com/lostfields/python-panasonic-comfort-cloud And run the follow: python .\pcomfortcloud.py -r true <username> <password> list

EmjayGitHub commented 3 years ago

@sockless-coding I've updated my component to v1.0.27 and gone through the integration setup steps. There is 1 log entry in the HA log now: 2021-03-07 10:29:49 WARNING (MainThread) [custom_components.panasonic_cc.config_flow] No device returned from Panasonic Cloud. I get this error for both my accounts (the new one to use with HA, and the existing one I use with my Android app). I am not entirely sure how to run the standalone script, but will try to figure out and do so. In the meantime I hope that you can use the above information for something.

sockless-coding commented 3 years ago

@EmjayGitHub What heat pump model do you have? It might not be fully supported, there were some issues where Panasonic changed some IDs and formats. It would help if you managed to run the python script... you need Python 3+ installed and then just download the repository and from that directory run the command.

EmjayGitHub commented 3 years ago

@sockless-coding I've uploaded the pcomfortcloud.py file to the /config/python_scripts folder on my HA setup. I'm just missing the proper way to execute it, but might be getting there. Regarding the heat pump model, I have 2 different ones, being the CS-Z25UFEAW-1 and CS-Z35UFEAW-1. They are connected to my network via the external network dongle CS-ZTAGC-1.

EmjayGitHub commented 3 years ago

Ok. So I got python downloaded and installed on my PC, and ran the command from the master branch.

C:\Users\X\Downloads\python-panasonic-comfort-cloud-master\python-panasonic-comfort-cloud-master>python .\pcomfortcloud.py -r true email@gmail.com my_password list
Traceback (most recent call last):
  File "C:\Users\X\Downloads\python-panasonic-comfort-cloud-master\python-panasonic-comfort-cloud-master\pcomfortcloud.py", line 4, in <module>
    from pcomfortcloud import __main__
  File "C:\Users\X\Downloads\python-panasonic-comfort-cloud-master\python-panasonic-comfort-cloud-master\pcomfortcloud\__init__.py", line 12, in <module>
    from .session import (
  File "C:\Users\X\Downloads\python-panasonic-comfort-cloud-master\python-panasonic-comfort-cloud-master\pcomfortcloud\session.py", line 6, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

Looks like a missing file somewhere. There is a requests.http file, but in the pcomfortcloud folder there is indeed no file named requests (.py or .http).

sockless-coding commented 3 years ago

You need to install the requests library by running python -m pip install requests or pip install requests

EmjayGitHub commented 3 years ago

After having done so, I get a new error, and we might be on to something here. pcomfortcloud.session.ResponseError: Invalid response, status code: 401 - Data: {"message":"Login ID or password is incorrect,or account is locked","code":4101}. The interesting part is, I tried with both of my accounts, and even the one I am already logged in with in the Android Comfort Cloud app, gives the above error. Seeing as that account works on the phone, I don't see any reason as to why it would fail using this.

sockless-coding commented 3 years ago

That wasn't a very helpful error message, could you try to temporarily change the password of one of the accounts to something else...

EmjayGitHub commented 3 years ago

Sorry for the bad news. Even after changing password the issue persists, with the same error message. I have confirmed that I can log in here: https://csapl.pcpf.panasonic.com/Account/Top/ with both accounts.

sockless-coding commented 3 years ago

Hmm, since you know how to use curl try the following this is how the authentication is made: curl -X POST -k -H 'Accept: application/json' -H 'X-APP-TYPE: 1' -H 'X-APP-VERSION: 1.10.0' -H 'User-Agent: Python-Panasonic-Comfort-Cloud' -H 'Content-Type: application/json' -H 'X-User-Authorization;' -i 'https://accsmart.panasonic.com/auth/login' --data '{"language": "0","loginId": "<username>","password": "<password>"}'

Just replace the <username> and <password>

The response should look like {"uToken":"0123456789abcsefghijklmnopqrstuv","result":0,"language":0} if it's successful.

EmjayGitHub commented 3 years ago

It seemed to work:

HTTP/1.1 200 
Server: nginx
Date: Sun, 07 Mar 2021 15:44:26 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: no-store
Pragma: no-cache
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
X-XSS-Protection: 1;mode=block
Strict-Transport-Security: max-age=31536000;includeSubdomains

{"uToken":"G2OIoiH8ODsGs5Mk3KDkmfiJtbMTrkgS","result":0,"language":0}# 

After having tried that, I ran it from the python cmd again, this time changing single quotes with double quotes, and it worked there as well. I'm not sure why I didn't think of this before.

I then tried adding the integration. It spent some more time on a blank window than before, but eventually the result was the same. The log also only shows: 2021-03-07 16:49:19 WARNING (MainThread) [custom_components.panasonic_cc.config_flow] No device returned from Panasonic Cloud.

I have to ask: I don't need to somehow add the heat pumps to that account, before adding the integration, right? I expect that is part of the setup process during setup of the integration.

sockless-coding commented 3 years ago

As long as you can see them in the Panasonic app when you log in with the account it should be fine. When you ran the python command did you get anything in the get groups section?

--- _get_groups()
--- raw beginning ---
...
--- raw ending    ---
EmjayGitHub commented 3 years ago

I haven't been logged in to the account supposed to be used by HA, on the phone. But I can do that and have them assigned there. I got this from the python command:

--- _get_groups()
--- raw beginning ---
{"iaqStatus":{"statusCode":200},"groupCount":1,"groupList":[{"groupId":135915,"groupName":"My House","deviceList":[]}]}
--- raw ending    ---
AndriesS82 commented 3 years ago

ok... can you explain this or give me more details? It's a bit chinees for me cause i have the same issue... Could it be solved if I update to the latest version of home assistant. I am running 0.114.0

EmjayGitHub commented 3 years ago

I added the ACs to the HA account through the app, and now it works. I'm sorry I wasn't aware of this step, before setting it up in HA.

sockless-coding commented 3 years ago

@AndriesS82, make sure you see your heat pump in the Panasonic app when you log in with the credentials you plan on using for HA.

AndriesS82 commented 3 years ago

Ok. My AC's are not connected yet... In a couple of weeks i will power them up and connect them with the app on my mobile and see what will happen then.