sockless-coding / panasonic_cc

Panasonic Comfort Cloud - Home Assistant Component
MIT License
176 stars 38 forks source link

Failed to setup device for AC with new mainboard (other 4 still work, 5th one only with panasonic app) #12

Closed michelcve closed 3 years ago

michelcve commented 4 years ago

I've had the main board of one of my AC's replaced (because of duplicate serial number). But not what device fails to register with panasonic_cc (works in de panasonic app though).

Here is the full error I got:

2020-09-18 10:12:19 WARNING (MainThread) [custom_components.panasonic_cc] Failed to setup device: Airco Daniel (Invalid response, status code: 404 - Data: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head>
  <title>404 Not found</title>
  <style type="text/css">
    <!--
    BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}
    H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
    PRE, TT {border: 1px dotted #525D76}
    A {color : black;}A.name {color : black;}
    -->
  </style>
 </head>
 <body>
   <h1>404 Not found</h1>
   <p>
    The page you tried to access does not exist.
   </p>
 </body>
</html>
)
sockless-coding commented 4 years ago

Hi, hard to tell whats failing, though my guess is that it's still looking for the old device id. Are you using a separate account for HA? If so try logging in to the Panasonic app with that, other way might be to rename the device just to force it to update.

michelcve commented 4 years ago

@sockless-coding The mainboard was replaced before being added to the panasonic ID that I use for home assistant.

I also tried removing the integration as a whole, and reinstalling, but that didn't seem to help.

So, I installed PCAP Remote, and captured some traffic while using teh Panasonic App.

I noticed the ID of the new mainboard is somewhat different:

CS-A76C2097/20200210/M100007#

(I altered a few number, as to not publicly post my device guid, but please note that this GUID differs quite a but from the standard 'devicetype-serialnumber').

When retrieving the deviceStatus the following URL is called:

GET /deviceStatus/now/CS-A76C2097f20200210fM100007%23

Which is a bit weird, seems like the '/' is encoded as a single 'f'. The '#' is encoded as '%23', which seems like normal URL encoding.

Could it be the strange '/' encoding, that causes the URL to be incorrect in panasonic_cc, resulting in the 404 that I'm seeing?

I'm happy to help if you need more information on this. Thanks for your help!

michelcve commented 4 years ago

As I presume it might be an issue with the library you use, I took the liberty of reporting it here as well [https://github.com/lostfields/python-panasonic-comfort-cloud/issues/32]

sockless-coding commented 4 years ago

Yeah it looks that way I was just about to ask you if you could download the python lib from lostfields and run: python .\pcomfortcloud.py -r true [username] [password] list just to see how your deviceGuid looks from api, I'm guessing the guid might need some encoding.

michelcve commented 4 years ago

@sockless-coding Just an update, we figured out what went wrong (I tried a local hack, and it seems to fix the problem). The library owner will make a proper fix for it.

sockless-coding commented 4 years ago

Ah good :) I'll try to issue a new release as soon as lostfields updates the lib package.

michelcve commented 4 years ago

@sockless-coding Lostfields just made fix for this issue 2 hours ago ;-).

I should probably make a new ticket for this, but do you know whether it would be possible to support both horizontal and vertical direction settings, as well as support getting power usage information?

sockless-coding commented 4 years ago

Well you are in luck, it looks like lostfields included my pull request that fixes the Left/Right swing modes. And I also have a dev version with a daily energy sensor: ScreenShot

michelcve commented 4 years ago

@sockless-coding Ooh nice, really looking forward to that! Great job, thanks for all your efforts!

michelcve commented 3 years ago

@sockless-coding Just wondering, any idea when the fix will make it into your component?

sockless-coding commented 3 years ago

@michelcve It should be included as far as I know... Lostfields made a new release a few days back and the latest release is using it. (though I haven't looked in to his code).

michelcve commented 3 years ago

@sockless-coding Sorry, my bad. Turns out there is a problem with the fix that Lostfields made. I've notified him about it in this issue.

michelcve commented 3 years ago

@sockless-coding Lostfields just merged a fix to master, that I confirmed to be working.

sockless-coding commented 3 years ago

@michelcve Ok, he needs to publish a new version to PyPi before I can make a new version.

wdflorczyk commented 3 years ago

Hi guys! I have exactly the same problem. Is it fixed or not?

sockless-coding commented 3 years ago

@wdflorczyk We are still waiting for @lostfields to publish the fixed version of python-panasonic-comfort-cloud to pypi so HA can access it.

wdflorczyk commented 3 years ago

Hi, thank you for your reply. I asked him to do it and he did it :). "Done :-) Version 0.0.18"

sockless-coding commented 3 years ago

@wdflorczyk I've released v1.0.21 that's now using 0.0.18 of pcomfortcloud. Hopefully it contains the correct fix this time.

michelcve commented 3 years ago

@sockless-coding I've just updated, but I think v1.0.21 introduced a bug:

2020-12-22 14:06:20 ERROR (MainThread) [homeassistant.config_entries] Error sett                                                                                                             ing up entry  for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 236, in as                                                                                                             ync_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", lin                                                                                                             e 67, in async_setup_entry
    return await hass.data[DOMAIN].async_setup_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line                                                                                                              140, in async_setup_entry
    platform = await async_prepare_setup_platform(
  File "/usr/src/homeassistant/homeassistant/setup.py", line 298, in async_prepa                                                                                                             re_setup_platform
    platform = integration.get_platform(domain)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 424, in get_platfo                                                                                                             rm
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 429, in _import_pl                                                                                                             atform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_mod                                                                                                             ule
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 779, in exec_module
  File "<frozen importlib._bootstrap_external>", line 916, in get_code
  File "<frozen importlib._bootstrap_external>", line 846, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/panasonic_cc/sensor.py", line 130
    return round(self._api.current_power,2)M,|m,
michelcve commented 3 years ago

Made a seperate issue for the above mentioned error #21

michelcve commented 3 years ago

Closing this issue, because the original problem is resolved with the upgrade to v0.0.18 of pcomfortcloud (which I confirmed after manually working around issue #21 ).