panasonic_cc: Precondition Failed
Checklist
- I have verified that the account and device works in the Comfort Cloud App.
- This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
- This issue is not a duplicate issue of currently previous issues…
What version of Home Assistant Core?
core-2024.10.4
Describe the issue
Aircon dashboard went unavailable ~30 minutes ago. Reviewed logs, found ‘Precondition failed’. Logging into the Panasonic App works without issue and the Aircon can still be controlled via the app, just not HA.
Error/Debug Logs
Logger: custom_components.panasonic_cc.coordinator
Source: custom_components/panasonic_cc/coordinator.py:86
integration: Panasonic Comfort Cloud (documentation, issues)
First occurred: 11:37:36 (56 occurrences)
Last logged: 12:05:05
Error fetching device data from API: (get_status: Expected status code 200, received: 412: { "code":41201, "message":"Precondition Failed" }
Traceback (most recent call last):
File "/config/custom_components/panasonic_cc/coordinator.py", line 86, in _fetch_device_data
if await self._api_client.try_update_device(self._device):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/panasonic_cc/pcomfortcloud/apiclient.py", line 178, in try_update_device
json_response = await self._get_device_status(device.info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/panasonic_cc/pcomfortcloud/apiclient.py", line 169, in _get_device_status
json_response = await self.execute_get(self._get_device_status_now_url(device_info.guid), "get_status", 200)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/panasonic_cc/pcomfortcloud/panasonicsession.py", line 145, in execute_get
await check_response(response, function_description, expected_status_code)
File "/config/custom_components/panasonic_cc/pcomfortcloud/helpers.py", line 32, in check_response
raise exceptions.ResponseError(
custom_components.panasonic_cc.pcomfortcloud.exceptions.ResponseError: (get_status: Expected status code 200, received: 412: {
"code":41201,
"message":"Precondition Failed"
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 30
- Comments: 149 (17 by maintainers)
Version 2024.11.0 has been released
I’m going to take a look and see if I can find out what they have changed… hopefully it isn’t the activation of
x-cfc-api-keyvalidation.If anyone from Panasonic is reading this, please stop it. It makes me never want to buy any Panasonic stuff ever again.
I’ve confirmed that
x-cfc-api-keyis the reason for the 412 and that it is composed ofx-app-name,x-app-timestampand token fromx-user-authorization-v2(if authenticated). The timestamp doesn’t seem to be validated and can be reused. So the main thing is to figure out how the token affects the outcome.Please don’t all reply telling you have the same problem. I guess it is already clear that everybody has this problem. Thanks.
I’m also having the same issue here. Happened 8 hours ago
Panasonic developers tried their best to block enthusiastic users. Meanwhile, LG released the official integration for Home Assistant. I paid a lot for five air conditioners, but I decided never to buy any Panasonic products again. I really respect the author and all heroes to create this integration and tried hard to make it work every month.
Let’s remeber this next time we think about buying new Panasonic equipment… There are other, better alternatives! 😉
Same here. For Homebridge plugin also stop working with same error code.
Hi everyone,
Could we please stay focused on the original problem of this issue? I’ve enjoyed following the discussion on the local solution, but I feel the conversation has veered off-topic. It would be great to continue that discussion in a separate thread so that this space remains dedicated to updates or information related to the potential fix.
Thank you for understanding!
Peeps. Please stop replying with ‘Same here’!! Many have notifications turned on but don’t want these kind of updates.
https://tweakers.net/nieuws/228460/airconditioning-van-panasonic-is-niet-meer-aan-te-sturen-via-home-assistant.html
Got it in the news, hopefully they will answer to Tweakers 😃
Do we really have to post all this here? Can’t we just stick to the issue at hand instead of posting all indivual complaints to Panasonic? Perhaps create a new ticktet for this and move that conversation over there.
I decided to give it a go to try and reverse engineer libsecurity-lib.so but I don’t really have any experience in reverse engineering unfortunately but I do work as an embedded developer and know a little bit of assembly. After some googling and watching a short youtube video I ended up using Ghidra and have been using it for few hours now trying to decipher the createSecurityKey function.
Unfortunately it looks quite large and I have a really hard time following everything that happens but it looks like the first thing it does is to retrieve the first package signature from “[Landroid/content/pm/Signature:”. It looks like this object is an array but the first array element is retrieved from it and then it does a SHA512 on that signature and possibly a timestamp, but it doesn’t look like it’s the x-app-timestamp.
After this I can’t quite follow what happens with this SHA512 but there’s hundreds of more lines to analyze, probably with some hardcoded “magic numbers” in there.
I’m sure x-app-name, x-app-timestamp & x-user-authorization are also used to build the final string much further down but I just haven’t been able to follow. It’s not so easy when the value is retrieved by a function call to GetStringUTFChars with result stored in an unknown pointer variable pVar23 which then is used to call an unknown function which might modify &local_170 and/or &local_340 and so on…
Much further down there’s also a call to a SHA256 function. It also looks like there’s a case in the code from some debug build or environment where the function will just return a random string as the security key but I don’t think that helps us.
I send an email to Panasonic today (translated from Dutch to English by Google Translate, so sorry for mistakes):
Dear Panasonic,
For a number of years I have been using 3 Panasonic air conditioners to my satisfaction. I have an implementation in use via Home Assistant. The plugin for this is https://github.com/sockless-coding/panasonic_cc However, as a developer/hobbyist, I realize that this implementation is not official, but there are many home automation users who control their air conditioners in this way.
Since November 5 early in the morning, I/we believe that security has been further tightened and this API connection is no longer possible. Could you undo this?
It would be better if home automation users could communicate with the WiFi modules of the air conditioner itself, without having to use the cloud. For example, you can turn this on via the Comford Cloud app and accept a number of conditions, after which you can use the local API. Or, a public API from the Comford Cloud. For now it would be great if you could restore the (not entirely official) API for the many Home Assistant users who want to automate something.
Thanks in advance
On behalf of many home automation enthusiasts,
%my name%
Keep you posted!
@nelsongraca it doesn’t look like they have changed anything in the client request code/headers this time. Haven’t had time to confirm this since I had some trouble with my request snooping setup. But initial findings points to server side validation of the
x-cfc-api-keyheader, but the generation of that value is handled by theJava_com_panasonic_cn_securitylib_PSecurity_createSecurityKeymethod located inlibsecurity-lib.so…The
X-CFC-API-KEYis based on several values: The string constant “Comfort Cloud” The time sent in theX-APP-TIMESTAMPheader The key access token or null if not authenticated These values are manipulated and hashed using SHA512 manipulated some more and turned in to a 67 character long stringThere IS a way to manage locally only, but it involves building your own WiFi adapter for the AC unit and replacing the original one. There is a guide somewhere, I’ll see if I can find the link again.
UPDATE: Here’s the link: https://www.espthings.io/index.php/2023/09/02/esphome-panasonic-climate-interface/
@sockless-coding , I’m using the Panasonic Comfort Cloud app and intercepting the network requests so hopefully I can find what’s missing. I’m writing some nodejs code right now to test to see if I can control the AC from the tokens/codes I get from the different payloads.
I’m Currently keeping a markdown file to keep track of the values. Next I’ll dive into your repo to see how you’re controlling the panasonic AC in python, trying to create a working PoC right now where I can change anything at all just to test out if this works.
EDIT: I have a private repo set up, I’ll make it public once I’ve confirmed it works
EDIT2: The auth flow does error out sometimes when I proxy requests, I just retry it until it works
I mainly followed this guide on youtube on intercepting network requests from the app: https://www.youtube.com/watch?v=r7aV39-CKg4
I would like to discourage you, and others to not support the creator and author of this project. They are discriminating against those who can’t do diy even for health or body function reasons, telling anyone who can’t diy to abandon the project altogether regardless if the reason is legitimate or not. If this is the only choice, then please do not use their affiliate links as it encourages even more discrimination.
me too
Step 1 would be to get a simple request like
https://accsmart.panasonic.com/resource/resourcePathto work, this one doesn’t require authentication Headers being sent to it are:Headers are generated like this
The culprit is probably the
x-cfc-api-keySame here… maybe just to wait HA update 2024.11
@sockless-coding Great Work
pls send a paypal adress . i cant buy coffee thx
Exactly like that!!
I suggested previously to disable the constant polling in this integration which would significantly reduce the load on Panasonic’s servers and that was rejected. This was the natural outcome from that.
I ain’t admitting defeat here… ISTG, there is a way forward without having to do any hardware stuff… Here’s what I’m currently doing…
I’m using Charles proxy to proxy the requests from the panasonic comfort cloud app to my macbook. I, am then able to read all of the network requests from the panasonic comfort cloud app. What I’m trying to figure out, if there’s any way to use the tokens/codes that come from logging into the panasonic comfort cloud app…
I’m working right now so I may not have time to commit to it. Sensitive information edited out. I’ll continue to look into it but I’m currently at work right now so I won’t have time until after to write some code to test things out.
EDIT: If this succeeds, we can make temporary inputs to the extension to accept those tokens and probably some additional docs on how to get them from the auth request.
How is this discriminating? There is a knowledge bar and skill bar that needs to be met to even start with such a project. It’s simply a warning that it might be smarter to not waste your time
PCBWay seems to offer the PCB + Assembly and components. (https://www.pcbway.com/project/shareproject/espthings_io_ET_P1101_ESPHome_Panasonic_Climate_Interface_4cc10e31.html)
I’ve requested a quote and the PCB + Assembly is $29 for 2 units, only waiting for the components quote now.
If this issue is sourced on the Panasonic side and there’s little we can do at our end, isn’t it best we collaborate a bit to push them to resolution? Or should there be no coordinated effort, no chat against this thread (as there’s potentially no technical solution at our end) and we just sit around waiting for magic to happen?
My only need is energy monitoring…
I used ghidra and binary ninja to poke around last night, the first thing it seems to do is compare signatures to one of two strings (debug / release)
Figured that was an attempt to prevent us from yoinking the module and just using it
They could. But they don’t want to. They clearly replied that they not planning an official API.
@pacholoamit if the apps can calculate it so can we it’s a matter of time, I’ll try to look into the APK if I find the time.
@garmck I’m pretty sure they knew about it, also let’s try to stay on topic and focus our efforts on fixing this 🙂
A few months ago there was another project where the API got hardened, and the solution then was this code. I have no idea, tbh, but throwing out there in case it sparks some idea:
Same issue here, i’ve just send the mail as well.
update: Case No.: 00365044
Same for me 😦 but worked until now and didn’t work after a reboot a my HA
@Wyger-leystra not possible, they use MTLS from the heat pump so without getting a valid certificate the heatpump wont connect.
The amount of traffic generated by this integration is negligible to Panasonic… even if it makes 7680 requests per day… that times 1350 (HA analytics) thats 10 368 000 requests per day… How much traffic do you think the heat pump them self generate? If you look at the google play store it has 500k+ downloads… This is some package capture from my heat pump calling home:
Say 2 times per minute… 2880 * 500000 = 1 440 000 000 a few magnitudes more than the integration… and thats excluding all heatpumps controlled by apple users…
if we would be able to redirect the calls to the panasonic cloud (using a router / DNS redirect for example), do you think it would be possible to create a mock API? This way we could still use HA and the existing hardware. Like a MITM aproach?
You only need esp32, logic converter 5v <-> 3.3v and connector. No PCB needed
Even if it probably won’t help much, I have also opened a very detailed support ticket with Panasonic Germany (aircon_support_de@eu.panasonic.com).
Case number: 00365238
I really hope that Panasonic takes action here and doesn’t leave all HomeAssitant / IO Broker users in the lurch
Perhaps @sockless-coding can still work magic
That is the sourcecode used for the HW mentioned in the first link. The first link is details on one way of building the HW needed for the sourcecode:-) I strongly concidering to order the parts and build o couple of them myself. Need to get rid of the comfort cloud dependenciy at home.
I am afraid their intention is to block everything not coming from the app as much as possible …they do not want to help us.
I faced this same issue with the BYD app, as did some others with different car apps. The only solution in that case was to create an add-on which emulated, say, Android and would pass through the values from the integration to the add-on which would run that .so function and return the output back to the integration.
I’ll be digging around to check if I can find what changed @sockless-coding any findings so far?
same over here 😦
Same issue here!
Oh well at lest it’s not just me:)
Same issue here!
+1
And here too…
Same. You guys rock. Actually I have Swedish Tibber and they have also trouble to get it to work with Panasonic and they have tried in month. I have complained both to them and Panasonic. You solved this in some hours. You could sell this solution to them…. Hope you feel grate you earned it 😃
fre 8 nov. 2024 kl. 18:03 skrev jaknil0 @.***>:
Thank you so much @sockless-coding 🙇 You are awesome!
or just wait till he is online and confirms the link 😃
I think what @Wyger-leystra meant, is to mimic Panasonic Cloud for the device itself, so a proxy can intercept commands and do not let them leave the house. Not sure how feasible this is and how difficult to implement.
Do you think they didn’t know before? They didn’t wonder why so many “apps” connect to their servers every 30 seconds? Normally, the application is used several times a day, so it connects maybe 20-30 times per day? This integration connects 7680 times per day! Some other plugins / integrations had a refresh time of up to every 3 seconds! Why do you think they keep changing APIs?
It’s frustrating to see Panasonic spend their time on locking us out rather than improving the awful Comfort Cloud app.
@pacholoamit - what version of the iOS app are you running? Did you have to patch it to trust your certificate? Mine seems to be doing SSL pinning.
As I said before, it’s an external function that cannot be called natively from Python and I don’t believe that the values are static, so would need to reverse engineer the .so code.
Thanks! That helps, so far I was able to get the
bearer tokenfrom the IOS app and used it with/userinfo, this was using thehttps://authglb.digital.panasonic.comendpoints though, when I used the same bearer token with thehttps://accsmart.panasonic.com/device/groupendpoint (I found it after looking through some nodejs libraries) I’m getting a 403 unauthorized error.I’ll take a look at https://aquarea-smart.panasonic.com/ to see the requests being sent. Getting this error though, I’ll retry again in a bit.
@pacholoamit yeah that is for IOS, the certificate check is a bit annoying for the Android version… The important part is looking at the accsmart.panasonic.com calls, the auth is easy enough to handle and can be viewed in a browser if you go via https://aquarea-smart.panasonic.com/
@pacholoamit are you debugging the IOS app? When I patch the android to support my mitm cert I get the same error in the app
@marcel-st PCB + Assembly include´s all parts inkl. esp?
Got this answer from Panasonic Swedenm they didn’t even comment on the strenghtened security as of nov 5, "Hi Anders,
Thank you for your email.
Unfortunately, there is no open API or any plan for it to come. Sorry that’s not the answer you want but unfortunately it is.
Kind regards Frederick Panasonic Support"
I’m still struggling to find the correct connector for my device. Ordered three different that looked that it would fit but doesn’t 😭
Have the esp already here and configured
isn’t there a way to use that integration within HA?
They can get “Works with Home Assistant” for their marketing and product capabilities too 😉 . If everyone is writing letters to Panasonic, you could mention this https://partner.home-assistant.io/
For anyone who want to mail too: I got a file number: 00365019 aircon_support_nl@eu.panasonic.com
Just put that number in the subject and body somewhere.
I guess you can send in English too, hopefully they will understand 😛
was this raised as ticket or email? Please share guidance I think there should be a whole raft of us sending something similar.
Same here. Hoping Panasonic won’t Block and it’s just temporary issue…
Facing the same issue 😦 Appreciate all that you do for us! Thank you team!
__Logger: homeassistant.config_entries Source: config_entries.py:594 First occurred: 10:53:10 AM (2 occurrences) Last logged: 11:12:16 AM
Error setting up entry for panasonic_cc Traceback (most recent call last): File “/config/custom_components/panasonic_cc/pcomfortcloud/apiclient.py”, line 64, in start_session await self._get_groups() File “/config/custom_components/panasonic_cc/pcomfortcloud/apiclient.py”, line 79, in _get_groups self._groups = await self.execute_get( ^^^^^^^^^^^^^^^^^^^^^^^ File “/config/custom_components/panasonic_cc/pcomfortcloud/panasonicsession.py”, line 145, in execute_get await check_response(response, function_description, expected_status_code) File “/config/custom_components/panasonic_cc/pcomfortcloud/helpers.py”, line 32, in check_response raise exceptions.ResponseError( custom_components.panasonic_cc.pcomfortcloud.exceptions.ResponseError: (get_groups: Expected status code 200, received: 412: { “code”:41201, “message”:“Precondition Failed” }
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/config_entries.py”, line 594, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/config/custom_components/panasonic_cc/init.py”, line 76, in async_setup_entry await api.start_session() File “/config/custom_components/panasonic_cc/pcomfortcloud/apiclient.py”, line 67, in start_session await self.reauthenticate() File “/config/custom_components/panasonic_cc/pcomfortcloud/apiclient.py”, line 71, in reauthenticate await super().reauthenticate() File “/config/custom_components/panasonic_cc/pcomfortcloud/panasonicsession.py”, line 68, in reauthenticate await self._authentication.authenticate(self._username, self._password) File “/config/custom_components/panasonic_cc/pcomfortcloud/panasonicauthentication.py”, line 68, in authenticate await self.retrieve_client_acc() File “/config/custom_components/panasonic_cc/pcomfortcloud/panasonicauthentication.py”, line 263, in retrieve_client_acc await check_response(response, ‘get_acc_client_id’, 200) File “/config/custom_components/panasonic_cc/pcomfortcloud/helpers.py”, line 32, in check_response raise exceptions.ResponseError( custom_components.panasonic_cc.pcomfortcloud.exceptions.ResponseError: (get_acc_client_id: Expected status code 200, received: 412: { “code”:41201, “message”:“Precondition Failed” }