skodaconnect / homeassistant-skodaconnect

Skoda Connect - A home assistant plugin to add integration with your car
Apache License 2.0
232 stars 28 forks source link

Bad Gateway / Forbidden error #8

Closed JeffreySnijders closed 3 years ago

JeffreySnijders commented 3 years ago

Hi! I was trying to setup this integration but I can't get it to work. I keep getting Bad Gateway / Forbidden errors. When I log in to the Skoda Connect portal everything works, so my credentials are correct. This is my config:

I'm running Home Assistant version: 2020.12.0 SkodaConnect integration version: 1.0.27

skodaconnect:
  username: !secret skoda_username
  password: !secret skoda_password
  scandinavian_miles: false
  imperial_units: false
  scan_interval:
    minutes: 5

And this is the errorlog:

Could not fetch tripstatistics, error: 403, message='Forbidden', url=URL('https://msg.volkswagen.de/fs-car/bs/tripstatistics/v1/skoda/CZ/vehicles/TMBAP9NE6xxxxxx/tripdata/shortTerm?newest')

Could not fetch StoredVehicleDataResponse, error: 502, message='Bad Gateway', url=URL('https://msg.volkswagen.de/fs-car/bs/vsr/v1/skoda/CZ/vehicles/TMBAP9NE6xxxxxx/status')

Could not fetch position (ClientResponseError), error: 502, message='Bad Gateway', url=URL('https://msg.volkswagen.de/fs-car/bs/cf/v1/skoda/CZ/vehicles/TMBAP9NE6xxxxxx/position')

I tried with and without the S-PIN and also resetted the S-PIN as well as the password for my account. What am I missing?

Thank you in advance!

Jeffrey

Kaibob2 commented 3 years ago

GREAT JOB!! As far as i can tell for the moment everything works perfect. Especially the switch.octavia_force_data_refresh entity is huge improvement and works as intended. Thank you for this integration. I will keep testing in the next days and build some automations around it.

Farfar commented 3 years ago

GREAT JOB!! As far as i can tell for the moment everything works perfect. Especially the switch.octavia_force_data_refresh entity is huge improvement and works as intended. Thank you for this integration. I will keep testing in the next days and build some automations around it.

Please do and report back. Especially the pre-heater if you have it on your car.

Kaibob2 commented 3 years ago

I would love to have one, but don't. Would it be an option to invert the sensors for the doors. For example binary_sensor.octavia_door_closed_left_back is off when the window is closed. I would say it's more logical if it's on when closed because it says window closed = on (true)

Farfar commented 3 years ago

Would it be an option to invert the sensors for the doors. For example binary_sensor.octavia_door_closed_left_back is off when the window is closed. I would say it's more logical if it's on when closed because it says window closed = on (true)

I agree. But the way that the binary sensor door device class works we can't invert the state. I might rename the sensors though so they make more sense.

Kaibob2 commented 3 years ago

I see. Renaming the sensors would have been my Plan B :)

lissmeister commented 3 years ago

Nice job getting the sensors working again! The parking heater switches, both heat/vent, still doesn´t work though.

I´m getting this error message and some additional traceback.

DEBUG (MainThread) [custom_components.skodaconnect.switch] Turning ON pheater_heating.
ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139712086054944] 'Vehicle' object has no attribute 'is_combustion_climatisation_supported'

Do you need any additional info?

Farfar commented 3 years ago

Nice job getting the sensors working again! The parking heater switches, both heat/vent, still doesn´t work though.

I´m getting this error message and some additional traceback.

DEBUG (MainThread) [custom_components.skodaconnect.switch] Turning ON pheater_heating.
ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139712086054944] 'Vehicle' object has no attribute 'is_combustion_climatisation_supported'

Do you need any additional info?

No I think I have what I need to find the misbehaving code. It's probably the library changes that I haven't changed correctly in the integration code. Will take a look tomorrow.

Farfar commented 3 years ago

I´m getting this error message and some additional traceback.

Could you test if changing if not self.is_combustion_climatisation_supported: to if not self.is_pheater_heating_supported: on row 359 in skodaconnect/vehicle.py ? Exact location of the file depends on where and how you installed home assistant. sudo find / -name vehicle.py should get you the path.

lissmeister commented 3 years ago

So, finally managed to access the homeassistant container through ssh in hassio and i edited the file and that seems to solve the check, but then it fails further down on row 383 in set_pheater

2021-01-28 11:21:22 ERROR (MainThread) [skodaconnect.vehicle] Failed to set parking heater to heating
2021-01-28 11:21:22 WARNING (MainThread) [skodaconnect.vehicle] Failed to set parking heater mode to heating - Failed to set parking heater to heating
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/skodaconnect/vehicle.py", line 383, in set_pheater

Ventilation fails in a similar manner 'Vehicle' object has no attribute 'pheater_climatisation'

Thanks!

Farfar commented 3 years ago

Ventilation fails in a similar manner 'Vehicle' object has no attribute 'pheater_climatisation'

New release: RC5. Hopefully this will at least make it one step further. I reworked the code some so if it still fails I might know more as to why.

lissmeister commented 3 years ago

Ventilation and heating works like a charm now, both turning on and off.

All such requests output the following in the log, but still functioning. DEBUG (MainThread) [skodaconnect.connection] Request for parking heater returned with state "unknown",

Great job fixing this. Tack!

Farfar commented 3 years ago

DEBUG (MainThread) [skodaconnect.connection] Request for parking heater returned with state "unknown",

That's because it can't determine the state from the returned data. Does that line end with a valid request ID and remaining requests?

lissmeister commented 3 years ago

Yes, request id and remaining requests are both there, sorry.

DEBUG (MainThread) [skodaconnect.connection] Request for parking heater returned with state "unknown", request id: 18534028, remaining requests: 11

Once these requests finished the icon and the toggle both became yellow/active.

DEBUG (MainThread) [custom_components.skodaconnect.sensor] Getting state of pheater_status
DEBUG (MainThread) [custom_components.skodaconnect.sensor] Getting state of pheater_duration

Is there anything else i should test?

Farfar commented 3 years ago

Once these requests finished the icon and the toggle both became yellow/active.

Excellent! Then it's only the pre heater function that doesn't return a state along with request id. The important thing is that the request id is there so it can check for status and refresh after request is finished.

I now feel confident that it will work when stable version is released. Thank you for testing! Only missing thing now is service to be able to change duration for parking heater.

lissmeister commented 3 years ago

Do you know if it's possible to get the remaining fuel range as seen in this screenshot from the app, in addition to the fuel level percentage? Days and distance are negative in HA, but positive in the app. I could of course use a value_template to flip them, but i'm guessing more users get a bit annoyed by it too. 😀

image

Farfar commented 3 years ago

Do you know if it's possible to get the remaining fuel range as seen in this screenshot from the app, in addition to the fuel level percentage?

Yes it's there already: sensor.xyzw_combustion_range. And the service intervals might change as well, the negative value makes more sense for service overdue.

lissmeister commented 3 years ago

Doh, was looking for something fuel related.. Thanks! 😆

Farfar commented 3 years ago

Closing this issue as it should be solved in current code.