sdamasoc / domoticz_panasonic_CZ-TACG1

A Python plugin for Domoticz to communicate with Panasonic Cloud Confort throught CZ-TACG1 WiFi adapter
MIT License
8 stars 1 forks source link

Panasonic Aquarea heatpump: The device XXX return an error (code=4300, message=Have no authority to the request) #7

Closed Marcel81 closed 5 months ago

Marcel81 commented 1 year ago

Hi, Next to 3 Panasconic airconditioners I do have a Panasonic heatpump with comfort cloud connection. All seems to be working but the heatpump is created in Domoticz but doesnt seem to update. The message in the log is: The device XXXX return an error (code=4300, message=Have no authority to the request).

This is tested with the original panasonic account (not the guest one) but no luck.

Any idea what could be wrong in my situation? Or is the heatpump not (yet) supported. If the latter is the case I volunteer to support this new functionality.

sdamasoc commented 1 year ago

Hello, normally the api is the same for all confort cloud devices. But maybe you can use the testPlugin.py file to test your devices. You need to hardcode your user/password in the file and then run it as a standard python script.

Marcel81 commented 1 year ago

Hi.

I did use this script and it runs without errors. This is the part of the output I get for the heatpump: "{"deviceGuid":"BXXXXXXX","deviceType":"2","deviceName":"Warmtepomp","connectionStatus":0,"operationMode":1,"zoneStatus":[{"zoneId":1,"operationStatus":1,"temperature":1},{"zoneId":2}],"tankStatus":{"operationStatus":1,"temperature":52},"parameters":{}}]}]}".

It seems it can retrieve the data but still the same error in Domoticz logging that it hasn't got the authority to the request. Even after removal of the hardware (and its devices) no luck.

This message return from the test script brings also the next question: Should it also create a device for the "tank" which is a physical boiler controlled by the inner unit of the Panasonic heatpump?

The goal to use this script is to lower the target temperature from the heatpump when my temperature measurement in the living room exceeds a threshold due to the woodstove burning.

Hope you can help me a bit furter in investigation why these errors appear and the heatpump values don't get updated.

Marcel81 commented 1 year ago

I've been digging into the code of the actual plugin and from what I can see is that the settings (e.g. fan speed, airswing etc.) mapped are especially for AC units and not specificied for a heatpump (see the reply values of the API call). Can this functionality be added?

sdamasoc commented 1 year ago

Everything is possible :)

Indeed there is actually a TODO in the code to check if the setting is supported before the create (# TODO check if device is support before creation ("airSwingLR":true,"nanoe":false,"autoMode":true,"autoSwingUD":false,"ecoNavi":false,...)).

To add this fonctionnality I will need the JSON of your device to compare with the AC unit...

Marcel81 commented 1 year ago

Yes, what else do you need apart from the already provided information 2 comments ago?

sdamasoc commented 1 year ago

Is this your full JSON response { "deviceGuid": "BXXXXXXX", "deviceType": "2", "deviceName": "Warmtepomp", "connectionStatus": 0, "operationMode": 1, "zoneStatus": [ { "zoneId": 1, "operationStatus": 1, "temperature": 1 }, { "zoneId": 2 } ], "tankStatus": { "operationStatus": 1, "temperature": 52 }, "parameters": {} } It's strage that "parameters" is empty, because it's this part that I use to update the device... What would be nice is to catch the requests sent by the cloud confort app on your phone to see which fields are updated.

Marcel81 commented 1 year ago

Yes that the response provided by the testscript. I will try to get the complete response with the url provided in different issues or let me know which one to use.

Marcel81 commented 1 year ago

The output from the json request : {"deviceGuid":"BXXXXX","deviceType":"2","deviceName":"Warmtepomp","connectionStatus":0,"operationMode":1,"zoneStatus":[{"zoneId":1,"operationStatus":1,"temperature":0},{"zoneId":2}],"tankStatus":{"operationStatus":1,"temperature":52},"parameters":{}}]}]}

The used request is: curl -s --location --request GET 'https://accsmart.panasonic.com/device/group/' --header 'Accept: application/json; charset=UTF-8' --header 'Content-Type: application/json' --header 'X-APP-TYPE: 0' --header 'X-APP-VERSION: 1.16.0' --header "X-User-Authorization: <MYTOKEN>" --header 'User-Agent: G-RAC' --data-raw ''

No Parameters filled in (maybe that's due to the original failure message).

sdamasoc commented 1 year ago

Indeed the empty parameters is the failure cause.

Can you try this command to get the details of a specific device: curl -s --location --request GET 'https://accsmart.panasonic.com/deviceStatus/now/<DEVICE_GUID>' --header 'Accept: application/json; charset=UTF-8' --header 'Content-Type: application/json' --header 'X-APP-TYPE: 0' --header 'X-APP-VERSION: 1.16.0' --header "X-User-Authorization: <TOKEN>" --header 'User-Agent: G-RAC' --data-raw '' You must replace and with your data.

Marcel81 commented 1 year ago

Hi, I tried this command and now it shows the same error message as in the logging: {"message":"Have no authority to the request","code":4300}

sdamasoc commented 1 year ago

It seems that this API is not supported on your device.

Can you try these urls: curl -s --location --request GET 'https://accsmart.panasonic.com/deviceStatus/<GUID>' --header 'Accept: application/json; charset=UTF-8' --header 'Content-Type: application/json' --header 'X-APP-TYPE: 0' --header 'X-APP-VERSION: 1.16.0' --header "X-User-Authorization: <TOKEN>" --header 'User-Agent: G-RAC' --data-raw ''

curl -s --location --request GET 'https://accsmart.panasonic.com/auth/agreement/status/' --header 'Accept: application/json; charset=UTF-8' --header 'Content-Type: application/json' --header 'X-APP-TYPE: 0' --header 'X-APP-VERSION: 1.16.0' --header "X-User-Authorization: <TOKEN>" --header 'User-Agent: G-RAC' or this one: curl -s --location --request POST 'https://accsmart.panasonic.com/deviceStatus/control/' --header 'Accept: application/json; charset=UTF-8' --header 'Content-Type: application/json' --header 'X-APP-TYPE: 0' --header 'X-APP-VERSION: 1.16.0' --header 'X-User-Authorization: <TOKEN>' --data-raw '{ "deviceGuid": "<GUID>", "parameters": { "temperatureSet": 21.0 } }'

sdamasoc commented 1 year ago

It would be great if you can use an application on your phone to catch all queries from the confort cloud app. On my iPhone I use iHTTP Tracker to trace all the queries sent to the panasonic server.

Marcel81 commented 1 year ago

Hi Apologies for the delay, it's been quite busy these days.

None of the queries gave another result nor worked. I did install the app on my phone and played around with the Comfort Cloud app adjusting temperature settings on my heatpump (Aquarea).

The url shown in there is: https://aquarea-smart.panasonic.com/remote/v1/api/devices/008007B<MydeviceID>001434545313831373030634345373130434345373138313931304300000000

The json commands for setting the heat on the tank and heatpump are: {"status":[{"deviceGuid":"008007B<MydeviceID>001434545313831373030634345373130434345373138313931304300000000","tankStatus":[{"heatSet":54}]}]}

{"status":[{"deviceGuid":"008007B<MydeviceID>001434545313831373030634345373130434345373138313931304300000000","zoneStatus":[{"zoneId":1,"heatSet":0}]}]}

Hope this helps with further investigation. There are some homebridge implementations already working maybe they have got some tips to find answers. The one I tried is built by Hernas.

sdamasoc commented 9 months ago

I've looked at your issue, but it seems that the API is completely different for heat pumps... I will take a look at other implementations to see what I can do

sdamasoc commented 9 months ago

@Marcel81 I Marcel, I found the Hernas implementations in typescript and I am able to migrate it to python but for that I would need an hardware to test. Is it possible to create an account for me to test connection api? then to turn on/off or change temperature maybe you could test it yourself so I will not change your heatpump settings.

Marcel81 commented 9 months ago

@sdamasoc Great work! Yes no problem. I've created an account for you. Sent you an email with initial instructions, please reply on that when received.

sdamasoc commented 8 months ago

New code can be found in a separate branch https://github.com/sdamasoc/domoticz_panasonic_CZ-TACG1/tree/v2.0.0 This will support Aquarea devices

sdamasoc commented 5 months ago

code merged, issue closed