flobz / psa_car_controller

Control psa car with connected_car v4 API.
GNU General Public License v3.0
403 stars 210 forks source link

ingress not working on Home Assistant #363

Closed albenex closed 1 year ago

albenex commented 2 years ago

Hi, i had a working 2.6.0 psacc addon installed inside my HA instance. updated to 3.0.3 and it couldn’t boot with eternal “Loading…” screen.

then i tried rebooting either addon and HA with no change.

i eventually uninstalled and installed again (probably losing old data) and still no change.

To Reproduce Steps to reproduce the behavior:

  1. install 3.0.3 via HA add-on psacc repo.
  2. try to launch

Config file no configuration available, also tried with clean install. same

Environment (please complete the following information):

dreimer1986 commented 2 years ago

3.0.3 was removed again. Likely because of the problems you (and me) have. I can wait for an update though as my main aim are the REST sensors and these work.

flobz commented 2 years ago

I create a repo for people who want to test the V3 https://github.com/flobz/psacc-ha-beta. Please give me feedback

albenex commented 2 years ago

Just tried. Same error as previous one.

Containerised psa_car_controller loading... 2022-06-25 16:33:39,065 :: ERROR :: Bad config 2022-06-25 16:33:39,070 :: WARNING :: Can't get language 2022-06-25 16:33:40,590 :: INFO :: update_data

Il sab 25 giu 2022, 16:13 Florian BEZANNIER @.***> ha scritto:

I create a repo for people who want to test the V3 https://github.com/flobz/psacc-ha-beta. Please give me feedback

— Reply to this email directly, view it on GitHub https://github.com/flobz/psa_car_controller/issues/363#issuecomment-1166296180, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ22U5EKVC5Y4VJPCG6GB3VQ4HX5ANCNFSM5U7GYABA . You are receiving this because you authored the thread.Message ID: @.***>

rchiileea commented 2 years ago

is this updated this weekend? the beta from last weekend just stays on loading page, I have it all running in docker on my nas at moment, but will put it over to dedicated ha machine when we get it working.

on another note I tried creating a mapdata tracker for ha and it was not to good and showed nout, but then on the docker the map does not show for me either (but trips are there). but map is just blue (but is this down to a fault with the peugeot api as I notice some times it does not update car position.

albenex commented 2 years ago

AE11C3AE-0985-4247-B37D-BF2AF5B3B61B ver. 3.0.4

alloro72 commented 2 years ago

The same issue on my setup

maedball commented 1 year ago

Since yesterday i have a similar error message in my already running environment after a hardware restart of the homeassistant Blue:

Addon Version 2.6.0:

Containerised psa_car_controller loading... 2022-09-30 21:25:54,582 :: INFO :: ["{'vin': 'RandomBIN', 'vehicle_id': 'somenumberhere', 'label': 'Grandland X Hybrid', 'brand': 'C', 'abrp_name': None, 'battery_power': 13.2, 'fuel_capacity': 43, 'max_elec_consumption': 70, 'max_fuel_consumption': 30}"] 2022-09-30 21:25:54,890 :: ERROR :: remote_refresh_token isn't defined 2022-09-30 21:25:55,508 :: ERROR :: Error during activation: {'err': 'NOK:FORBIDDEN'} 2022-09-30 21:25:55,526 :: ERROR :: get_otp_code: Traceback (most recent call last): File "/psa_car_controller/libs/psa/RemoteClient.py", line 186, in get_otp_code otp_code = self.otp.get_otp_code() File "/psa_car_controller/otp/otp.py", line 277, in get_otp_code raise ConfigException("Can't get otp code") otp.otp.ConfigException: Can't get otp code 2022-09-30 21:25:55,527 :: ERROR :: Please redo otp config 2022-09-30 21:25:56,091 :: ERROR :: Error during activation: {'err': 'NOK:FORBIDDEN'} 2022-09-30 21:25:56,092 :: ERROR :: start_remote_control failed redo otp config 2022-09-30 21:25:56,093 :: INFO :: save config change 2022-09-30 21:25:56,098 :: WARNING :: Can't get language

kurim commented 1 year ago

To 3.0.4 basically it works but only if you redirect the port to 5000 and access to 5000 directly to configure 3.0.4 If you try to use ingress to access to the ui it does not work.

I guess for some reason the call of the scrips does not work correctly for some reason. image

Containerised psa_car_controller loading...
2022-10-03 13:03:09,608 :: ERROR :: Bad config
2022-10-03 13:03:09,614 :: WARNING :: Can't get language
2022-10-03 13:03:11,429 :: INFO :: update_data
2022-10-03 13:04:04,499 :: INFO :: Starting analysis on AndroidManifest.xml
2022-10-03 13:04:04,666 :: INFO :: APK file was successfully validated!
2022-10-03 13:04:04,668 :: WARNING :: Requested API level 30 is larger than maximum we have, returning API level 28 instead.
2022-10-03 13:04:22,105 :: INFO :: save config change
2022-10-03 13:04:23,472 :: INFO :: 
Your vehicles: ["....
maedball commented 1 year ago

I can confirm. what kurim stated. Everything is working normal if you connect from "outside" with the Beta version.

Inside: HA image

Direct connect to the IP / Port image

kurim commented 1 year ago

The reason why it does not load in ingress is the following: For some reason the "dash" addon will not load correctly because of wrong url.

Log shows:

:8123/_dash-component-suites/dash/dash_table/bundle.v5_1_3m1655539387.js

the correct URL for thhe files is:

:8123/api/hassio_ingress/[randomnumber I guess]/_dash-component-suites/dash/dash_table/bundle.v5_1_3m1655539387.js

If you open this URL you will see the source of the dash part, so I think the url handling to start from current folder and not from hostname

flobz commented 1 year ago

@kurim Thanks for the investigation. I had to tweak dash so it can work with HA ingress :class MyProxyFix(ProxyFix):. It took me a lot of time and unfortunately it doesn't work anymore since I upgrade to dash v2.

PatrikNorrgard commented 1 year ago

Are you sure it´s a duplicate? Could it be the division by zero, that causes the addon to crash and refuse connections?

2022-11-07 13:36:49,930 :: INFO :: mqtt msg received: psa/RemoteServices/to/cid/OV-ACNT200001014762/VehCharge/state/ProcessManagement b'{"process_date":"2022-11-07T11:36:49Z","vin":"REDACTED_FOR_SECURITY","correlation_id":"e56d8134bee24510b491b159b002c87020221107113648982","process_code":"901","process_message":"[process.901.vehicle.asleep.key]"}' Exception in thread Thread-8: Traceback (most recent call last): File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner self.run() File "/usr/lib/python3.9/threading.py", line 892, in run self._target(*self._args, self._kwargs) File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/web/app.py", line 47, in start_app run(config_flask(*args, *kwargs)) File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/web/app.py", line 81, in config_flask importlib.import_module(view) File "/usr/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 790, in exec_module File "", line 228, in _call_with_frames_removed File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/web/view/views.py", line 399, in Charging.set_default_price(APP.myp.vehicles_list) File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/charging.py", line 45, in set_default_price Charging.set_charge_price(charge, conn, cars.get_car_by_vin(charge.vin)) File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/charging.py", line 36, in set_charge_price battery_curves = Charging.get_battery_curve(conn, charge, car) File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/charging.py", line 31, in get_battery_curve battery_curves = BatteryChargeCurve.dto_to_battery_curve(car, charge, battery_curves_dto) File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/battery_charge_curve.py", line 26, in dto_to_battery_curve km_by_kw = 0.8 battery_curves_dto[-1].autonomy / battery_capacity ZeroDivisionError: float division by zero** WARNING: dev bundles requested with serve_locally=False. This is not supported, switching to serve_locally=True

meichhorn commented 1 year ago

Similar Problems...

Tried to upgrade to 3.0.5 yesterday. Then the here known Loading...-Problem occured. Message stays 'forever'. Tried to restore the Backup (2.6.0) directly made before but unfortenately it does not work. Here the point (in 2.6.0) where i'm stuck:

Screenshot 2022-11-07 191440 Screenshot 2022-11-07 192039 Screenshot 2022-11-07 191412

Has anyone reading this an idea how i can get my (before perfectly working) configuration back again? Any idea really appreceated ;-)

Thanks in advance Markus

meichhorn commented 1 year ago

also found this in Supervisor log:

Screenshot 2022-11-07 210724

sure 4 errors and on caus i do not know yet... ;-(

kurim commented 1 year ago

Set addon to: image

And don't use ingress, just open homeassistant:5000 to access PSACC @meichhorn you must use 3.0.5, 2.x is EOL and was not updated with latest APK structure

PatrikNorrgard commented 1 year ago

Hi, I always had port to 5000, and also tried accessing from Ha-instance IP:5000 but that stopped working, after the addon updated itself to 3.0.5. Now it just refuses the connection.

Edit: Now after trying to restore old version, and upgrading back to 3.05, it is accessible again, using ha-ip:5000.

PatrikNorrgard commented 1 year ago

And now I was able to authenticate and get everything working again (excep Webui from inside HA, but I can live without that).

Thanks!

albenex commented 1 year ago

Same here, WEB UI was working on previous versions and after update it just stucks in "Loading..." but no problem as sensor are still available and way more reliable than 2.* versions.

kurim commented 1 year ago

Just to highlight:

@kurim Thanks for the investigation. I had to tweak dash so it can work with HA ingress :class MyProxyFix(ProxyFix):. It took me a lot of time and unfortunately it doesn't work anymore since I upgrade to dash v2.

Hope flobz will find a new Proxy way to get it work.

meichhorn commented 1 year ago

@kurim Thanks a lot! That was the way to go... Everything working again ;-)) (-> just open homeassistant:5000 to access PSACC_)

DavidFFerreira commented 1 year ago

Still, did everything and got Loadig page.... Here is part of the log after do OTP Config again image

Malyngo commented 1 year ago

I just upgraded to the new version and also see this issue. Starting out of the sidebar wants to load assets from :8123 instead of :5000, like others already said. Opening the url directly http://hassio.local:5000/ works.

But there is one thing I do want to add: when opening http://hassio.local:5000/, there still is one file that won't be loaded, the clientside.js (in my case http://hassio.local:5000/api/hassio_ingress/ioCQDSynKChqJcWW8iXz1qBXimb05Ble3U8xo4JdtbE/assets/clientside.js?m=1667316605.0) This one is served if I take its url and just change the port number to 8123. (So: http://hassio.local:8123/api/hassio_ingress/ioCQDSynKChqJcWW8iXz1qBXimb05Ble3U8xo4JdtbE/assets/clientside.js?m=1667316605.0 will load)

For not starting out of the sidebar, I do have a workaround: I just created a new Dashboard and added a webpage card to it with the URL of the Car controller. Set it to Panel (1 card) and it's just like before, you just need to create that Dashboard manually.

flobz commented 1 year ago

It's fixed in next version : v3.0.6. Can you try ? (release is on its way)

kurim commented 1 year ago

ok it works... the reason was that the package not correct restart after upgrade.

So sorry for confusing you

albenex commented 1 year ago

3.0.6 working as expected for me. using port 5000 i can see web interface on sidebar. also sensors are working fine

Flodu31 commented 1 year ago

It works for me in HA with the last version, I have all my history too. Thanks @flobz

dreimer1986 commented 1 year ago

The map does funny things, but that is not new. So it's fixed here, too :D

albenex commented 1 year ago

my trips and maps are not working but I think it's related to API things and not add-on

flobz commented 1 year ago

Great thanks for the feedback.