Closed raresv closed 7 months ago
I changed the code to this one, and it seems to work: Like this:
@property
def is_parking_light_supported(self) -> bool:
"""Return true if parking light is supported."""
vehicle_lights = self.attrs.get("vehicleLights")
if vehicle_lights is None:
return False
lights_status = vehicle_lights.get("lightsStatus")
if lights_status is None:
return False
value = lights_status.get("value")
return "lights" in value if value is not None else False
Maybe this helps, I did not test it much. Sorry, I should have made a pull request but I just figured I could try and solve it while reporting it :).
Hi @raresv,
All three cars I have access to do have vehicleLights.lightsStatus.value.lights
present. One of them is without paid service as well, so it shouldn't be related.
If you can, please run the plugin in the debug mode and share the response from selectivestatus
API.
In the log it should be something like this:
DEBUG (MainThread) [volkswagencarnet.vw_connection] Request for "https://emea.bff.cariad.digital/vehicle/v1/vehicles/MYCARVINNUMBER/selectivestatus?jobs=access,fuelStatus,vehicleLights,vehicleHealthInspection,measurements,charging,climatisation,automation" returned with status code [207], response:
Please remove your VIN before sharing it here.
Another option is to share your VW credentials with me (stickpins at gmail dot com) and I will check where the problem is.
I've run it but this is all it shows on that front:
DEBUG:volkswagencarnet.vw_vehicle:API endpoints: {'access': {'active': False}, 'tripStatistics': {'active': False}, 'measurements': {'active': False}, 'honkAndFlash': {'active': False}, 'parkingPosition': {'active': False}}
DEBUG:volkswagencarnet.vw_connection:HTTP GET "https://emea.bff.cariad.digital/vehicle/v1/vehicles/WVGZZZ...7/selectivestatus?jobs=access,fuelStatus,vehicleLights,vehicleHealthInspection,measurements,charging,climatisation,automation"
DEBUG:volkswagencarnet.vw_connection:HTTP GET "https://emea.bff.cariad.digital/vehicle/v2/vehicles"
DEBUG:volkswagencarnet.vw_connection:Request for "https://emea.bff.cariad.digital/vehicle/v1/vehicles/WVGZZZ....7/selectivestatus?jobs=access,fuelStatus,vehicleLights,vehicleHealthInspection,measurements,charging,climatisation,automation" returned with status code [207]
(there is no ", response:" at the end of the log item) I'll try to dig a bit more..
I did a bit of poor-man's debugging (added some logging in the code above): and apparently there is a nice error in the response instead of a good value:
Here is the vehicleLights value:
{'lightsStatus': {'error': {'message': 'Bad Gateway', 'errorTimeStamp': datetime.datetime(2024, 1, 21, 17, 6, 31, tzinfo=datetime.timezone.utc), 'info': 'Upstream service responded with an unexpected status. If the problem persists, please contact our support.', 'code': 4007, 'group': 2, 'retry': True}}}
which leads to lightStatus not being ok:
lightsStatus value:
{'error': {'message': 'Bad Gateway', 'errorTimeStamp': datetime.datetime(2024, 1, 21, 17, 6, 31, tzinfo=datetime.timezone.utc), 'info': 'Upstream service responded with an unexpected status. If the problem persists, please contact our support.', 'code': 4007, 'group': 2, 'retry': True}}
which then means trying to get the "value" item from lightStatus returns None
For context, for the other car I have the API responds nicely: (i use the sample code from you to run the library, so it does both cars in the same run)
vehicleLights value:
{'lightsStatus': {'value': {'carCapturedTimestamp': datetime.datetime(2024, 1, 21, 11, 26, 55, tzinfo=datetime.timezone.utc), 'lights': [{'name': 'right', 'status': 'off'}, {'name': 'left', 'status': 'off'}]}}}
lightsStatus value:
{'value': {'carCapturedTimestamp': datetime.datetime(2024, 1, 21, 11, 26, 55, tzinfo=datetime.timezone.utc), 'lights': [{'name': 'right', 'status': 'off'}, {'name': 'left', 'status': 'off'}]}}
so the "value" is nicely:
{'carCapturedTimestamp': datetime.datetime(2024, 1, 21, 11, 26, 55, tzinfo=datetime.timezone.utc), 'lights': [{'name': 'right', 'status': 'off'}, {'name': 'left', 'status': 'off'}]}
@raresv thanks for the details, I will fix it in the next beta. In any case, it's very strange that VW API responds this way, have no clue what could be the reason.
I think this happened for a long time already, it's not temporary. I use the home assistant addon based on this and due to this fluke it hangs while configuring the second car
@raresv please try a new beta https://github.com/robinostlund/homeassistant-volkswagencarnet/releases/tag/v4.5.1-beta4. The issue should be fixed.
I just installed the beta and I can confirm the HA integration now connects properly and loads the car information also (does not load much information, though... but that's either normal or something for me to dig into it more). But.. well done, thank you!
One of my VW cars (Tiguan) has their VW services expired (I can still see it in the mobile app, but some of the services are not available anymore). As a result of this, I think some attributes have some values which are not parsed correctly. Or maybe there is just something with the vehicleLights sensor: Although... for the other VW car I own (eGolf) , all works fine.
See trace below for Tiguan::
See extract below for the eGolf which works (parking lights parsing was ok):