cjaliaga / aioaquarea

Asynchronous library to control Panasonic Aquarea devices
MIT License
12 stars 7 forks source link

Provide docs and usage examples #5

Open cjaliaga opened 2 years ago

agm15 commented 9 months ago

Hello,

I will try to explain a little bit how to log in into the installer cloud and retrieve information.

Requirements:

The client ID can be obtained if you analyze the source code of the website, once you're logged in and you see the list of customers that you provide tech support to, basically you should only see yourself, right click, inspect element and you will see the atribute "data-id" that has the value you are looking for.

Next one is our deviceID, that one as well is even easier to obtain, just enter your customer plant by simply clicking on it on the customer list you will see after the login and go to Data registry, if you have the item inspector opened, on the network tab you'll see a request is being made to load the information. Just analyze the payload and you will see "var.deviceid" which contains the value that you are looking for.

Once you have all of that saved, its all about login and understanding the variables that you need to send in order to receive the information.

I will explain it further.

First you get the source code from here https://aquarea-service.panasonic.com and obtain the information for const shiesuahruefutohkun which is a variable inside the code of the website, some sort of token.

Once you have it you are ready to do the first login here https://aquarea-service.panasonic.com/installer/api/auth/login You need to send this information:

"var.loginId" => "yourusername@email.com", "var.password" => md5("yourusernameandyourpasswordtogether"), "var.inputOmit" => "false", "shiesuahruefutohkun" => "the variable shiesuahruefutohkun you scraped before"

Once you post that you will get the cookie that will allow you to keep sending request and obtain information.

Next step, post here https://aquarea-service.panasonic.com/installer/home and from the response, update our Shiesuahruefutohkun variable with the new information inside the response field "data".

Then we make another post to https://aquarea-service.panasonic.com/installer/functionUserInformation passing this variable that contains our customer id "var.functionSelectedGwUid".

And once again, update our Shiesuahruefutohkun just like we did before.

Repeat this process one more time but this time we post https://aquarea-service.panasonic.com/installer/api/function/status passing the information of our device id and our shiesuahruefutohkun.

"var.deviceId" => $deviceID, "shiesuahruefutohkun" => $Shiesuahruefutohkun

Finally we are ready to receive information about the status of our sensors. In order to do that, we make a post request to https://aquarea-service.panasonic.com/installer/api/data/log with this information:

"var.deviceId" => $deviceID, "var.target" => 0, "var.logItems" => '{"logItems":[39,40,41,52,70,71,74]}', "var.startDate" => (time() - 3600) * 1000, "shiesuahruefutohkun" => $Shiesuahruefutohkun

The tricky part is to obtain the logItem IDs in order to receive custom information from the sensors. 39-External temperature 40-Return temperature 41-Impulse temperature 52-Room temperature 70-Heat consumption 71-Energy generation 74-ACS Energy consumption

But there are way more ids that we can use. In order to know its corresponding ID we have to enter in the chart configuration menu, inspect each element and in the checkbox we will see the data-index atribute that has the value of that sensor ID.

Sorry for my english, I hope you guys can understand it

cjaliaga commented 8 months ago

@agm15 sorry for using this issue. Do you happen to have a heat pump without an external sensor? So ECO and Comfort modes can be enabled? If that's the case, I'd appreciate your help checking something with the aquarea smart environment.

Gracias!!

agm15 commented 8 months ago

Hello,

What do you mean by external sensor? Im not really sure what I have but If you tell me where to check I will gladly do it. What I know is that I can enable both ECO and Confort modes if that helps

Best

cjaliaga commented 8 months ago

Yes! That's perfect! I'm testing setting ECO and Comfort modes with the demo environment but there's something weird happening that I have the feeling is the demo environment.

So what I'd need is to get the responses from the aquarea-smart endpoint before and after enabling one of the modes. ECO for example. The content of the POST to update the special status (ECO/Comfort) can be handy too.

1) Login into the Aquarea page with your preferred method: username/password, installer link... 2) Open in the browser the status endpoint: https://aquarea-smart.panasonic.com/remote/v1/api/devices/DEVICE-GUID?var.deviceDirect=1 3) Copy the JSON from that endpoint 4) Enable ECO mode. With the developer tools opened you'll see the POST request, if you can share the content of that request would be great to see the calculated temperatures for the zone(s) 5) Wait some time, maybe a minute or so 6) Refresh the status endpoint: https://aquarea-smart.panasonic.com/remote/v1/api/devices/DEVICE-GUID?var.deviceDirect=1 7) Copy the response 8) Please share them with me 😊

Please feel free to remove any personal information/guids from the responses and of course let me know if I didn't explain myself properly.

Thanks a lot!!!!

agm15 commented 8 months ago

Hey,

Step 2 JSON

{"accessToken":{},"errorCode":0,"status":[{"deiceStatus":0,"operationStatus":1,"modelSeriesSelection":2,"multiOdConnection":0,"specialStatus":[{"specialMode":1,"operationStatus":0},{"specialMode":2,"operationStatus":0}],"cnCntErrorStatus":0,"zoneStatus":[{"operationStatus":1,"ecoHeat":-2,"coolMin":18,"heatMin":10,"comfortCool":-2,"temparatureNow":22,"coolSet":28,"zoneId":1,"comfortHeat":2,"heatMax":30,"coolMax":35,"ecoCool":2,"heatSet":26},{"operationStatus":0,"ecoHeat":0,"coolMin":null,"heatMin":null,"comfortCool":0,"temparatureNow":null,"coolSet":0,"zoneId":2,"comfortHeat":0,"heatMax":null,"coolMax":null,"ecoCool":0,"heatSet":0}],"outdoorNow":13,"operationMode":1,"holidayTimer":0,"powerful":0,"deviceGuid":"","bivalent":0,"tankStatus":[{"operationStatus":1,"temparatureNow":45,"heatMax":65,"heatMin":40,"heatSet":46}],"informationMessage":0,"pumpDuty":127,"quietMode":0,"forceHeater":0,"tank":1,"forceDHW":0,"pendingUser":0,"direction":1}]}

Step 4:

Payload:

{"status":[{"deviceGuid":"","specialStatus":1,"zoneStatus":[{"zoneId":1,"heatSet":24,"coolSet":30}]}]}

Response:

{"errorCode":0,"accessToken":{}}

6: The refresh happens automatically, this is the response

{ "accessToken": {}, "errorCode": 0, "status": [ { "deiceStatus": 0, "operationStatus": 1, "modelSeriesSelection": 2, "multiOdConnection": 0, "specialStatus": [ { "specialMode": 1, "operationStatus": 1 }, { "specialMode": 2, "operationStatus": 0 } ], "cnCntErrorStatus": 0, "zoneStatus": [ { "operationStatus": 1, "ecoHeat": -2, "coolMin": 18, "heatMin": 10, "comfortCool": -2, "temparatureNow": 22, "coolSet": 30, "zoneId": 1, "comfortHeat": 2, "heatMax": 30, "coolMax": 35, "ecoCool": 2, "heatSet": 24 }, { "operationStatus": 0, "ecoHeat": 0, "coolMin": null, "heatMin": null, "comfortCool": 0, "temparatureNow": null, "coolSet": 0, "zoneId": 2, "comfortHeat": 0, "heatMax": null, "coolMax": null, "ecoCool": 0, "heatSet": 0 } ], "outdoorNow": 14, "operationMode": 1, "holidayTimer": 0, "powerful": 0, "deviceGuid": "", "bivalent": 0, "tankStatus": [ { "operationStatus": 1, "temparatureNow": 45, "heatMax": 65, "heatMin": 40, "heatSet": 46 } ], "informationMessage": 0, "pumpDuty": 127, "quietMode": 0, "forceHeater": 0, "tank": 1, "forceDHW": 0, "pendingUser": 0, "direction": 1 } ] }

I copied the responses as they were, only removed the DEVICE GUID.

Let me know if you need anything else!

EDIT: I've seen specialMode is turned 1 when Eco mode is enabled, to disable is the same request from step 2 but setting it to 0. Also what confort and eco mode seems to be doing is just lowering/rising the temperature by 2 degrees celsius.

cjaliaga commented 8 months ago

Thanks a lot @agm15 , this is really helpful.

It reads the value from ecoHeat and ecoCool (and same for comfortHeat and comfortCool) from that zone and adds that to the current temperature, in your case is set to -2/+2 but I'm not sure if that's something that can be configured somewhere.

Here's the implementation of that calculation that I was testing last night: https://github.com/cjaliaga/aioaquarea/blob/fd17393bd1d6e246a49317d8ef26a63cc03c8eaf/aioaquarea/data.py#L643-L668

The weird thing that I was seeing in the demo environment is that after setting the mode (comfort/eco/none), the status request would return with the specialStatus set to the right mode, but the temperatures were not modified so I wasn't totally sure if the issue was on the code or just in the environment.

Thanks to your tests I can see it seems to be the environment. I'll publish a new version of the integration soon with the presets so you can test it from Home Assistant :)

Thanks again!

agm15 commented 8 months ago

No worries, just let me know if you need some more testing. Also I believe those settings for eco and comfort were available for configuration somewhere on the website. I just dont use it anymore since I have everything integrated in home assistant and in order to log in I have to disable the integrations..

Thanks for your work!! Really apreciated :)

cjaliaga commented 8 months ago

@agm15 I just released https://github.com/cjaliaga/home-assistant-aquarea/releases/tag/v0.6.0. Could you please give it a try and let me know if the presets work as expected? I did my best testing it but my device doesn't support that option.